[Representation] Add test for scope clearing

Add test clearing to verify that scope gets cleared
on view changes, WTD-1182.
This commit is contained in:
Victor Woeltjen 2015-05-20 16:39:49 -07:00
parent 9b6d8cf1ec
commit cde173dbdc

View File

@ -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();
});
});
}
);