File tree Expand file tree Collapse file tree 3 files changed +15
-1
lines changed
Expand file tree Collapse file tree 3 files changed +15
-1
lines changed Original file line number Diff line number Diff line change 3535 "preact" : " ^5.6.0"
3636 },
3737 "dependencies" : {
38- "preact-render-to-string" : " ^2.7 .0"
38+ "preact-render-to-string" : " ^3.0 .0"
3939 },
4040 "greenkeeper" : {
4141 "ignore" : [
Original file line number Diff line number Diff line change @@ -10,6 +10,8 @@ export const options = {};
1010// options to pass to renderToString() when doing a deep comparison
1111const RENDER_OPTS = {
1212 sortAttributes : true ,
13+ xml : true ,
14+ jsx : true ,
1315 pretty : true
1416} ;
1517
Original file line number Diff line number Diff line change @@ -78,5 +78,17 @@ describe('preact-jsx-chai', () => {
7878 expect ( < Outer /> ) . to . eql ( < span b1 = "b" > 1</ span > ) ;
7979 expect ( < Outer a /> ) . not . to . eql ( < Outer b /> ) ;
8080 } ) ;
81+
82+ it ( 'should shallow-compare components with complex props' , ( ) => {
83+ let counter = 0 ;
84+ const Outer = ( ) => < Inner b = { [ 'a' , 'b' , 'c' ] } c = { { foo :'bar' } } /> ;
85+ const Inner = ( { b } ) => < span b1 = { b + '' } > { ++ counter } </ span > ;
86+ expect ( < Outer a /> ) . to . equal ( < Inner b = { [ 'a' , 'b' , 'c' ] } c = { { foo :'bar' } } /> ) ;
87+
88+ // make sure inequality within an attribute generates a failed assertion:
89+ expect ( ( ) => {
90+ expect ( < Outer a /> ) . to . equal ( < Inner b = { [ 'a' , 'c' , 'c' ] } c = { { foo :'bar' } } /> ) ;
91+ } ) . to . throw ( / " b " .* ?" c " / ) ; // really loose here, but it would fail if the assertion stopped working
92+ } ) ;
8193 } ) ;
8294} ) ;
You can’t perform that action at this time.
0 commit comments