mirror of
https://github.com/nasa/openmct.git
synced 2025-06-01 07:00:49 +00:00
[Representation] Add more test cases
...for TemplateLinker.
This commit is contained in:
parent
a48370abd3
commit
5b475c9f64
@ -202,6 +202,40 @@ define(
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe("when an initial template URL is provided", function () {
|
||||
var testUrl;
|
||||
|
||||
beforeEach(function () {
|
||||
testUrl = "some/test/url.html";
|
||||
linker.link(mockScope, mockElement, testUrl);
|
||||
});
|
||||
|
||||
it("does not remove the element initially", function () {
|
||||
expect(mockElement.replaceWith)
|
||||
.not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("loads the specified template", function () {
|
||||
expect(mockHttp.get).toHaveBeenCalledWith(testUrl);
|
||||
});
|
||||
});
|
||||
|
||||
it("does not issue multiple requests for the same URL", function () {
|
||||
var testUrls = ['a', 'b', 'c', 'd'].map(function (k) {
|
||||
return k + "/some/template.html";
|
||||
});
|
||||
|
||||
testUrls.forEach(function (testUrl, i) {
|
||||
expect(mockHttp.get.callCount).toEqual(i);
|
||||
linker.link(mockScope, mockElement, testUrl);
|
||||
expect(mockHttp.get.callCount).toEqual(i + 1);
|
||||
linker.link(mockScope, mockElement, testUrl);
|
||||
expect(mockHttp.get.callCount).toEqual(i + 1);
|
||||
linker.link(mockScope, mockElement)(testUrl);
|
||||
expect(mockHttp.get.callCount).toEqual(i + 1);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
||||
|
Loading…
x
Reference in New Issue
Block a user