File tree 2 files changed +17
-0
lines changed
2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -280,6 +280,9 @@ export function assertion(renderFunc: () => DNode | DNode[]) {
280
280
const node = findNode ( render , wrapped ) ;
281
281
node . children = node . children || [ ] ;
282
282
let childrenResult = children ( ) ;
283
+ if ( ! Array . isArray ( childrenResult ) ) {
284
+ childrenResult = [ childrenResult ] ;
285
+ }
283
286
switch ( type ) {
284
287
case 'prepend' :
285
288
node . children = [ ...childrenResult , ...node . children ] ;
Original file line number Diff line number Diff line change @@ -758,5 +758,19 @@ describe('test renderer', () => {
758
758
) )
759
759
) ;
760
760
} ) ;
761
+
762
+ it ( 'Should wrap single children in an array when calling setChildren' , ( ) => {
763
+ const factory = create ( ) . children < string > ( ) ;
764
+ const TestWidget = factory ( ( ) => 'foo' ) ;
765
+ const App = create ( ) ( ( ) => {
766
+ return < TestWidget > bar</ TestWidget > ;
767
+ } ) ;
768
+ const WrappedTestWudget = wrap ( TestWidget ) ;
769
+
770
+ const testAssertion = assertion ( ( ) => < WrappedTestWudget > bar</ WrappedTestWudget > ) ;
771
+ const r = renderer ( ( ) => < App /> ) ;
772
+
773
+ r . expect ( testAssertion . setChildren ( WrappedTestWudget , ( ) => 'bar' ) ) ;
774
+ } ) ;
761
775
} ) ;
762
776
} ) ;
You can’t perform that action at this time.
0 commit comments