From c41db4f22b12aa18e16a11557aa3d19f0e236b27 Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Wed, 17 Jun 2015 20:41:40 -0700 Subject: [PATCH] [Imagery] Test policy Test policy which restricts the Imagery view to domain objects which have image telemetry. WTD-1170. --- .../test/policies/ImageryViewPolicySpec.js | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/platform/features/imagery/test/policies/ImageryViewPolicySpec.js b/platform/features/imagery/test/policies/ImageryViewPolicySpec.js index 7a22809f10..21e64cc324 100644 --- a/platform/features/imagery/test/policies/ImageryViewPolicySpec.js +++ b/platform/features/imagery/test/policies/ImageryViewPolicySpec.js @@ -30,7 +30,50 @@ define( var testView, mockDomainObject, mockTelemetry, + testMetadata, policy; + + beforeEach(function () { + testView = { key: "imagery" }; + testMetadata = {}; + mockDomainObject = jasmine.createSpyObj( + 'domainObject', + ['getId', 'getModel', 'getCapability'] + ); + mockTelemetry = jasmine.createSpyObj( + 'telemetry', + ['getMetadata'] + ); + mockDomainObject.getCapability.andCallFake(function (c) { + return c === 'telemetry' ? mockTelemetry : undefined; + }); + mockTelemetry.getMetadata.andReturn(testMetadata); + + policy = new ImageryViewPolicy(); + }); + + it("allows the imagery view for domain objects with image telemetry", function () { + testMetadata.ranges = [ { key: "foo", format: "imageUrl" } ]; + expect(policy.allow(testView, mockDomainObject)).toBeTruthy(); + }); + + it("disallows the imagery view for domain objects without image telemetry", function () { + testMetadata.ranges = [ { key: "foo", format: "somethingElse" } ]; + 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(); + }); + + it("allows other views", function () { + testView.key = "somethingElse"; + testMetadata.ranges = [ { key: "foo", format: "somethingElse" } ]; + expect(policy.allow(testView, mockDomainObject)).toBeTruthy(); + }); + }); } );