mirror of
https://github.com/nasa/openmct.git
synced 2025-05-09 12:03:21 +00:00
Fixed failing tests
This commit is contained in:
parent
6c4c53dde7
commit
4312857fd4
@ -110,11 +110,11 @@ define(
|
|||||||
});
|
});
|
||||||
});}, $q.when(undefined)
|
});}, $q.when(undefined)
|
||||||
).then(function (){
|
).then(function (){
|
||||||
//Add the clone to the list of clones that will
|
//Add the clone to the list of clones that will
|
||||||
//be returned by this function
|
//be returned by this function
|
||||||
clones.push(modelClone);
|
clones.push(modelClone);
|
||||||
return modelClone;
|
return modelClone;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
return copy(domainObject, parent).then(function(){
|
return copy(domainObject, parent).then(function(){
|
||||||
@ -158,7 +158,7 @@ define(
|
|||||||
return function(clones) {
|
return function(clones) {
|
||||||
var parentClone = clones[clones.length-1];
|
var parentClone = clones[clones.length-1];
|
||||||
if (!parent.hasCapability('composition')){
|
if (!parent.hasCapability('composition')){
|
||||||
self.$q.reject();
|
return self.$q.reject();
|
||||||
}
|
}
|
||||||
parentClone.model.location = parent.getId();
|
parentClone.model.location = parent.getId();
|
||||||
|
|
||||||
|
@ -31,6 +31,10 @@ define(
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
function synchronousPromise(value) {
|
function synchronousPromise(value) {
|
||||||
|
if (value && value.then) {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
var promise = {
|
var promise = {
|
||||||
then: function (callback) {
|
then: function (callback) {
|
||||||
return synchronousPromise(callback(value));
|
return synchronousPromise(callback(value));
|
||||||
@ -143,10 +147,11 @@ define(
|
|||||||
|
|
||||||
mockPersistenceService = jasmine.createSpyObj(
|
mockPersistenceService = jasmine.createSpyObj(
|
||||||
'persistenceService',
|
'persistenceService',
|
||||||
['createObject']
|
['createObject', 'updateObject']
|
||||||
);
|
);
|
||||||
persistObjectPromise = synchronousPromise(undefined);
|
persistObjectPromise = synchronousPromise(undefined);
|
||||||
mockPersistenceService.createObject.andReturn(persistObjectPromise);
|
mockPersistenceService.createObject.andReturn(persistObjectPromise);
|
||||||
|
mockPersistenceService.updateObject.andReturn(persistObjectPromise);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("on domain object without composition", function () {
|
describe("on domain object without composition", function () {
|
||||||
@ -167,7 +172,15 @@ define(
|
|||||||
});
|
});
|
||||||
mockQ = jasmine.createSpyObj('mockQ', ['when', 'all', 'reject']);
|
mockQ = jasmine.createSpyObj('mockQ', ['when', 'all', 'reject']);
|
||||||
mockQ.when.andCallFake(synchronousPromise);
|
mockQ.when.andCallFake(synchronousPromise);
|
||||||
mockQ.all.andCallFake(synchronousPromise);
|
//mockQ.all.andCallFake(synchronousPromise);
|
||||||
|
mockQ.all.andCallFake(function (promises) {
|
||||||
|
var result = {};
|
||||||
|
Object.keys(promises).forEach(function (k) {
|
||||||
|
promises[k].then(function (v) { result[k] = v; });
|
||||||
|
});
|
||||||
|
return synchronousPromise(result);
|
||||||
|
});
|
||||||
|
|
||||||
copyService = new CopyService(mockQ, creationService, policyService, mockPersistenceService);
|
copyService = new CopyService(mockQ, creationService, policyService, mockPersistenceService);
|
||||||
copyResult = copyService.perform(object, newParent);
|
copyResult = copyService.perform(object, newParent);
|
||||||
copyFinished = jasmine.createSpy('copyFinished');
|
copyFinished = jasmine.createSpy('copyFinished');
|
||||||
@ -209,8 +222,16 @@ define(
|
|||||||
compositionPromise;
|
compositionPromise;
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
mockQ = jasmine.createSpyObj('mockQ', ['when']);
|
mockQ = jasmine.createSpyObj('mockQ', ['when', 'all', 'reject']);
|
||||||
mockQ.when.andCallFake(synchronousPromise);
|
mockQ.when.andCallFake(synchronousPromise);
|
||||||
|
mockQ.all.andCallFake(function (promises) {
|
||||||
|
var result = {};
|
||||||
|
Object.keys(promises).forEach(function (k) {
|
||||||
|
promises[k].then(function (v) { result[k] = v; });
|
||||||
|
});
|
||||||
|
return synchronousPromise(result);
|
||||||
|
});
|
||||||
|
|
||||||
childObject = domainObjectFactory({
|
childObject = domainObjectFactory({
|
||||||
name: 'childObject',
|
name: 'childObject',
|
||||||
id: 'def',
|
id: 'def',
|
||||||
@ -220,15 +241,19 @@ define(
|
|||||||
});
|
});
|
||||||
compositionCapability = jasmine.createSpyObj(
|
compositionCapability = jasmine.createSpyObj(
|
||||||
'compositionCapability',
|
'compositionCapability',
|
||||||
['invoke']
|
['invoke', 'add']
|
||||||
);
|
);
|
||||||
compositionPromise = jasmine.createSpyObj(
|
compositionPromise = jasmine.createSpyObj(
|
||||||
'compositionPromise',
|
'compositionPromise',
|
||||||
['then']
|
['then']
|
||||||
);
|
);
|
||||||
|
|
||||||
|
compositionPromise.then.andCallFake(synchronousPromise);
|
||||||
|
|
||||||
compositionCapability
|
compositionCapability
|
||||||
.invoke
|
.invoke
|
||||||
.andReturn(compositionPromise);
|
.andReturn(compositionPromise);
|
||||||
|
|
||||||
object = domainObjectFactory({
|
object = domainObjectFactory({
|
||||||
name: 'object',
|
name: 'object',
|
||||||
id: 'abc',
|
id: 'abc',
|
||||||
@ -263,23 +288,40 @@ define(
|
|||||||
creationService.createObject.andReturn(createObjectPromise);
|
creationService.createObject.andReturn(createObjectPromise);
|
||||||
copyService = new CopyService(mockQ, creationService, policyService);
|
copyService = new CopyService(mockQ, creationService, policyService);
|
||||||
copyResult = copyService.perform(object, newParent);
|
copyResult = copyService.perform(object, newParent);
|
||||||
|
compositionPromise.then.mostRecentCall.args[0]([childObject]);
|
||||||
copyFinished = jasmine.createSpy('copyFinished');
|
copyFinished = jasmine.createSpy('copyFinished');
|
||||||
copyResult.then(copyFinished);
|
copyResult.then(copyFinished);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("uses creation service", function () {
|
/**
|
||||||
|
* Test no longer valid due to creation service not
|
||||||
|
* being used
|
||||||
|
*/
|
||||||
|
/*it("uses creation service", function () {
|
||||||
expect(creationService.createObject)
|
expect(creationService.createObject)
|
||||||
.toHaveBeenCalledWith(jasmine.any(Object), newParent);
|
.toHaveBeenCalledWith(jasmine.any(Object), newParent);
|
||||||
|
|
||||||
|
expect(createObjectPromise.then)
|
||||||
|
.toHaveBeenCalledWith(jasmine.any(Function));
|
||||||
|
});*/
|
||||||
|
|
||||||
|
it("uses persistence service", function () {
|
||||||
|
expect(mockPersistenceService.createObject)
|
||||||
|
.toHaveBeenCalledWith(jasmine.any(Object), jasmine.any(String), newParent);
|
||||||
|
|
||||||
expect(createObjectPromise.then)
|
expect(createObjectPromise.then)
|
||||||
.toHaveBeenCalledWith(jasmine.any(Function));
|
.toHaveBeenCalledWith(jasmine.any(Function));
|
||||||
});
|
});
|
||||||
|
|
||||||
it("clears model composition", function () {
|
it("clears model composition", function () {
|
||||||
var newModel = creationService
|
/*var newModel = creationService
|
||||||
.createObject
|
.createObject
|
||||||
.mostRecentCall
|
.mostRecentCall
|
||||||
.args[0];
|
.args[0];*/
|
||||||
|
var newModel = mockPersistenceService
|
||||||
|
.createObject
|
||||||
|
.mostRecentCall
|
||||||
|
.args[2];
|
||||||
|
|
||||||
expect(newModel.composition.length).toBe(0);
|
expect(newModel.composition.length).toBe(0);
|
||||||
expect(newModel.name).toBe('some object');
|
expect(newModel.name).toBe('some object');
|
||||||
@ -329,6 +371,10 @@ define(
|
|||||||
expect(perform).toThrow();
|
expect(perform).toThrow();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
/**
|
||||||
|
* Additional tests:
|
||||||
|
* - Created and persisted dates
|
||||||
|
*/
|
||||||
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user