mirror of
https://github.com/nasa/openmct.git
synced 2025-04-09 04:14:32 +00:00
Merge remote-tracking branch 'github-open/open139-1' into open-master
This commit is contained in:
commit
6ce4ce6ada
@ -154,7 +154,7 @@
|
||||
"provides": "creationService",
|
||||
"type": "provider",
|
||||
"implementation": "creation/CreationService.js",
|
||||
"depends": [ "persistenceService", "$q", "$log" ]
|
||||
"depends": [ "persistenceService", "now", "$q", "$log" ]
|
||||
}
|
||||
],
|
||||
"runs": [
|
||||
|
@ -42,10 +42,11 @@ define(
|
||||
* @memberof platform/commonUI/browse
|
||||
* @constructor
|
||||
*/
|
||||
function CreationService(persistenceService, $q, $log) {
|
||||
function CreationService(persistenceService, now, $q, $log) {
|
||||
this.persistenceService = persistenceService;
|
||||
this.$q = $q;
|
||||
this.$log = $log;
|
||||
this.now = now;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -114,6 +115,7 @@ define(
|
||||
// 2. Create a model with that ID in the persistence space
|
||||
// 3. Add that ID to
|
||||
return self.$q.when(uuid()).then(function (id) {
|
||||
model.persisted = self.now();
|
||||
return doPersist(persistence.getSpace(), id, model);
|
||||
}).then(function (id) {
|
||||
return addToComposition(id, parent, persistence);
|
||||
|
@ -31,6 +31,7 @@ define(
|
||||
|
||||
describe("The creation service", function () {
|
||||
var mockPersistenceService,
|
||||
mockNow,
|
||||
mockQ,
|
||||
mockLog,
|
||||
mockParentObject,
|
||||
@ -63,6 +64,7 @@ define(
|
||||
"persistenceService",
|
||||
[ "createObject" ]
|
||||
);
|
||||
mockNow = jasmine.createSpy('now');
|
||||
mockQ = { when: mockPromise, reject: mockReject };
|
||||
mockLog = jasmine.createSpyObj(
|
||||
"$log",
|
||||
@ -103,6 +105,8 @@ define(
|
||||
mockPromise(true)
|
||||
);
|
||||
|
||||
mockNow.andReturn(12321);
|
||||
|
||||
mockParentObject.getCapability.andCallFake(function (key) {
|
||||
return mockCapabilities[key];
|
||||
});
|
||||
@ -124,6 +128,7 @@ define(
|
||||
|
||||
creationService = new CreationService(
|
||||
mockPersistenceService,
|
||||
mockNow,
|
||||
mockQ,
|
||||
mockLog
|
||||
);
|
||||
@ -202,6 +207,12 @@ define(
|
||||
expect(mockLog.error).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("attaches a 'persisted' timestamp", function () {
|
||||
var model = { someKey: "some value" };
|
||||
creationService.createObject(model, mockParentObject);
|
||||
expect(model.persisted).toEqual(mockNow());
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
);
|
||||
|
Loading…
x
Reference in New Issue
Block a user