mirror of
https://github.com/nasa/openmct.git
synced 2025-02-07 11:30:28 +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,
|
mockOtherObject,
|
||||||
mockActionCapability,
|
mockActionCapability,
|
||||||
mockPersistence,
|
mockPersistence,
|
||||||
|
mockContext,
|
||||||
|
mockAction,
|
||||||
handler;
|
handler;
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
|
var mockPromise = jasmine.createSpyObj('promise', ['then']);
|
||||||
|
|
||||||
mockSwimlane = jasmine.createSpyObj(
|
mockSwimlane = jasmine.createSpyObj(
|
||||||
"swimlane",
|
"swimlane",
|
||||||
[ "highlight", "highlightBottom" ]
|
[ "highlight", "highlightBottom" ]
|
||||||
@ -60,6 +64,11 @@ define(
|
|||||||
[ "getId", "getCapability", "useCapability", "hasCapability" ]
|
[ "getId", "getCapability", "useCapability", "hasCapability" ]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
mockAction = jasmine.createSpyObj('action', ['perform']);
|
||||||
|
mockAction.perform.andReturn(mockPromise);
|
||||||
|
mockPromise.then.andCallFake(function (callback) {
|
||||||
|
callback();
|
||||||
|
});
|
||||||
|
|
||||||
mockOtherObject = jasmine.createSpyObj(
|
mockOtherObject = jasmine.createSpyObj(
|
||||||
"domainObject",
|
"domainObject",
|
||||||
@ -67,20 +76,34 @@ define(
|
|||||||
);
|
);
|
||||||
mockActionCapability = jasmine.createSpyObj("action", ["perform", "getActions"]);
|
mockActionCapability = jasmine.createSpyObj("action", ["perform", "getActions"]);
|
||||||
mockPersistence = jasmine.createSpyObj("persistence", ["persist"]);
|
mockPersistence = jasmine.createSpyObj("persistence", ["persist"]);
|
||||||
|
mockContext = jasmine.createSpyObj('context', [ 'getParent' ]);
|
||||||
|
|
||||||
mockActionCapability.getActions.andReturn([{}]);
|
mockActionCapability.getActions.andReturn([mockAction]);
|
||||||
mockSwimlane.parent.domainObject.getId.andReturn('a');
|
mockSwimlane.parent.domainObject.getId.andReturn('a');
|
||||||
mockSwimlane.domainObject.getId.andReturn('b');
|
mockSwimlane.domainObject.getId.andReturn('b');
|
||||||
mockSwimlane.children[0].domainObject.getId.andReturn('c');
|
mockSwimlane.children[0].domainObject.getId.andReturn('c');
|
||||||
mockOtherObject.getId.andReturn('d');
|
mockOtherObject.getId.andReturn('d');
|
||||||
|
|
||||||
|
|
||||||
mockSwimlane.domainObject.getCapability.andCallFake(function (c) {
|
mockSwimlane.domainObject.getCapability.andCallFake(function (c) {
|
||||||
return {
|
return {
|
||||||
action: mockActionCapability,
|
action: mockActionCapability,
|
||||||
persistence: mockPersistence
|
persistence: mockPersistence
|
||||||
}[c];
|
}[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);
|
mockSwimlane.domainObject.hasCapability.andReturn(true);
|
||||||
|
|
||||||
@ -89,13 +112,17 @@ define(
|
|||||||
|
|
||||||
it("disallows drop outside of edit mode", function () {
|
it("disallows drop outside of edit mode", function () {
|
||||||
// Verify precondition
|
// Verify precondition
|
||||||
expect(handler.allowDropIn('d')).toBeTruthy();
|
expect(handler.allowDropIn('d', mockSwimlane.domainObject))
|
||||||
expect(handler.allowDropAfter('d')).toBeTruthy();
|
.toBeTruthy();
|
||||||
|
expect(handler.allowDropAfter('d', mockSwimlane.domainObject))
|
||||||
|
.toBeTruthy();
|
||||||
// Act as if we're not in edit mode
|
// Act as if we're not in edit mode
|
||||||
mockSwimlane.domainObject.hasCapability.andReturn(false);
|
mockSwimlane.domainObject.hasCapability.andReturn(false);
|
||||||
// Now, they should be disallowed
|
// Now, they should be disallowed
|
||||||
expect(handler.allowDropIn('d')).toBeFalsy();
|
expect(handler.allowDropIn('d', mockSwimlane.domainObject))
|
||||||
expect(handler.allowDropAfter('d')).toBeFalsy();
|
.toBeFalsy();
|
||||||
|
expect(handler.allowDropAfter('d', mockSwimlane.domainObject))
|
||||||
|
.toBeFalsy();
|
||||||
|
|
||||||
// Verify that editor capability was really checked for
|
// Verify that editor capability was really checked for
|
||||||
expect(mockSwimlane.domainObject.hasCapability)
|
expect(mockSwimlane.domainObject.hasCapability)
|
||||||
@ -103,8 +130,9 @@ define(
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("disallows dropping of parents", function () {
|
it("disallows dropping of parents", function () {
|
||||||
expect(handler.allowDropIn('a')).toBeFalsy();
|
var mockParent = mockSwimlane.parent.domainObject;
|
||||||
expect(handler.allowDropAfter('a')).toBeFalsy();
|
expect(handler.allowDropIn('a', mockParent)).toBeFalsy();
|
||||||
|
expect(handler.allowDropAfter('a', mockParent)).toBeFalsy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("does not drop when no highlight state is present", function () {
|
it("does not drop when no highlight state is present", function () {
|
||||||
@ -121,7 +149,7 @@ define(
|
|||||||
it("inserts into when highlighted", function () {
|
it("inserts into when highlighted", function () {
|
||||||
var testModel = { composition: [ 'c' ] };
|
var testModel = { composition: [ 'c' ] };
|
||||||
mockSwimlane.highlight.andReturn(true);
|
mockSwimlane.highlight.andReturn(true);
|
||||||
handler.drop('d');
|
handler.drop('d', mockOtherObject);
|
||||||
// Should have mutated
|
// Should have mutated
|
||||||
expect(mockSwimlane.domainObject.useCapability)
|
expect(mockSwimlane.domainObject.useCapability)
|
||||||
.toHaveBeenCalledWith("mutation", jasmine.any(Function));
|
.toHaveBeenCalledWith("mutation", jasmine.any(Function));
|
||||||
@ -133,24 +161,11 @@ define(
|
|||||||
expect(mockPersistence.persist).toHaveBeenCalled();
|
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 () {
|
it("inserts after as a peer when highlighted at the bottom", function () {
|
||||||
var testModel = { composition: [ 'x', 'b', 'y' ] };
|
var testModel = { composition: [ 'x', 'b', 'y' ] };
|
||||||
mockSwimlane.highlightBottom.andReturn(true);
|
mockSwimlane.highlightBottom.andReturn(true);
|
||||||
mockSwimlane.expanded = false;
|
mockSwimlane.expanded = false;
|
||||||
handler.drop('d');
|
handler.drop('d', mockOtherObject);
|
||||||
// Should have mutated
|
// Should have mutated
|
||||||
expect(mockSwimlane.parent.domainObject.useCapability)
|
expect(mockSwimlane.parent.domainObject.useCapability)
|
||||||
.toHaveBeenCalledWith("mutation", jasmine.any(Function));
|
.toHaveBeenCalledWith("mutation", jasmine.any(Function));
|
||||||
@ -164,7 +179,7 @@ define(
|
|||||||
var testModel = { composition: [ 'c' ] };
|
var testModel = { composition: [ 'c' ] };
|
||||||
mockSwimlane.highlightBottom.andReturn(true);
|
mockSwimlane.highlightBottom.andReturn(true);
|
||||||
mockSwimlane.expanded = true;
|
mockSwimlane.expanded = true;
|
||||||
handler.drop('d');
|
handler.drop('d', mockOtherObject);
|
||||||
// Should have mutated
|
// Should have mutated
|
||||||
expect(mockSwimlane.domainObject.useCapability)
|
expect(mockSwimlane.domainObject.useCapability)
|
||||||
.toHaveBeenCalledWith("mutation", jasmine.any(Function));
|
.toHaveBeenCalledWith("mutation", jasmine.any(Function));
|
||||||
@ -179,7 +194,7 @@ define(
|
|||||||
mockSwimlane.highlightBottom.andReturn(true);
|
mockSwimlane.highlightBottom.andReturn(true);
|
||||||
mockSwimlane.expanded = true;
|
mockSwimlane.expanded = true;
|
||||||
mockSwimlane.children = [];
|
mockSwimlane.children = [];
|
||||||
handler.drop('d');
|
handler.drop('d', mockOtherObject);
|
||||||
// Should have mutated
|
// Should have mutated
|
||||||
expect(mockSwimlane.parent.domainObject.useCapability)
|
expect(mockSwimlane.parent.domainObject.useCapability)
|
||||||
.toHaveBeenCalledWith("mutation", jasmine.any(Function));
|
.toHaveBeenCalledWith("mutation", jasmine.any(Function));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user