From cde173dbdc8afc5c2f69a956cc8e2bc24a59ce18 Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Wed, 20 May 2015 16:39:49 -0700 Subject: [PATCH] [Representation] Add test for scope clearing Add test clearing to verify that scope gets cleared on view changes, WTD-1182. --- .../test/MCTRepresentationSpec.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/platform/representation/test/MCTRepresentationSpec.js b/platform/representation/test/MCTRepresentationSpec.js index 835c40b71b..45e88daca5 100644 --- a/platform/representation/test/MCTRepresentationSpec.js +++ b/platform/representation/test/MCTRepresentationSpec.js @@ -160,6 +160,25 @@ define( // Should have gotten a warning - that's an unknown key expect(mockLog.warn).toHaveBeenCalled(); }); + + it("clears out obsolete peroperties from scope", function () { + mctRepresentation.link(mockScope, mockElement); + + mockScope.key = "def"; + mockScope.domainObject = mockDomainObject; + mockDomainObject.useCapability.andReturn("some value"); + + // Trigger the watch + mockScope.$watch.calls[0].args[1](); + expect(mockScope.testCapability).toBeDefined(); + + // Change the view + mockScope.key = "xyz"; + + // Trigger the watch again; should clear capability from scope + mockScope.$watch.calls[0].args[1](); + expect(mockScope.testCapability).toBeUndefined(); + }); }); } ); \ No newline at end of file