mirror of
https://github.com/nasa/openmct.git
synced 2025-06-01 15:10:50 +00:00
parent
7513f24ff3
commit
b2333d83d2
@ -26,14 +26,17 @@ define(
|
|||||||
|
|
||||||
describe("Imagery view policy", function () {
|
describe("Imagery view policy", function () {
|
||||||
var testView,
|
var testView,
|
||||||
|
openmct,
|
||||||
mockDomainObject,
|
mockDomainObject,
|
||||||
mockTelemetry,
|
mockTelemetry,
|
||||||
testMetadata,
|
mockMetadata,
|
||||||
policy;
|
policy;
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
testView = { key: "imagery" };
|
testView = { key: "imagery" };
|
||||||
testMetadata = {};
|
mockMetadata = jasmine.createSpyObj('metadata', [
|
||||||
|
"valuesForHints"
|
||||||
|
]);
|
||||||
mockDomainObject = jasmine.createSpyObj(
|
mockDomainObject = jasmine.createSpyObj(
|
||||||
'domainObject',
|
'domainObject',
|
||||||
['getId', 'getModel', 'getCapability']
|
['getId', 'getModel', 'getCapability']
|
||||||
@ -45,30 +48,33 @@ define(
|
|||||||
mockDomainObject.getCapability.andCallFake(function (c) {
|
mockDomainObject.getCapability.andCallFake(function (c) {
|
||||||
return c === 'telemetry' ? mockTelemetry : undefined;
|
return c === 'telemetry' ? mockTelemetry : undefined;
|
||||||
});
|
});
|
||||||
mockTelemetry.getMetadata.andReturn(testMetadata);
|
mockDomainObject.getId.andReturn("some-id");
|
||||||
|
mockDomainObject.getModel.andReturn({ name: "foo" });
|
||||||
|
mockTelemetry.getMetadata.andReturn(mockMetadata);
|
||||||
|
mockMetadata.valuesForHints.andReturn(["bar"]);
|
||||||
|
|
||||||
policy = new ImageryViewPolicy();
|
openmct = { telemetry: mockTelemetry };
|
||||||
|
|
||||||
|
policy = new ImageryViewPolicy(openmct);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("checks for hints indicating image telemetry", function () {
|
||||||
|
policy.allow(testView, mockDomainObject);
|
||||||
|
expect(mockMetadata.valuesForHints)
|
||||||
|
.toHaveBeenCalledWith(["image"]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("allows the imagery view for domain objects with image telemetry", function () {
|
it("allows the imagery view for domain objects with image telemetry", function () {
|
||||||
testMetadata.ranges = [{ key: "foo", format: "imageUrl" }];
|
|
||||||
expect(policy.allow(testView, mockDomainObject)).toBeTruthy();
|
expect(policy.allow(testView, mockDomainObject)).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("disallows the imagery view for domain objects without image telemetry", function () {
|
it("disallows the imagery view for domain objects without image telemetry", function () {
|
||||||
testMetadata.ranges = [{ key: "foo", format: "somethingElse" }];
|
mockMetadata.valuesForHints.andReturn([]);
|
||||||
expect(policy.allow(testView, mockDomainObject)).toBeFalsy();
|
|
||||||
});
|
|
||||||
|
|
||||||
it("disallows the imagery view for domain objects without telemetry", function () {
|
|
||||||
testMetadata.ranges = [{ key: "foo", format: "imageUrl" }];
|
|
||||||
mockDomainObject.getCapability.andReturn(undefined);
|
|
||||||
expect(policy.allow(testView, mockDomainObject)).toBeFalsy();
|
expect(policy.allow(testView, mockDomainObject)).toBeFalsy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("allows other views", function () {
|
it("allows other views", function () {
|
||||||
testView.key = "somethingElse";
|
testView.key = "somethingElse";
|
||||||
testMetadata.ranges = [{ key: "foo", format: "somethingElse" }];
|
|
||||||
expect(policy.allow(testView, mockDomainObject)).toBeTruthy();
|
expect(policy.allow(testView, mockDomainObject)).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user