-
-
Notifications
You must be signed in to change notification settings - Fork 103
/
html-behavior.spec.ts
60 lines (44 loc) · 2.1 KB
/
html-behavior.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
48
49
50
51
52
53
54
55
56
57
58
59
60
import {Container} from 'aurelia-dependency-injection';
import {ObserverLocator, bindingMode} from 'aurelia-binding';
import {TaskQueue} from 'aurelia-task-queue';
import {HtmlBehaviorResource} from '../src/html-behavior';
import {ViewResources} from '../src/view-resources';
describe('html-behavior', () => {
let defaultBindingMode = bindingMode.oneWay;
it('should leave BindableProperty defaultBindingMode undefined after initialize when unspecified', () => {
let resource = new HtmlBehaviorResource();
resource.attributeName = 'test';
let container = new Container();
container.registerInstance(ObserverLocator, {});
container.registerInstance(TaskQueue, {});
let target = function() {};
resource.initialize(container, target);
expect(resource.attributes['test'].defaultBindingMode).toBe(defaultBindingMode);
});
it('should register aliases for a custom attribute if provided', () => {
const resources = new ViewResources(new ViewResources(), 'app.html');
spyOn(resources, 'registerAttribute').and.callThrough();
const resource = new HtmlBehaviorResource();
resource.attributeName = 'test';
resource.aliases = ['foo', 'bar'] as any;
let target = function() {};
let container = new Container();
container.registerInstance(ObserverLocator, {});
container.registerInstance(TaskQueue, {});
resource.initialize(container, target);
resource.register(resources);
// one call for the base name and 2 for the aliases
expect(resources.registerAttribute).toHaveBeenCalledTimes(3);
});
it('should leave set BindableProperty defaultBindingMode after initialize when specified', () => {
let resource = new HtmlBehaviorResource();
resource.attributeName = 'test';
resource.attributeDefaultBindingMode = bindingMode.twoWay;
let container = new Container();
container.registerInstance(ObserverLocator, {});
container.registerInstance(TaskQueue, {});
let target = function() {};
resource.initialize(container, target);
expect(resource.attributes['test'].defaultBindingMode).toBe(bindingMode.twoWay);
});
});