mirror of
https://github.com/nasa/openmct.git
synced 2025-01-31 08:25:31 +00:00
[Build] Update TemplateLinker spec
This commit is contained in:
parent
507f2391ff
commit
6509d84a5d
@ -44,6 +44,16 @@ define(
|
|||||||
mockPromise,
|
mockPromise,
|
||||||
linker;
|
linker;
|
||||||
|
|
||||||
|
function testExtension(path, res, templatePath) {
|
||||||
|
return {
|
||||||
|
bundle: {
|
||||||
|
path: path,
|
||||||
|
resources: res
|
||||||
|
},
|
||||||
|
templateUrl: templatePath
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
mockTemplateRequest = jasmine.createSpy('$templateRequest');
|
mockTemplateRequest = jasmine.createSpy('$templateRequest');
|
||||||
mockSce = jasmine.createSpyObj('$sce', ['trustAsResourceUrl']);
|
mockSce = jasmine.createSpyObj('$sce', ['trustAsResourceUrl']);
|
||||||
@ -91,13 +101,8 @@ define(
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("resolves extension paths", function () {
|
it("resolves extension paths", function () {
|
||||||
expect(linker.getPath({
|
var testExt = testExtension('a', 'b', 'c/d.html');
|
||||||
bundle: {
|
expect(linker.getPath(testExt)).toEqual('a/b/c/d.html');
|
||||||
path: 'a',
|
|
||||||
resources: 'b'
|
|
||||||
},
|
|
||||||
templateUrl: 'c/d.html'
|
|
||||||
})).toEqual('a/b/c/d.html');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("when linking elements", function () {
|
describe("when linking elements", function () {
|
||||||
@ -132,13 +137,15 @@ define(
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe("and then changing templates", function () {
|
describe("and then changing templates", function () {
|
||||||
var testUrl,
|
var testExt,
|
||||||
|
testUrl,
|
||||||
testTemplate;
|
testTemplate;
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
testUrl = "some/url/template.html";
|
testExt = testExtension('some', 'url', 'template.html');
|
||||||
|
testUrl = linker.getPath(testExt);
|
||||||
testTemplate = "<div>Some template!</div>";
|
testTemplate = "<div>Some template!</div>";
|
||||||
changeTemplate(testUrl);
|
changeTemplate(testExt);
|
||||||
mockPromise.then.mostRecentCall
|
mockPromise.then.mostRecentCall
|
||||||
.args[0](testTemplate);
|
.args[0](testTemplate);
|
||||||
});
|
});
|
||||||
@ -182,7 +189,9 @@ define(
|
|||||||
|
|
||||||
describe("which cannot be found", function () {
|
describe("which cannot be found", function () {
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
changeTemplate("some/bad/url");
|
changeTemplate(
|
||||||
|
testExtension("some", "bad", "template.html")
|
||||||
|
);
|
||||||
// Reject the template promise
|
// Reject the template promise
|
||||||
mockPromise.then.mostRecentCall.args[1]();
|
mockPromise.then.mostRecentCall.args[1]();
|
||||||
});
|
});
|
||||||
@ -206,11 +215,13 @@ define(
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe("when an initial template URL is provided", function () {
|
describe("when an initial template URL is provided", function () {
|
||||||
var testUrl;
|
var testExt,
|
||||||
|
testUrl;
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
testUrl = "some/test/url.html";
|
testExt = testExtension('some', 'test', 'template.html');
|
||||||
linker.link(mockScope, mockElement, testUrl);
|
testUrl = linker.getPath(testExt);
|
||||||
|
linker.link(mockScope, mockElement, testExt);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("does not remove the element initially", function () {
|
it("does not remove the element initially", function () {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user