@@ -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);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user