mirror of
https://github.com/nasa/openmct.git
synced 2025-01-08 22:12:42 +00:00
70 lines
2.6 KiB
JavaScript
70 lines
2.6 KiB
JavaScript
/*global define,describe,it,expect,beforeEach */
|
|
|
|
define(
|
|
[
|
|
'../../src/capabilities/LocationCapability',
|
|
'../DomainObjectFactory'
|
|
],
|
|
function (LocationCapability, domainObjectFactory) {
|
|
|
|
describe("LocationCapability", function () {
|
|
|
|
|
|
// xit("applies to objects with a context capability", function () {
|
|
// var domainObject = domainObjectFactory({
|
|
// capabilities: {
|
|
// context: true
|
|
// }
|
|
// });
|
|
// expect(LocationCapability.appliesTo(domainObject)).toBe(true);
|
|
// });
|
|
//
|
|
// xit("does not apply to objects without context capability", function () {
|
|
// var domainObject = domainObjectFactory();
|
|
// expect(LocationCapability.appliesTo(domainObject)).toBe(false);
|
|
// });
|
|
|
|
describe("instantiated with domain object", function () {
|
|
var locationCapability,
|
|
domainObject;
|
|
|
|
beforeEach(function () {
|
|
domainObject = domainObjectFactory({
|
|
capabilities: {
|
|
context: {
|
|
getPath: function() {
|
|
return [
|
|
domainObjectFactory({id: 'root'}),
|
|
domainObjectFactory({id: 'parent'}),
|
|
domainObjectFactory({id: 'me'})
|
|
];
|
|
}
|
|
}
|
|
}
|
|
});
|
|
|
|
locationCapability = new LocationCapability(domainObject);
|
|
});
|
|
|
|
it("returns location", function () {
|
|
expect(locationCapability.getLocation())
|
|
.toBe('root/parent/me');
|
|
});
|
|
|
|
it("knows when the object is an original", function () {
|
|
domainObject.model.location = 'root/parent/me';
|
|
expect(locationCapability.isOriginal()).toBe(true);
|
|
expect(locationCapability.isLink()).toBe(false);
|
|
});
|
|
|
|
it("knows when the object is a link.", function () {
|
|
domainObject.model.location = 'root/another/location/me';
|
|
expect(locationCapability.isLink()).toBe(true);
|
|
expect(locationCapability.isOriginal()).toBe(false);
|
|
});
|
|
|
|
});
|
|
});
|
|
}
|
|
);
|