From 52811787ac9596db67f61287047f3a0883c872bb Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Tue, 24 Feb 2015 14:33:11 -0800 Subject: [PATCH] [Fixed Position] Update FixedController spec Update FixedController spec to include test for updating set of elements in configuration based on changes to composition, WTD-883. --- .../layout/test/FixedControllerSpec.js | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/platform/features/layout/test/FixedControllerSpec.js b/platform/features/layout/test/FixedControllerSpec.js index 087028c44a..4d976acd7f 100644 --- a/platform/features/layout/test/FixedControllerSpec.js +++ b/platform/features/layout/test/FixedControllerSpec.js @@ -13,6 +13,7 @@ define( mockFormatter, mockDomainObject, mockSubscription, + mockPromise, testGrid, testModel, testValues, @@ -77,6 +78,10 @@ define( 'subscription', [ 'unsubscribe', 'getTelemetryObjects', 'getRangeValue' ] ); + mockPromise = jasmine.createSpyObj( + 'promise', + [ 'then' ] + ); testGrid = [ 123, 456 ]; testModel = { @@ -103,6 +108,8 @@ define( mockScope.model = testModel; mockScope.configuration = testConfiguration; mockScope.selection = []; // Act like edit mode + mockQ.when.andReturn(mockPromise); + mockPromise.then.andCallFake(function (cb) { cb({}); }); controller = new FixedController( mockScope, @@ -363,6 +370,19 @@ define( // Style should have been updated expect(controller.selected().style).not.toEqual(oldStyle); }); + + it("ensures elements in view match elements in composition", function () { + // View should ensure that at least one element is present + // for each id, and then unused ids do not have elements. + mockScope.model = testModel; + testModel.composition = [ 'b', 'd' ]; + findWatch("model.composition")(mockScope.model.composition); + + // Should have a new element for d; should not have elements for a, c + expect(testConfiguration.elements.length).toEqual(2); + expect(testConfiguration.elements[0].id).toEqual('b'); + expect(testConfiguration.elements[1].id).toEqual('d'); + }); }); } ); \ No newline at end of file