mirror of
https://github.com/nasa/openmct.git
synced 2025-06-14 13:18:15 +00:00
[Action] RemoveAction
Adjusted unit tests for checking if traverseObject is undefined. Also removed unnecessary ROOT_ID variable.
This commit is contained in:
@ -55,8 +55,7 @@ define(
|
|||||||
RemoveAction.prototype.perform = function () {
|
RemoveAction.prototype.perform = function () {
|
||||||
var $q = this.$q,
|
var $q = this.$q,
|
||||||
navigationService = this.navigationService,
|
navigationService = this.navigationService,
|
||||||
domainObject = this.domainObject,
|
domainObject = this.domainObject;
|
||||||
ROOT_ID = "ROOT";
|
|
||||||
/*
|
/*
|
||||||
* Check whether an object ID matches the ID of the object being
|
* Check whether an object ID matches the ID of the object being
|
||||||
* removed (used to filter a parent's composition to handle the
|
* removed (used to filter a parent's composition to handle the
|
||||||
|
@ -33,9 +33,11 @@ define(
|
|||||||
mockParent,
|
mockParent,
|
||||||
mockChildObject,
|
mockChildObject,
|
||||||
mockGrandchildObject,
|
mockGrandchildObject,
|
||||||
|
mockRootObject,
|
||||||
mockContext,
|
mockContext,
|
||||||
mockChildContext,
|
mockChildContext,
|
||||||
mockGrandchildContext,
|
mockGrandchildContext,
|
||||||
|
mockRootContext,
|
||||||
mockMutation,
|
mockMutation,
|
||||||
mockPersistence,
|
mockPersistence,
|
||||||
mockType,
|
mockType,
|
||||||
@ -67,6 +69,10 @@ define(
|
|||||||
"domainObject",
|
"domainObject",
|
||||||
[ "getId", "getCapability" ]
|
[ "getId", "getCapability" ]
|
||||||
);
|
);
|
||||||
|
mockRootObject = jasmine.createSpyObj(
|
||||||
|
"domainObject",
|
||||||
|
[ "getId", "getCapability" ]
|
||||||
|
);
|
||||||
mockQ = { when: mockPromise };
|
mockQ = { when: mockPromise };
|
||||||
mockParent = {
|
mockParent = {
|
||||||
getModel: function () {
|
getModel: function () {
|
||||||
@ -82,6 +88,7 @@ define(
|
|||||||
mockContext = jasmine.createSpyObj("context", [ "getParent" ]);
|
mockContext = jasmine.createSpyObj("context", [ "getParent" ]);
|
||||||
mockChildContext = jasmine.createSpyObj("context", [ "getParent" ]);
|
mockChildContext = jasmine.createSpyObj("context", [ "getParent" ]);
|
||||||
mockGrandchildContext = jasmine.createSpyObj("context", [ "getParent" ]);
|
mockGrandchildContext = jasmine.createSpyObj("context", [ "getParent" ]);
|
||||||
|
mockRootContext = jasmine.createSpyObj("context", [ "getParent" ]);
|
||||||
mockMutation = jasmine.createSpyObj("mutation", [ "invoke" ]);
|
mockMutation = jasmine.createSpyObj("mutation", [ "invoke" ]);
|
||||||
mockPersistence = jasmine.createSpyObj("persistence", [ "persist" ]);
|
mockPersistence = jasmine.createSpyObj("persistence", [ "persist" ]);
|
||||||
mockType = jasmine.createSpyObj("type", [ "hasFeature" ]);
|
mockType = jasmine.createSpyObj("type", [ "hasFeature" ]);
|
||||||
@ -155,8 +162,6 @@ define(
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("removes parent of object currently navigated to", function () {
|
it("removes parent of object currently navigated to", function () {
|
||||||
var mutator, result;
|
|
||||||
|
|
||||||
// Navigates to child object
|
// Navigates to child object
|
||||||
mockNavigationService.getNavigation.andReturn(mockChildObject);
|
mockNavigationService.getNavigation.andReturn(mockChildObject);
|
||||||
|
|
||||||
@ -187,18 +192,18 @@ define(
|
|||||||
|
|
||||||
// domainObject (grandparent) is set as ROOT, child and grandchild
|
// domainObject (grandparent) is set as ROOT, child and grandchild
|
||||||
// are set objects not being removed
|
// are set objects not being removed
|
||||||
mockDomainObject.getId.andReturn("ROOT");
|
mockDomainObject.getId.andReturn("test 1");
|
||||||
mockChildObject.getId.andReturn("not test");
|
mockRootObject.getId.andReturn("ROOT");
|
||||||
mockGrandchildObject.getId.andReturn("not test");
|
mockChildObject.getId.andReturn("not test 2");
|
||||||
|
mockGrandchildObject.getId.andReturn("not test 3");
|
||||||
|
|
||||||
// Sets context for the grandchild, child, and domainObject
|
// Sets context for the grandchild, child, and domainObject
|
||||||
mockDomainObject.getCapability.andReturn(mockContext);
|
mockRootObject.getCapability.andReturn(mockRootContext);
|
||||||
mockChildObject.getCapability.andReturn(mockChildContext);
|
mockChildObject.getCapability.andReturn(mockChildContext);
|
||||||
mockGrandchildObject.getCapability.andReturn(mockGrandchildContext);
|
mockGrandchildObject.getCapability.andReturn(mockGrandchildContext);
|
||||||
|
|
||||||
// Parents of grandchild, child, and domainObject are set
|
// Parents of grandchild and child are set
|
||||||
mockContext.getParent.andReturn(mockParent);
|
mockChildContext.getParent.andReturn(mockRootObject);
|
||||||
mockChildContext.getParent.andReturn(mockDomainObject);
|
|
||||||
mockGrandchildContext.getParent.andReturn(mockChildObject);
|
mockGrandchildContext.getParent.andReturn(mockChildObject);
|
||||||
|
|
||||||
mockType.hasFeature.andReturn(true);
|
mockType.hasFeature.andReturn(true);
|
||||||
|
Reference in New Issue
Block a user