mirror of
https://github.com/nasa/openmct.git
synced 2025-01-19 19:27:07 +00:00
[Representation] Update TemplateLinker spec
...to reflect creation of a new scope each time a template is changed.
This commit is contained in:
parent
560454e7c2
commit
b487fa4438
@ -27,7 +27,8 @@ define(
|
|||||||
function (TemplateLinker) {
|
function (TemplateLinker) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var JQLITE_METHODS = [ 'replaceWith', 'empty', 'append' ];
|
var JQLITE_METHODS = [ 'replaceWith', 'empty', 'append' ],
|
||||||
|
SCOPE_METHODS = [ '$on', '$new', '$destroy' ];
|
||||||
|
|
||||||
describe("TemplateLinker", function () {
|
describe("TemplateLinker", function () {
|
||||||
var mockTemplateRequest,
|
var mockTemplateRequest,
|
||||||
@ -38,6 +39,7 @@ define(
|
|||||||
mockElement,
|
mockElement,
|
||||||
mockTemplates,
|
mockTemplates,
|
||||||
mockElements,
|
mockElements,
|
||||||
|
mockNewScope,
|
||||||
mockPromise,
|
mockPromise,
|
||||||
linker;
|
linker;
|
||||||
|
|
||||||
@ -46,7 +48,8 @@ define(
|
|||||||
mockSce = jasmine.createSpyObj('$sce', ['trustAsResourceUrl']);
|
mockSce = jasmine.createSpyObj('$sce', ['trustAsResourceUrl']);
|
||||||
mockCompile = jasmine.createSpy('$compile');
|
mockCompile = jasmine.createSpy('$compile');
|
||||||
mockLog = jasmine.createSpyObj('$log', ['error', 'warn']);
|
mockLog = jasmine.createSpyObj('$log', ['error', 'warn']);
|
||||||
mockScope = jasmine.createSpyObj('$scope', ['$on']);
|
mockScope = jasmine.createSpyObj('$scope', SCOPE_METHODS);
|
||||||
|
mockNewScope = jasmine.createSpyObj('$scope', SCOPE_METHODS);
|
||||||
mockElement = jasmine.createSpyObj('element', JQLITE_METHODS);
|
mockElement = jasmine.createSpyObj('element', JQLITE_METHODS);
|
||||||
mockPromise = jasmine.createSpyObj('promise', ['then']);
|
mockPromise = jasmine.createSpyObj('promise', ['then']);
|
||||||
mockTemplates = {};
|
mockTemplates = {};
|
||||||
@ -63,6 +66,7 @@ define(
|
|||||||
mockSce.trustAsResourceUrl.andCallFake(function (url) {
|
mockSce.trustAsResourceUrl.andCallFake(function (url) {
|
||||||
return { trusted: url };
|
return { trusted: url };
|
||||||
});
|
});
|
||||||
|
mockScope.$new.andReturn(mockNewScope);
|
||||||
|
|
||||||
linker = new TemplateLinker(
|
linker = new TemplateLinker(
|
||||||
mockTemplateRequest,
|
mockTemplateRequest,
|
||||||
@ -131,10 +135,10 @@ define(
|
|||||||
}, false);
|
}, false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("compiles loaded templates with linked scope", function () {
|
it("compiles loaded templates with a new scope", function () {
|
||||||
expect(mockCompile).toHaveBeenCalledWith(testTemplate);
|
expect(mockCompile).toHaveBeenCalledWith(testTemplate);
|
||||||
expect(mockTemplates[testTemplate])
|
expect(mockTemplates[testTemplate])
|
||||||
.toHaveBeenCalledWith(mockScope);
|
.toHaveBeenCalledWith(mockNewScope);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("replaces comments with specified element", function () {
|
it("replaces comments with specified element", function () {
|
||||||
|
Loading…
Reference in New Issue
Block a user