[Representation] Test for false-positives on refresh

#732
This commit is contained in:
Victor Woeltjen
2016-03-10 14:26:20 -08:00
parent 5d084c2618
commit 5296255fa6

View File

@@ -248,18 +248,23 @@ define(
expect(mockScope.testCapability).toBeUndefined(); expect(mockScope.testCapability).toBeUndefined();
}); });
it("detects changes among linked instances", function () { describe("when a domain object has been observed", function () {
var mockContext = jasmine.createSpyObj('context', ['getPath']), var mockContext,
mockContext2 = jasmine.createSpyObj('context', ['getPath']), mockContext2,
mockLink,
mockParent;
beforeEach(function () {
mockContext = jasmine.createSpyObj('context', ['getPath']);
mockContext2 = jasmine.createSpyObj('context', ['getPath']);
mockLink = jasmine.createSpyObj( mockLink = jasmine.createSpyObj(
'linkedObject', 'linkedObject',
DOMAIN_OBJECT_METHODS DOMAIN_OBJECT_METHODS
), );
mockParent = jasmine.createSpyObj( mockParent = jasmine.createSpyObj(
'parentObject', 'parentObject',
DOMAIN_OBJECT_METHODS DOMAIN_OBJECT_METHODS
), );
callCount;
mockDomainObject.getCapability.andCallFake(function (c) { mockDomainObject.getCapability.andCallFake(function (c) {
return c === 'context' && mockContext; return c === 'context' && mockContext;
@@ -287,7 +292,10 @@ define(
mockScope.domainObject = mockDomainObject; mockScope.domainObject = mockDomainObject;
mockScope.$watch.calls[0].args[1](); mockScope.$watch.calls[0].args[1]();
callCount = mockChangeTemplate.calls.length; });
it("detects subsequent changes among linked instances", function () {
var callCount = mockChangeTemplate.calls.length;
mockScope.domainObject = mockLink; mockScope.domainObject = mockLink;
mockScope.$watch.calls[0].args[1](); mockScope.$watch.calls[0].args[1]();
@@ -295,6 +303,15 @@ define(
expect(mockChangeTemplate.calls.length) expect(mockChangeTemplate.calls.length)
.toEqual(callCount + 1); .toEqual(callCount + 1);
}); });
it("does not trigger excess template changes for same instances", function () {
var callCount = mockChangeTemplate.calls.length;
mockScope.$watch.calls[0].args[1]();
expect(mockChangeTemplate.calls.length).toEqual(callCount);
});
});
}); });
} }
); );