[Layout] Fill in non-layout specs

Complete specs for scripts introduced in support of
Layout objects/views. WTD-535.
This commit is contained in:
Victor Woeltjen
2014-12-05 16:27:32 -08:00
parent d3f0505385
commit ecb4283df0
4 changed files with 261 additions and 34 deletions

View File

@@ -6,31 +6,56 @@ define(
"use strict";
describe("A gesture representer", function () {
var mockGestureService,
mockGestureHandle,
mockScope,
mockElement,
representer;
// it("attaches declared gestures, and detaches on refresh", function () {
// mctRepresentation.link(mockScope, mockElement);
//
// mockScope.key = "uvw";
// mockScope.domainObject = mockDomainObject;
//
// // Trigger the watch
// mockScope.$watch.mostRecentCall.args[1]();
//
// expect(mockGestureService.attachGestures).toHaveBeenCalledWith(
// mockElement,
// mockDomainObject,
// [ "testGesture", "otherTestGesture" ]
// );
//
// expect(mockGestureHandle.destroy).not.toHaveBeenCalled();
//
// // Refresh, expect a detach
// mockScope.key = "abc";
// mockScope.$watch.mostRecentCall.args[1]();
//
// // Should have destroyed those old gestures
// expect(mockGestureHandle.destroy).toHaveBeenCalled();
// });
beforeEach(function () {
mockGestureService = jasmine.createSpyObj(
"gestureService",
[ "attachGestures" ]
);
mockGestureHandle = jasmine.createSpyObj(
"gestureHandle",
[ "destroy" ]
);
mockElement = { someKey: "some value" };
mockGestureService.attachGestures.andReturn(mockGestureHandle);
representer = new GestureRepresenter(
mockGestureService,
undefined, // Scope is not used
mockElement
);
});
it("attaches declared gestures, and detaches on request", function () {
// Pass in some objects, which we expect to be passed into the
// gesture service accordingly.
var domainObject = { someOtherKey: "some other value" },
representation = { gestures: ["a", "b", "c"] };
representer.represent(representation, domainObject);
expect(mockGestureService.attachGestures).toHaveBeenCalledWith(
mockElement,
domainObject,
[ "a", "b", "c" ]
);
// Should not have been destroyed yet...
expect(mockGestureHandle.destroy).not.toHaveBeenCalled();
// Destroy
representer.destroy();
// Should have destroyed those old gestures
expect(mockGestureHandle.destroy).toHaveBeenCalled();
});
});
}