From 3cfcd027e0c7581c33ed288a90306d5a9496b92e Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Thu, 19 Feb 2015 13:29:43 -0800 Subject: [PATCH] [Fixed Position] Fill in specs for selection proxies Fill in specs for fixed position views selection proxies, WTD-879. --- .../features/layout/test/FixedProxySpec.js | 8 ++++- .../test/elements/AccessorMutatorSpec.js | 19 ++++++++++++ .../test/elements/ElementProxiesSpec.js | 17 ++++++++++- .../layout/test/elements/ElementProxySpec.js | 29 +++++++++++++++++++ .../test/elements/TelemetryProxySpec.js | 23 +++++++++++++++ 5 files changed, 94 insertions(+), 2 deletions(-) diff --git a/platform/features/layout/test/FixedProxySpec.js b/platform/features/layout/test/FixedProxySpec.js index d1b2daff0d..224b19f022 100644 --- a/platform/features/layout/test/FixedProxySpec.js +++ b/platform/features/layout/test/FixedProxySpec.js @@ -6,7 +6,13 @@ define( "use strict"; describe("Fixed Position view's selection proxy", function () { - + it("has a placeholder message when clicked", function () { + var oldAlert = window.alert; + window.alert = jasmine.createSpy('alert'); + new FixedProxy({}).add(''); + expect(window.alert).toHaveBeenCalledWith(jasmine.any(String)); + window.alert = oldAlert; + }); }); } ); diff --git a/platform/features/layout/test/elements/AccessorMutatorSpec.js b/platform/features/layout/test/elements/AccessorMutatorSpec.js index 0936034e98..afcede7176 100644 --- a/platform/features/layout/test/elements/AccessorMutatorSpec.js +++ b/platform/features/layout/test/elements/AccessorMutatorSpec.js @@ -6,6 +6,25 @@ define( "use strict"; describe("An accessor-mutator", function () { + var testObject, + am; + + beforeEach(function () { + testObject = { t: 42, other: 100 }; + am = new AccessorMutator(testObject, 't'); + }); + + it("allows access to a property", function () { + expect(am()).toEqual(42); + }); + + it("allows mutation of a property", function () { + expect(am("some other value")).toEqual("some other value"); + expect(testObject).toEqual({ + t: "some other value", + other: 100 + }); + }); }); } diff --git a/platform/features/layout/test/elements/ElementProxiesSpec.js b/platform/features/layout/test/elements/ElementProxiesSpec.js index 4382b8dbf9..cf771a043a 100644 --- a/platform/features/layout/test/elements/ElementProxiesSpec.js +++ b/platform/features/layout/test/elements/ElementProxiesSpec.js @@ -5,8 +5,23 @@ define( function (ElementProxies) { "use strict"; - describe("The set of element proxies", function () { + var ELEMENT_TYPES = [ + "fixed.telemetry" + ]; + // Verify that the set of proxies exposed matches the specific + // list above. + describe("The set of element proxies", function () { + ELEMENT_TYPES.forEach(function (t) { + it("exposes a proxy wrapper for " + t + " elements", function () { + expect(typeof ElementProxies[t]).toEqual('function'); + }); + }); + + it("exposes no additional wrappers", function () { + expect(Object.keys(ElementProxies).length) + .toEqual(ELEMENT_TYPES.length); + }); }); } ); diff --git a/platform/features/layout/test/elements/ElementProxySpec.js b/platform/features/layout/test/elements/ElementProxySpec.js index 02c948940f..e2a9c2880e 100644 --- a/platform/features/layout/test/elements/ElementProxySpec.js +++ b/platform/features/layout/test/elements/ElementProxySpec.js @@ -6,7 +6,36 @@ define( "use strict"; describe("A fixed position element proxy", function () { + var testElement, + testElements, + proxy; + beforeEach(function () { + testElement = { + x: 1, + y: 2, + z: 3, + width: 42, + height: 24 + }; + testElements = [ {}, {}, testElement, {} ]; + proxy = new ElementProxy( + testElement, + testElements.indexOf(testElement), + testElements + ); + }); + + it("exposes element properties", function () { + Object.keys(testElement).forEach(function (k) { + expect(proxy[k]()).toEqual(testElement[k]); + }); + }); + + it("allows elements to be removed", function () { + proxy.remove(); + expect(testElements).toEqual([{}, {}, {}]); + }); }); } ); diff --git a/platform/features/layout/test/elements/TelemetryProxySpec.js b/platform/features/layout/test/elements/TelemetryProxySpec.js index ad63f34a67..fdd7e555d0 100644 --- a/platform/features/layout/test/elements/TelemetryProxySpec.js +++ b/platform/features/layout/test/elements/TelemetryProxySpec.js @@ -6,7 +6,30 @@ define( "use strict"; describe("A fixed position telemetry proxy", function () { + var testElement, + testElements, + proxy; + beforeEach(function () { + testElement = { + x: 1, + y: 2, + z: 3, + width: 42, + height: 24, + id: "test-id" + }; + testElements = [ {}, {}, testElement, {} ]; + proxy = new TelemetryProxy( + testElement, + testElements.indexOf(testElement), + testElements + ); + }); + + it("exposes the element's id", function () { + expect(proxy.id).toEqual('test-id'); + }); }); } );