[Actions] Remove Action
When an ascendant or parent or currently selected object is removed the user is navigated to the parent of the object being removed. Added variables to RemoveAction test to test removing currently selected domainObject.
This commit is contained in:
@@ -28,8 +28,10 @@ define(
|
||||
|
||||
describe("The Remove action", function () {
|
||||
var mockQ,
|
||||
mockNavigationService,
|
||||
mockDomainObject,
|
||||
mockParent,
|
||||
mockGrandparent,
|
||||
mockContext,
|
||||
mockMutation,
|
||||
mockPersistence,
|
||||
@@ -55,6 +57,20 @@ define(
|
||||
[ "getId", "getCapability" ]
|
||||
);
|
||||
mockQ = { when: mockPromise };
|
||||
mockGrandparent = {
|
||||
getModel: function () {
|
||||
return model;
|
||||
},
|
||||
getCapability: function (k) {
|
||||
return capabilities[k];
|
||||
},
|
||||
useCapability: function (k, v) {
|
||||
return capabilities[k].invoke(v);
|
||||
},
|
||||
getId: function () {
|
||||
return "test";
|
||||
}
|
||||
};
|
||||
mockParent = {
|
||||
getModel: function () {
|
||||
return model;
|
||||
@@ -64,31 +80,44 @@ define(
|
||||
},
|
||||
useCapability: function (k, v) {
|
||||
return capabilities[k].invoke(v);
|
||||
},
|
||||
getParent: function () {
|
||||
return mockGrandparent;
|
||||
}
|
||||
};
|
||||
mockContext = jasmine.createSpyObj("context", [ "getParent" ]);
|
||||
mockMutation = jasmine.createSpyObj("mutation", [ "invoke" ]);
|
||||
mockPersistence = jasmine.createSpyObj("persistence", [ "persist" ]);
|
||||
mockType = jasmine.createSpyObj("type", [ "hasFeature" ]);
|
||||
|
||||
mockNavigationService = jasmine.createSpyObj(
|
||||
"navigationService",
|
||||
[
|
||||
"getNavigation",
|
||||
"setNavigation",
|
||||
"addListener",
|
||||
"removeListener"
|
||||
]
|
||||
);
|
||||
mockNavigationService.getNavigation.andReturn(mockDomainObject);
|
||||
|
||||
|
||||
mockDomainObject.getId.andReturn("test");
|
||||
mockDomainObject.getCapability.andReturn(mockContext);
|
||||
mockContext.getParent.andReturn(mockParent);
|
||||
mockType.hasFeature.andReturn(true);
|
||||
|
||||
|
||||
capabilities = {
|
||||
mutation: mockMutation,
|
||||
persistence: mockPersistence,
|
||||
type: mockType
|
||||
};
|
||||
model = {
|
||||
composition: [ "a", "test", "b", "c" ]
|
||||
composition: [ "a", "b", "test", "c" ]
|
||||
};
|
||||
|
||||
actionContext = { domainObject: mockDomainObject };
|
||||
|
||||
action = new RemoveAction(mockQ, actionContext);
|
||||
action = new RemoveAction(mockQ, mockNavigationService, actionContext);
|
||||
});
|
||||
|
||||
it("only applies to objects with parents", function () {
|
||||
|
||||
Reference in New Issue
Block a user