Merge pull request #4941 from edx/zub/story/tnl56-dragdropintocollapsedunittests
add tests for drag and drop unit into collapsed subsection on course out...
This commit is contained in:
@@ -11,7 +11,8 @@ define(["js/utils/drag_and_drop", "js/views/feedback_notification", "js/spec_hel
|
||||
handleClass: '.unit-drag-handle',
|
||||
droppableClass: 'ol.sortable-unit-list',
|
||||
parentLocationSelector: 'li.courseware-subsection',
|
||||
refresh: jasmine.createSpy('Spy on Unit')
|
||||
refresh: jasmine.createSpy('Spy on Unit'),
|
||||
ensureChildrenRendered: jasmine.createSpy('Spy on Unit')
|
||||
});
|
||||
}
|
||||
);
|
||||
@@ -23,7 +24,8 @@ define(["js/utils/drag_and_drop", "js/views/feedback_notification", "js/spec_hel
|
||||
handleClass: '.subsection-drag-handle',
|
||||
droppableClass: '.sortable-subsection-list',
|
||||
parentLocationSelector: 'section',
|
||||
refresh: jasmine.createSpy('Spy on Subsection')
|
||||
refresh: jasmine.createSpy('Spy on Subsection'),
|
||||
ensureChildrenRendered: jasmine.createSpy('Spy on Subsection')
|
||||
});
|
||||
}
|
||||
);
|
||||
@@ -277,6 +279,10 @@ define(["js/utils/drag_and_drop", "js/views/feedback_notification", "js/spec_hel
|
||||
expect($('#subsection-1')).not.toHaveClass('expand-on-drop');
|
||||
});
|
||||
it("expands a collapsed element when something is dropped in it", function () {
|
||||
expandElementSpy = spyOn(ContentDragger, 'expandElement').andCallThrough();
|
||||
expect(expandElementSpy).not.toHaveBeenCalled();
|
||||
expect($('#subsection-2').data('ensureChildrenRendered')).not.toHaveBeenCalled();
|
||||
|
||||
$('#subsection-2').addClass('is-collapsed');
|
||||
ContentDragger.dragState.dropDestination = $('#list-2');
|
||||
ContentDragger.dragState.attachMethod = "prepend";
|
||||
@@ -286,6 +292,10 @@ define(["js/utils/drag_and_drop", "js/views/feedback_notification", "js/spec_hel
|
||||
}, null, {
|
||||
clientX: $('#unit-1').offset().left
|
||||
});
|
||||
|
||||
// verify collapsed element expands while ensuring its children are properly rendered
|
||||
expect(expandElementSpy).toHaveBeenCalled();
|
||||
expect($('#subsection-2').data('ensureChildrenRendered')).toHaveBeenCalled();
|
||||
expect($('#subsection-2')).not.toHaveClass('is-collapsed');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user