-
Notifications
You must be signed in to change notification settings - Fork 107
/
Copy pathadvanced-tests.js
123 lines (109 loc) · 3.96 KB
/
advanced-tests.js
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
import { expect } from "chai";
import prodApp from "./app.module";
describe("advanced support", () => {
beforeEach(angular.mock.module(prodApp));
let compile;
let scope;
let interval;
beforeEach(
inject(($compile, $rootScope, $interval) => {
compile = $compile;
scope = $rootScope.$new();
interval = $interval;
})
);
describe("attributes and properties", () => {
const prep = el => {
return compile(el)(scope)[0];
}
it("will pass array data as a property", function() {
this.weight = 2;
let root = prep("<comp-with-props>")
scope.$digest()
let wc = root.querySelector('#wc')
let data = wc.arr;
expect(data).to.eql(['A', 'n', 'g', 'u', 'l', 'a', 'r']);
});
it("will pass object data as a property", function() {
this.weight = 2;
let root = prep("<comp-with-props>")
scope.$digest()
let wc = root.querySelector('#wc')
let data = wc.obj;
expect(data).to.eql({ org: "angular", repo: "angular" });
});
it("will pass object data to a camelCase-named property", function() {
this.weight = 2;
let root = prep("<comp-with-props>")
scope.$digest()
let wc = root.querySelector('#wc')
let data = wc.camelCaseObj;
expect(data).to.eql({ label: "passed" });
});
it("will pass object data to inherited properties", function() {
this.weight = 2;
let root = prep("<comp-with-inheritance>")
scope.$digest()
let wc = root.querySelector('#wc')
expect(wc.arr).to.eql(['A', 'n', 'g', 'u', 'l', 'a', 'r']);
expect(wc.obj).to.eql({ org: "angular", repo: "angular" });
});
});
describe("events", () => {
it("can declaratively listen to a lowercase DOM event dispatched by a Custom Element", function() {
this.weight = 2;
const root = compile("<comp-with-declarative-event>")(scope)[0];
scope.$digest();
let wc = root.querySelector("#wc");
let handled = root.querySelector("#lowercase");
expect(handled.textContent).to.eql("false");
wc.click();
scope.$digest();
expect(handled.textContent).to.eql("true");
});
it("can declaratively listen to a kebab-case DOM event dispatched by a Custom Element", function() {
this.weight = 1;
const root = compile("<comp-with-declarative-event>")(scope)[0];
scope.$digest();
let wc = root.querySelector("#wc");
let handled = root.querySelector("#kebab");
expect(handled.textContent).to.eql("false");
wc.click();
scope.$digest();
expect(handled.textContent).to.eql("true");
});
it("can declaratively listen to a camelCase DOM event dispatched by a Custom Element", function() {
this.weight = 1;
const root = compile("<comp-with-declarative-event>")(scope)[0];
scope.$digest();
let wc = root.querySelector("#wc");
let handled = root.querySelector("#camel");
expect(handled.textContent).to.eql("false");
wc.click();
scope.$digest();
expect(handled.textContent).to.eql("true");
});
it("can declaratively listen to a CAPScase DOM event dispatched by a Custom Element", function() {
this.weight = 1;
const root = compile("<comp-with-declarative-event>")(scope)[0];
scope.$digest();
let wc = root.querySelector("#wc");
let handled = root.querySelector("#caps");
expect(handled.textContent).to.eql("false");
wc.click();
scope.$digest();
expect(handled.textContent).to.eql("true");
});
it("can declaratively listen to a PascalCase DOM event dispatched by a Custom Element", function() {
this.weight = 1;
const root = compile("<comp-with-declarative-event>")(scope)[0];
scope.$digest();
let wc = root.querySelector("#wc");
let handled = root.querySelector("#pascal");
expect(handled.textContent).to.eql("false");
wc.click();
scope.$digest();
expect(handled.textContent).to.eql("true");
});
});
});