[Entanglement] Update specs

Update specs for move/copy/link services to account
for re-validation at time an action is performed.
nasa/openmctweb#98
This commit is contained in:
Victor Woeltjen
2015-09-22 15:42:39 -07:00
parent 119403e71c
commit 6996883b85
4 changed files with 76 additions and 54 deletions

View File

@@ -41,19 +41,24 @@ define(
}
describe("CopyService", function () {
var policyService;
beforeEach(function () {
policyService = jasmine.createSpyObj(
'policyService',
['allow']
);
policyService.allow.andReturn(true);
});
describe("validate", function () {
var policyService,
copyService,
var copyService,
object,
parentCandidate,
validate;
beforeEach(function () {
policyService = jasmine.createSpyObj(
'policyService',
['allow']
);
copyService = new CopyService(
null,
null,
@@ -148,7 +153,7 @@ define(
);
createObjectPromise = synchronousPromise(undefined);
creationService.createObject.andReturn(createObjectPromise);
copyService = new CopyService(null, creationService);
copyService = new CopyService(null, creationService, policyService);
copyResult = copyService.perform(object, newParent);
copyFinished = jasmine.createSpy('copyFinished');
copyResult.then(copyFinished);
@@ -180,7 +185,8 @@ define(
});
describe("on domainObject with composition", function () {
var childObject,
var newObject,
childObject,
compositionCapability,
compositionPromise;
@@ -216,6 +222,17 @@ define(
composition: compositionCapability
}
});
newObject = domainObjectFactory({
name: 'object',
id: 'abc2',
model: {
name: 'some object',
composition: []
},
capabilities: {
composition: compositionCapability
}
});
newParent = domainObjectFactory({
name: 'newParent',
id: '456',
@@ -227,9 +244,11 @@ define(
'creationService',
['createObject']
);
createObjectPromise = synchronousPromise(undefined);
policyService.allow.andReturn(true);
createObjectPromise = synchronousPromise(newObject);
creationService.createObject.andReturn(createObjectPromise);
copyService = new CopyService(mockQ, creationService);
copyService = new CopyService(mockQ, creationService, policyService);
copyResult = copyService.perform(object, newParent);
copyFinished = jasmine.createSpy('copyFinished');
copyResult.then(copyFinished);

View File

@@ -41,6 +41,7 @@ define(
'policyService',
['allow']
);
mockPolicyService.allow.andReturn(true);
linkService = new LinkService(mockPolicyService);
});
@@ -66,7 +67,6 @@ define(
validate = function () {
return linkService.validate(object, parentCandidate);
};
mockPolicyService.allow.andReturn(true);
});
it("does not allow invalid parentCandidate", function () {

View File

@@ -40,58 +40,57 @@ define(
var moveService,
policyService,
object,
objectContextCapability,
currentParent,
parentCandidate,
linkService;
beforeEach(function () {
objectContextCapability = jasmine.createSpyObj(
'objectContextCapability',
[
'getParent'
]
);
object = domainObjectFactory({
name: 'object',
id: 'a',
capabilities: {
context: objectContextCapability,
type: { type: 'object' }
}
});
currentParent = domainObjectFactory({
name: 'currentParent',
id: 'b'
});
objectContextCapability.getParent.andReturn(currentParent);
parentCandidate = domainObjectFactory({
name: 'parentCandidate',
model: { composition: [] },
id: 'c',
capabilities: {
type: { type: 'parentCandidate' }
}
});
policyService = jasmine.createSpyObj(
'policyService',
['allow']
);
linkService = new MockLinkService();
policyService.allow.andReturn(true);
moveService = new MoveService(policyService, linkService);
});
describe("validate", function () {
var object,
objectContextCapability,
currentParent,
parentCandidate,
validate;
var validate;
beforeEach(function () {
objectContextCapability = jasmine.createSpyObj(
'objectContextCapability',
[
'getParent'
]
);
object = domainObjectFactory({
name: 'object',
id: 'a',
capabilities: {
context: objectContextCapability,
type: { type: 'object' }
}
});
currentParent = domainObjectFactory({
name: 'currentParent',
id: 'b'
});
objectContextCapability.getParent.andReturn(currentParent);
parentCandidate = domainObjectFactory({
name: 'parentCandidate',
model: { composition: [] },
id: 'c',
capabilities: {
type: { type: 'parentCandidate' }
}
});
validate = function () {
return moveService.validate(object, parentCandidate);
};
@@ -145,14 +144,15 @@ define(
describe("perform", function () {
var object,
newParent,
actionCapability,
var actionCapability,
locationCapability,
locationPromise,
newParent,
moveResult;
beforeEach(function () {
newParent = parentCandidate;
actionCapability = jasmine.createSpyObj(
'actionCapability',
['perform']
@@ -175,7 +175,9 @@ define(
name: 'object',
capabilities: {
action: actionCapability,
location: locationCapability
location: locationCapability,
context: objectContextCapability,
type: { type: 'object' }
}
});