From 68145671162c2c0ccb6047836e6d9b1a367558a7 Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Fri, 20 Feb 2015 15:53:41 -0800 Subject: [PATCH] [Fixed Position] Update failing specs Update existing tests to account for changes from WTD-880. --- .../layout/test/FixedControllerSpec.js | 9 ++++++ .../features/layout/test/FixedProxySpec.js | 28 +++++++++++++++---- .../test/elements/ElementProxiesSpec.js | 7 ++++- 3 files changed, 37 insertions(+), 7 deletions(-) diff --git a/platform/features/layout/test/FixedControllerSpec.js b/platform/features/layout/test/FixedControllerSpec.js index 460228e362..e9b131e8fd 100644 --- a/platform/features/layout/test/FixedControllerSpec.js +++ b/platform/features/layout/test/FixedControllerSpec.js @@ -7,6 +7,8 @@ define( describe("The Fixed Position controller", function () { var mockScope, + mockQ, + mockDialogService, mockSubscriber, mockFormatter, mockDomainObject, @@ -58,6 +60,11 @@ define( 'telemetrySubscriber', [ 'subscribe' ] ); + mockQ = jasmine.createSpyObj('$q', ['when']); + mockDialogService = jasmine.createSpyObj( + 'dialogService', + ['getUserInput'] + ); mockFormatter = jasmine.createSpyObj( 'telemetryFormatter', [ 'formatDomainValue', 'formatRangeValue' ] @@ -99,6 +106,8 @@ define( controller = new FixedController( mockScope, + mockQ, + mockDialogService, mockSubscriber, mockFormatter ); diff --git a/platform/features/layout/test/FixedProxySpec.js b/platform/features/layout/test/FixedProxySpec.js index 224b19f022..f5fd464a7b 100644 --- a/platform/features/layout/test/FixedProxySpec.js +++ b/platform/features/layout/test/FixedProxySpec.js @@ -6,12 +6,28 @@ 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; + var mockCallback, + mockQ, + mockDialogService, + mockPromise, + proxy; + + beforeEach(function () { + mockCallback = jasmine.createSpy('callback'); + mockQ = jasmine.createSpyObj('$q', ['when']); + mockDialogService = jasmine.createSpyObj('dialogService', ['getUserInput']); + mockPromise = jasmine.createSpyObj('promise', ['then']); + + mockQ.when.andReturn(mockPromise); + + proxy = new FixedProxy(mockCallback, mockQ, mockDialogService); + }); + + it("handles promised element creation", function () { + // The element factory may return promises (e.g. if + // user input is required) so make sure proxy is wrapping these + proxy.add("fixed.box"); + expect(mockQ.when).toHaveBeenCalled(); }); }); } diff --git a/platform/features/layout/test/elements/ElementProxiesSpec.js b/platform/features/layout/test/elements/ElementProxiesSpec.js index cf771a043a..1e58fb8826 100644 --- a/platform/features/layout/test/elements/ElementProxiesSpec.js +++ b/platform/features/layout/test/elements/ElementProxiesSpec.js @@ -5,8 +5,13 @@ define( function (ElementProxies) { "use strict"; + // Expect these element types to have proxies var ELEMENT_TYPES = [ - "fixed.telemetry" + "fixed.telemetry", + "fixed.line", + "fixed.box", + "fixed.text", + "fixed.image" ]; // Verify that the set of proxies exposed matches the specific