File tree 1 file changed +47
-0
lines changed
1 file changed +47
-0
lines changed Original file line number Diff line number Diff line change @@ -338,4 +338,51 @@ describe('<SortableTree />', () => {
338
338
mount ( < TouchWrapped treeData = { [ { title : 'a' } ] } onChange = { ( ) => { } } /> )
339
339
) . toBeDefined ( ) ;
340
340
} ) ;
341
+
342
+ it ( 'loads using SortableTreeWithoutDndContext' , ( ) => {
343
+ const TestWrapped = DragDropContext ( HTML5Backend ) (
344
+ SortableTreeWithoutDndContext
345
+ ) ;
346
+
347
+ const onDragStateChanged = jest . fn ( ) ;
348
+ const treeData = [ { title : 'a' } , { title : 'b' } ] ;
349
+ const wrapper = mount (
350
+ < TestWrapped
351
+ treeData = { treeData }
352
+ onDragStateChanged = { onDragStateChanged }
353
+ onChange = { ( ) => { } }
354
+ />
355
+ ) ;
356
+
357
+ // Obtain a reference to the backend
358
+ const backend = wrapper
359
+ . instance ( )
360
+ . getManager ( )
361
+ . getBackend ( ) ;
362
+
363
+ // Retrieve our DnD-wrapped node component type
364
+ const wrappedNodeType = wrapper
365
+ . find ( SortableTreeWithoutDndContext )
366
+ . instance ( ) . nodeContentRenderer ;
367
+
368
+ // And get the first such component
369
+ const nodeInstance = wrapper
370
+ . find ( wrappedNodeType )
371
+ . first ( )
372
+ . instance ( ) ;
373
+
374
+ backend . simulateBeginDrag ( [ nodeInstance . getHandlerId ( ) ] ) ;
375
+
376
+ expect ( onDragStateChanged ) . toHaveBeenCalledWith ( {
377
+ isDragging : true ,
378
+ draggedNode : treeData [ 0 ] ,
379
+ } ) ;
380
+
381
+ backend . simulateEndDrag ( [ nodeInstance . getHandlerId ( ) ] ) ;
382
+
383
+ expect ( onDragStateChanged ) . toHaveBeenCalledWith ( {
384
+ isDragging : false ,
385
+ draggedNode : null ,
386
+ } ) ;
387
+ } ) ;
341
388
} ) ;
You can’t perform that action at this time.
0 commit comments