Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(templating-engine): allow for overrideContext in enhance
- Loading branch information
1 parent
35885f7
commit 49c99ed
Showing
2 changed files
with
52 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import './setup'; | ||
import {Container} from 'aurelia-dependency-injection'; | ||
import {TemplatingEngine} from '../src/templating-engine'; | ||
import {ViewResources} from '../src/view-resources'; | ||
import {DOM} from 'aurelia-pal'; | ||
|
||
describe('enhance', () => { | ||
let container; | ||
let element; | ||
let 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 = { 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); | ||
}); | ||
}); |