Added tests

This commit is contained in:
Henry
2016-05-12 14:20:16 -07:00
parent c305fba0a7
commit 69c4c3a2c8
7 changed files with 68 additions and 23 deletions

View File

@@ -236,7 +236,7 @@ define(
expect(mockLog.warn).toHaveBeenCalled();
});
it("clears out obsolete peroperties from scope", function () {
it("clears out obsolete properties from scope", function () {
mockScope.key = "def";
mockScope.domainObject = mockDomainObject;
mockDomainObject.useCapability.andReturn("some value");
@@ -253,6 +253,21 @@ define(
expect(mockScope.testCapability).toBeUndefined();
});
it("registers a status change listener", function () {
mockScope.$watch.calls[2].args[1](mockDomainObject);
expect(mockStatusCapability.listen).toHaveBeenCalled();
});
it("unlistens for status change on scope destruction", function () {
var mockUnlistener = jasmine.createSpy("unlisten");
mockStatusCapability.listen.andReturn(mockUnlistener);
mockScope.$watch.calls[2].args[1](mockDomainObject);
expect(mockStatusCapability.listen).toHaveBeenCalled();
mockScope.$on.calls[1].args[1]();
expect(mockUnlistener).toHaveBeenCalled();
});
describe("when a domain object has been observed", function () {
var mockContext,
mockContext2,
@@ -314,6 +329,7 @@ define(
mockScope.$watch.calls[0].args[1]();
expect(mockChangeTemplate.calls.length).toEqual(callCount);
});
});