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 30
30
"jsdom" : " ^8.0.4" ,
31
31
"pragmatist" : " ^3.0.16" ,
32
32
"react" : " ^0.15.0-alpha.1" ,
33
+ "react-addons-shallow-compare" : " ^0.15.0-alpha.1" ,
33
34
"react-addons-test-utils" : " ^0.15.0-alpha.1" ,
34
35
"react-dom" : " ^0.15.0-alpha.1"
35
36
},
Original file line number Diff line number Diff line change 6
6
7
7
import React from 'react' ;
8
8
import TestUtils from 'react-addons-test-utils' ;
9
+ import shallowCompare from 'react-addons-shallow-compare' ;
9
10
import jsdom from 'jsdom' ;
10
11
import extendReactClass from './../src/extendReactClass' ;
11
12
@@ -52,6 +53,36 @@ describe('extendReactClass', () => {
52
53
53
54
TestUtils . renderIntoDocument ( < Component bar = 'baz' /> ) ;
54
55
} ) ;
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
+ } ) ;
55
86
} ) ;
56
87
context ( 'overwriting default styles using "styles" property of the extended component' , ( ) => {
57
88
it ( 'overwrites default styles' , ( done ) => {
You can’t perform that action at this time.
0 commit comments