mirror of
https://github.com/nasa/openmct.git
synced 2025-01-19 11:17:04 +00:00
[Representation] Test switching between links
Add test case to verify that representation gets refreshed when switching among two linked instances of the same domain object.
This commit is contained in:
parent
5e07951892
commit
386f1f20ff
@ -247,6 +247,54 @@ define(
|
||||
mockScope.$watch.calls[0].args[1]();
|
||||
expect(mockScope.testCapability).toBeUndefined();
|
||||
});
|
||||
|
||||
it("detects changes among linked instances", function () {
|
||||
var mockContext = jasmine.createSpyObj('context', ['getPath']),
|
||||
mockContext2 = jasmine.createSpyObj('context', ['getPath']),
|
||||
mockLink = jasmine.createSpyObj(
|
||||
'linkedObject',
|
||||
DOMAIN_OBJECT_METHODS
|
||||
),
|
||||
mockParent = jasmine.createSpyObj(
|
||||
'parentObject',
|
||||
DOMAIN_OBJECT_METHODS
|
||||
),
|
||||
callCount;
|
||||
|
||||
mockDomainObject.getCapability.andCallFake(function (c) {
|
||||
return c === 'context' && mockContext;
|
||||
});
|
||||
mockLink.getCapability.andCallFake(function (c) {
|
||||
return c === 'context' && mockContext2;
|
||||
});
|
||||
mockDomainObject.hasCapability.andCallFake(function (c) {
|
||||
return c === 'context';
|
||||
});
|
||||
mockLink.hasCapability.andCallFake(function (c) {
|
||||
return c === 'context';
|
||||
});
|
||||
mockLink.getModel.andReturn({});
|
||||
|
||||
mockContext.getPath.andReturn([mockDomainObject]);
|
||||
mockContext2.getPath.andReturn([mockParent, mockLink]);
|
||||
|
||||
mockLink.getId.andReturn('test-id');
|
||||
mockDomainObject.getId.andReturn('test-id');
|
||||
|
||||
mockParent.getId.andReturn('parent-id');
|
||||
|
||||
mockScope.key = "abc";
|
||||
mockScope.domainObject = mockDomainObject;
|
||||
|
||||
mockScope.$watch.calls[0].args[1]();
|
||||
callCount = mockChangeTemplate.calls.length;
|
||||
|
||||
mockScope.domainObject = mockLink;
|
||||
mockScope.$watch.calls[0].args[1]();
|
||||
|
||||
expect(mockChangeTemplate.calls.length)
|
||||
.toEqual(callCount + 1);
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user