Commit 7693659e by Andy Armstrong

Address Christina's review comments

parent 6f404fe2
...@@ -8,7 +8,7 @@ define([ "jquery", "js/spec_helpers/create_sinon", "js/spec_helpers/view_helpers ...@@ -8,7 +8,7 @@ define([ "jquery", "js/spec_helpers/create_sinon", "js/spec_helpers/view_helpers
describe("Supports reordering components", function () { describe("Supports reordering components", function () {
var model, containerView, mockContainerHTML, respondWithMockXBlockFragment, init, getComponent, var model, containerView, mockContainerHTML, respondWithMockXBlockFragment, init, getComponent,
getDragHandle, dragComponentVertically, dragComponentToY, dragComponentAbove, getDragHandle, dragComponentVertically, dragComponentAbove,
verifyRequest, verifyNumReorderCalls, respondToRequest, verifyRequest, verifyNumReorderCalls, respondToRequest,
rootLocator = 'testCourse/branch/draft/split_test/splitFFF', rootLocator = 'testCourse/branch/draft/split_test/splitFFF',
...@@ -26,7 +26,6 @@ define([ "jquery", "js/spec_helpers/create_sinon", "js/spec_helpers/view_helpers ...@@ -26,7 +26,6 @@ define([ "jquery", "js/spec_helpers/create_sinon", "js/spec_helpers/view_helpers
groupBComponent2 = "locator-component-B2", groupBComponent2 = "locator-component-B2",
groupBComponent3 = "locator-component-B3"; groupBComponent3 = "locator-component-B3";
rootLocator = 'testCourse/branch/draft/split_test/splitFFF';
mockContainerHTML = readFixtures('mock/mock-container-xblock.underscore'); mockContainerHTML = readFixtures('mock/mock-container-xblock.underscore');
respondWithMockXBlockFragment = function (requests, response) { respondWithMockXBlockFragment = function (requests, response) {
...@@ -81,18 +80,15 @@ define([ "jquery", "js/spec_helpers/create_sinon", "js/spec_helpers/view_helpers ...@@ -81,18 +80,15 @@ define([ "jquery", "js/spec_helpers/create_sinon", "js/spec_helpers/view_helpers
handle.simulate("drag", {dy: dy}); handle.simulate("drag", {dy: dy});
}; };
dragComponentToY = function (locator, y) { dragComponentAbove = function (sourceLocator, targetLocator) {
var handle = getDragHandle(locator), var targetElement = getComponent(targetLocator),
targetTop = targetElement.offset().top + 1,
handle = getDragHandle(sourceLocator),
handleY = handle.offset().top + (handle.height() / 2), handleY = handle.offset().top + (handle.height() / 2),
dy = y - handleY; dy = targetTop - handleY;
handle.simulate("drag", {dy: dy}); handle.simulate("drag", {dy: dy});
}; };
dragComponentAbove = function (sourceLocator, targetLocator) {
var targetElement = getComponent(targetLocator);
dragComponentToY(sourceLocator, targetElement.offset().top + 1);
};
verifyRequest = function (requests, reorderCallIndex, expectedURL, expectedChildren) { verifyRequest = function (requests, reorderCallIndex, expectedURL, expectedChildren) {
var actualIndex, request, children, i; var actualIndex, request, children, i;
// 0th call is the response to the initial render call to get HTML. // 0th call is the response to the initial render call to get HTML.
...@@ -137,10 +133,10 @@ define([ "jquery", "js/spec_helpers/create_sinon", "js/spec_helpers/view_helpers ...@@ -137,10 +133,10 @@ define([ "jquery", "js/spec_helpers/create_sinon", "js/spec_helpers/view_helpers
it('can drag from one group to another', function () { it('can drag from one group to another', function () {
var requests = init(this); var requests = init(this);
// Drag the first component in Group B to the first group. // Drag the first component in Group B to the top of group A.
dragComponentAbove(groupBComponent1, groupAComponent1); dragComponentAbove(groupBComponent1, groupAComponent1);
// Respond to the first request which will trigger a request to make the move // Respond to the two requests: add the component to Group A, then remove it from Group B.
respondToRequest(requests, 0, 200); respondToRequest(requests, 0, 200);
respondToRequest(requests, 1, 200); respondToRequest(requests, 1, 200);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment