-
-
Notifications
You must be signed in to change notification settings - Fork 103
/
templating-engine.spec.ts
47 lines (38 loc) · 1.42 KB
/
templating-engine.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import { createOverrideContext } from 'aurelia-binding';
import { Container } from 'aurelia-dependency-injection';
import { DOM } from 'aurelia-pal';
import { TemplatingEngine, ViewResources } from '../src/aurelia-templating';
describe('enhance', () => {
let container;
let element;
let templatingEngine: TemplatingEngine;
beforeEach(() => {
container = new Container();
element = DOM.createElement('div');
templatingEngine = container.get(TemplatingEngine);
});
it('passes bindingContext and overrideContext to .bind()', () => {
let bindingContext = { some: 'var' };
let overrideContext = createOverrideContext(bindingContext);
overrideContext['foo'] = 'bar';
let view = templatingEngine.enhance({
element: element,
bindingContext: bindingContext,
overrideContext: overrideContext
});
expect(view.bindingContext).toBe(bindingContext);
expect(view.overrideContext).toBe(overrideContext);
expect(view.bindingContext['some']).toBe('var');
expect(view.overrideContext['foo']).toBe('bar');
});
it('supports passing of ViewResources to the view-compiler', () => {
let compileNodeSpy = spyOn(templatingEngine['_viewCompiler'], '_compileNode');
let resources = new ViewResources();
templatingEngine.enhance({
element: element,
resources: resources
});
let r = compileNodeSpy.calls.argsFor(0)[1];
expect(r).toBe(resources);
});
});