mirror of
https://github.com/nasa/openmct.git
synced 2025-01-19 03:06:54 +00:00
[Timeline] Update failing specs
...and remove obsolete test case for handling drops in a timeline
This commit is contained in:
parent
dea6554e04
commit
b2337dea97
@ -31,9 +31,13 @@ define(
|
||||
mockOtherObject,
|
||||
mockActionCapability,
|
||||
mockPersistence,
|
||||
mockContext,
|
||||
mockAction,
|
||||
handler;
|
||||
|
||||
beforeEach(function () {
|
||||
var mockPromise = jasmine.createSpyObj('promise', ['then']);
|
||||
|
||||
mockSwimlane = jasmine.createSpyObj(
|
||||
"swimlane",
|
||||
[ "highlight", "highlightBottom" ]
|
||||
@ -60,6 +64,11 @@ define(
|
||||
[ "getId", "getCapability", "useCapability", "hasCapability" ]
|
||||
);
|
||||
|
||||
mockAction = jasmine.createSpyObj('action', ['perform']);
|
||||
mockAction.perform.andReturn(mockPromise);
|
||||
mockPromise.then.andCallFake(function (callback) {
|
||||
callback();
|
||||
});
|
||||
|
||||
mockOtherObject = jasmine.createSpyObj(
|
||||
"domainObject",
|
||||
@ -67,20 +76,34 @@ define(
|
||||
);
|
||||
mockActionCapability = jasmine.createSpyObj("action", ["perform", "getActions"]);
|
||||
mockPersistence = jasmine.createSpyObj("persistence", ["persist"]);
|
||||
mockContext = jasmine.createSpyObj('context', [ 'getParent' ]);
|
||||
|
||||
mockActionCapability.getActions.andReturn([{}]);
|
||||
mockActionCapability.getActions.andReturn([mockAction]);
|
||||
mockSwimlane.parent.domainObject.getId.andReturn('a');
|
||||
mockSwimlane.domainObject.getId.andReturn('b');
|
||||
mockSwimlane.children[0].domainObject.getId.andReturn('c');
|
||||
mockOtherObject.getId.andReturn('d');
|
||||
|
||||
|
||||
mockSwimlane.domainObject.getCapability.andCallFake(function (c) {
|
||||
return {
|
||||
action: mockActionCapability,
|
||||
persistence: mockPersistence
|
||||
}[c];
|
||||
});
|
||||
mockOtherObject.getCapability.andReturn(mockActionCapability);
|
||||
mockSwimlane.parent.domainObject.getCapability.andCallFake(function (c) {
|
||||
return {
|
||||
action: mockActionCapability,
|
||||
persistence: mockPersistence
|
||||
}[c];
|
||||
});
|
||||
mockOtherObject.getCapability.andCallFake(function (c) {
|
||||
return {
|
||||
action: mockActionCapability,
|
||||
context: mockContext
|
||||
}[c];
|
||||
});
|
||||
mockContext.getParent.andReturn(mockOtherObject);
|
||||
|
||||
mockSwimlane.domainObject.hasCapability.andReturn(true);
|
||||
|
||||
@ -89,13 +112,17 @@ define(
|
||||
|
||||
it("disallows drop outside of edit mode", function () {
|
||||
// Verify precondition
|
||||
expect(handler.allowDropIn('d')).toBeTruthy();
|
||||
expect(handler.allowDropAfter('d')).toBeTruthy();
|
||||
expect(handler.allowDropIn('d', mockSwimlane.domainObject))
|
||||
.toBeTruthy();
|
||||
expect(handler.allowDropAfter('d', mockSwimlane.domainObject))
|
||||
.toBeTruthy();
|
||||
// Act as if we're not in edit mode
|
||||
mockSwimlane.domainObject.hasCapability.andReturn(false);
|
||||
// Now, they should be disallowed
|
||||
expect(handler.allowDropIn('d')).toBeFalsy();
|
||||
expect(handler.allowDropAfter('d')).toBeFalsy();
|
||||
expect(handler.allowDropIn('d', mockSwimlane.domainObject))
|
||||
.toBeFalsy();
|
||||
expect(handler.allowDropAfter('d', mockSwimlane.domainObject))
|
||||
.toBeFalsy();
|
||||
|
||||
// Verify that editor capability was really checked for
|
||||
expect(mockSwimlane.domainObject.hasCapability)
|
||||
@ -103,8 +130,9 @@ define(
|
||||
});
|
||||
|
||||
it("disallows dropping of parents", function () {
|
||||
expect(handler.allowDropIn('a')).toBeFalsy();
|
||||
expect(handler.allowDropAfter('a')).toBeFalsy();
|
||||
var mockParent = mockSwimlane.parent.domainObject;
|
||||
expect(handler.allowDropIn('a', mockParent)).toBeFalsy();
|
||||
expect(handler.allowDropAfter('a', mockParent)).toBeFalsy();
|
||||
});
|
||||
|
||||
it("does not drop when no highlight state is present", function () {
|
||||
@ -121,7 +149,7 @@ define(
|
||||
it("inserts into when highlighted", function () {
|
||||
var testModel = { composition: [ 'c' ] };
|
||||
mockSwimlane.highlight.andReturn(true);
|
||||
handler.drop('d');
|
||||
handler.drop('d', mockOtherObject);
|
||||
// Should have mutated
|
||||
expect(mockSwimlane.domainObject.useCapability)
|
||||
.toHaveBeenCalledWith("mutation", jasmine.any(Function));
|
||||
@ -133,24 +161,11 @@ define(
|
||||
expect(mockPersistence.persist).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("removes objects before insertion, if provided", function () {
|
||||
var testModel = { composition: [ 'c' ] };
|
||||
mockSwimlane.highlight.andReturn(true);
|
||||
handler.drop('d', mockOtherObject);
|
||||
// Should have invoked a remove action
|
||||
expect(mockActionCapability.perform)
|
||||
.toHaveBeenCalledWith('remove');
|
||||
// Verify that mutator still ran as expected
|
||||
mockSwimlane.domainObject.useCapability.mostRecentCall
|
||||
.args[1](testModel);
|
||||
expect(testModel.composition).toEqual(['c', 'd']);
|
||||
});
|
||||
|
||||
it("inserts after as a peer when highlighted at the bottom", function () {
|
||||
var testModel = { composition: [ 'x', 'b', 'y' ] };
|
||||
mockSwimlane.highlightBottom.andReturn(true);
|
||||
mockSwimlane.expanded = false;
|
||||
handler.drop('d');
|
||||
handler.drop('d', mockOtherObject);
|
||||
// Should have mutated
|
||||
expect(mockSwimlane.parent.domainObject.useCapability)
|
||||
.toHaveBeenCalledWith("mutation", jasmine.any(Function));
|
||||
@ -164,7 +179,7 @@ define(
|
||||
var testModel = { composition: [ 'c' ] };
|
||||
mockSwimlane.highlightBottom.andReturn(true);
|
||||
mockSwimlane.expanded = true;
|
||||
handler.drop('d');
|
||||
handler.drop('d', mockOtherObject);
|
||||
// Should have mutated
|
||||
expect(mockSwimlane.domainObject.useCapability)
|
||||
.toHaveBeenCalledWith("mutation", jasmine.any(Function));
|
||||
@ -179,7 +194,7 @@ define(
|
||||
mockSwimlane.highlightBottom.andReturn(true);
|
||||
mockSwimlane.expanded = true;
|
||||
mockSwimlane.children = [];
|
||||
handler.drop('d');
|
||||
handler.drop('d', mockOtherObject);
|
||||
// Should have mutated
|
||||
expect(mockSwimlane.parent.domainObject.useCapability)
|
||||
.toHaveBeenCalledWith("mutation", jasmine.any(Function));
|
||||
|
Loading…
Reference in New Issue
Block a user