File tree Expand file tree Collapse file tree 2 files changed +32
-0
lines changed
Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Original file line number Diff line number Diff line change 3030 "jsdom" : " ^8.0.4" ,
3131 "pragmatist" : " ^3.0.16" ,
3232 "react" : " ^0.15.0-alpha.1" ,
33+ "react-addons-shallow-compare" : " ^0.14.7" ,
3334 "react-addons-test-utils" : " ^0.15.0-alpha.1" ,
3435 "react-dom" : " ^0.15.0-alpha.1"
3536 },
Original file line number Diff line number Diff line change 66
77import React from 'react' ;
88import TestUtils from 'react-addons-test-utils' ;
9+ import shallowCompare from 'react-addons-shallow-compare' ;
910import jsdom from 'jsdom' ;
1011import extendReactClass from './../src/extendReactClass' ;
1112
@@ -52,6 +53,36 @@ describe('extendReactClass', () => {
5253
5354 TestUtils . renderIntoDocument ( < Component bar = 'baz' /> ) ;
5455 } ) ;
56+ it ( 'does not affect pure-render logic' , ( done ) => {
57+ let Component ,
58+ instance ,
59+ rendered = false ;
60+
61+ const styles = {
62+ foo : 'foo-1'
63+ } ;
64+
65+ Component = class extends React . Component {
66+ shouldComponentUpdate ( newProps ) {
67+ if ( rendered ) {
68+ expect ( shallowCompare ( this . props , newProps ) ) . to . be . true ;
69+ done ( ) ;
70+ }
71+ return true ;
72+ }
73+
74+ render ( ) {
75+ rendered = true ;
76+ }
77+ } ;
78+
79+ Component = extendReactClass ( Component , styles ) ;
80+
81+ instance = TestUtils . renderIntoDocument ( < Component foo = 'bar' /> ) ;
82+
83+ // trigger shouldComponentUpdate
84+ instance . setState ( { } ) ;
85+ } ) ;
5586 } ) ;
5687 context ( 'overwriting default styles using "styles" property of the extended component' , ( ) => {
5788 it ( 'overwrites default styles' , ( done ) => {
You can’t perform that action at this time.
0 commit comments