[Timeline] Add capabilities to test inputs

This commit is contained in:
Victor Woeltjen 2016-03-08 10:47:01 -08:00
parent 66b1a92554
commit 5ee5e7fea1

View File

@ -42,6 +42,7 @@ define([
'getModel' 'getModel'
] ]
), ),
mockRelationships,
model = testModels[id]; model = testModels[id];
mockDomainObject.getId.andReturn(id); mockDomainObject.getId.andReturn(id);
@ -53,6 +54,31 @@ define([
false; false;
}); });
if (!!model.composition) {
mockDomainObject.useCapability.andCallFake(function (c) {
return c === 'composition' &&
Promise.resolve(model.composition.map(function (id) {
return mockDomainObjects[id]
}));
});
}
if (!!model.relationships) {
mockRelationships = jasmine.createSpyObj(
'relationship',
['getRelatedObjects']
);
mockRelationships.getRelatedObjects.andCallFake(function (k) {
var ids = model.relationships[k] || [];
return Promise.resolve(ids.map(function (id) {
return mockDomainObjects[id];
}));
});
mockDomainObject.getCapability.andCallFake(function (c) {
return c === 'relationship' && mockRelationships;
});
}
mockDomainObjects[id] = mockDomainObject; mockDomainObjects[id] = mockDomainObject;
} }