mirror of
https://github.com/nasa/openmct.git
synced 2025-06-18 23:28:14 +00:00
[Creation] Store location of new objects
The creation service stores the location (the full path) to the domain object as "model.location"
This commit is contained in:
@ -38,6 +38,7 @@ define(
|
||||
mockMutationCapability,
|
||||
mockPersistenceCapability,
|
||||
mockCompositionCapability,
|
||||
mockContextCapability,
|
||||
mockCapabilities,
|
||||
creationService;
|
||||
|
||||
@ -87,16 +88,30 @@ define(
|
||||
"composition",
|
||||
["invoke"]
|
||||
);
|
||||
mockContextCapability = jasmine.createSpyObj(
|
||||
"context",
|
||||
["getPath"]
|
||||
);
|
||||
mockCapabilities = {
|
||||
mutation: mockMutationCapability,
|
||||
persistence: mockPersistenceCapability,
|
||||
composition: mockCompositionCapability
|
||||
composition: mockCompositionCapability,
|
||||
context: mockContextCapability
|
||||
};
|
||||
|
||||
mockPersistenceService.createObject.andReturn(
|
||||
mockPromise(true)
|
||||
);
|
||||
|
||||
mockContextCapability.getPath.andReturn([
|
||||
{
|
||||
getId: function () { return 'root'; }
|
||||
},
|
||||
{
|
||||
getId: function () { return 'parent'; }
|
||||
}
|
||||
]);
|
||||
|
||||
mockParentObject.getCapability.andCallFake(function (key) {
|
||||
return mockCapabilities[key];
|
||||
});
|
||||
@ -194,6 +209,15 @@ define(
|
||||
expect(mockLog.error).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("stores location on new domainObjects", function() {
|
||||
var model = { name: "my model" };
|
||||
var objectPromise = creationService.createObject(
|
||||
model,
|
||||
mockParentObject
|
||||
);
|
||||
expect(model.location).toBeDefined();
|
||||
expect(model.location.indexOf('root/parent')).toBe(0);
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user