|
1 |
| -import { expect } from "chai"; |
2 | 1 | import prodApp from "./app.module";
|
3 | 2 |
|
4 |
| -describe("advanced support", () => { |
| 3 | +import tests from 'advanced-tests'; |
5 | 4 |
|
| 5 | +describe('', function () { |
6 | 6 | beforeEach(angular.mock.module(prodApp));
|
7 | 7 |
|
8 | 8 | let compile;
|
9 | 9 | let scope;
|
10 | 10 | let interval;
|
| 11 | + |
11 | 12 | beforeEach(
|
12 | 13 | inject(($compile, $rootScope, $interval) => {
|
13 | 14 | compile = $compile;
|
14 |
| - scope = $rootScope.$new(); |
| 15 | + scope = $rootScope; |
15 | 16 | interval = $interval;
|
16 | 17 | })
|
17 | 18 | );
|
18 | 19 |
|
19 |
| - describe("attributes and properties", () => { |
20 |
| - const prep = el => { |
21 |
| - return compile(el)(scope)[0]; |
| 20 | + function render(component) { |
| 21 | + const root = compile(component)(scope)[0]; |
| 22 | + scope.$apply(); |
| 23 | + const wc = root.querySelector('#wc'); |
| 24 | + return { wc, root } |
| 25 | + } |
| 26 | + |
| 27 | + tests({ |
| 28 | + renderComponentWithProperties() { |
| 29 | + return render('<comp-with-props>') |
| 30 | + }, |
| 31 | + renderComponentWithDeclarativeEvent() { |
| 32 | + const { wc, root } = render('<comp-with-declarative-event>'); |
| 33 | + function click() { |
| 34 | + wc.click(); |
| 35 | + scope.$digest(); |
| 36 | + } |
| 37 | + return { wc, click, root }; |
22 | 38 | }
|
23 |
| - |
24 |
| - it("will pass array data as a property", function() { |
25 |
| - this.weight = 2; |
26 |
| - let root = prep("<comp-with-props>") |
27 |
| - scope.$digest() |
28 |
| - let wc = root.querySelector('#wc') |
29 |
| - let data = wc.arr; |
30 |
| - expect(data).to.eql(['A', 'n', 'g', 'u', 'l', 'a', 'r']); |
31 |
| - }); |
32 |
| - |
33 |
| - it("will pass object data as a property", function() { |
34 |
| - this.weight = 2; |
35 |
| - let root = prep("<comp-with-props>") |
36 |
| - scope.$digest() |
37 |
| - let wc = root.querySelector('#wc') |
38 |
| - let data = wc.obj; |
39 |
| - expect(data).to.eql({ org: "angular", repo: "angular" }); |
40 |
| - }); |
41 |
| - |
42 |
| - it("will pass object data to a camelCase-named property", function() { |
43 |
| - this.weight = 2; |
44 |
| - let root = prep("<comp-with-props>") |
45 |
| - scope.$digest() |
46 |
| - let wc = root.querySelector('#wc') |
47 |
| - let data = wc.camelCaseObj; |
48 |
| - expect(data).to.eql({ label: "passed" }); |
49 |
| - }); |
50 |
| - }); |
51 |
| - |
52 |
| - describe("events", () => { |
53 |
| - it("can declaratively listen to a lowercase DOM event dispatched by a Custom Element", function() { |
54 |
| - this.weight = 2; |
55 |
| - const root = compile("<comp-with-declarative-event>")(scope)[0]; |
56 |
| - scope.$digest(); |
57 |
| - let wc = root.querySelector("#wc"); |
58 |
| - let handled = root.querySelector("#lowercase"); |
59 |
| - expect(handled.textContent).to.eql("false"); |
60 |
| - wc.click(); |
61 |
| - scope.$digest(); |
62 |
| - expect(handled.textContent).to.eql("true"); |
63 |
| - }); |
64 |
| - |
65 |
| - it("can declaratively listen to a kebab-case DOM event dispatched by a Custom Element", function() { |
66 |
| - this.weight = 1; |
67 |
| - const root = compile("<comp-with-declarative-event>")(scope)[0]; |
68 |
| - scope.$digest(); |
69 |
| - let wc = root.querySelector("#wc"); |
70 |
| - let handled = root.querySelector("#kebab"); |
71 |
| - expect(handled.textContent).to.eql("false"); |
72 |
| - wc.click(); |
73 |
| - scope.$digest(); |
74 |
| - expect(handled.textContent).to.eql("true"); |
75 |
| - }); |
76 |
| - |
77 |
| - it("can declaratively listen to a camelCase DOM event dispatched by a Custom Element", function() { |
78 |
| - this.weight = 1; |
79 |
| - const root = compile("<comp-with-declarative-event>")(scope)[0]; |
80 |
| - scope.$digest(); |
81 |
| - let wc = root.querySelector("#wc"); |
82 |
| - let handled = root.querySelector("#camel"); |
83 |
| - expect(handled.textContent).to.eql("false"); |
84 |
| - wc.click(); |
85 |
| - scope.$digest(); |
86 |
| - expect(handled.textContent).to.eql("true"); |
87 |
| - }); |
88 |
| - |
89 |
| - it("can declaratively listen to a CAPScase DOM event dispatched by a Custom Element", function() { |
90 |
| - this.weight = 1; |
91 |
| - const root = compile("<comp-with-declarative-event>")(scope)[0]; |
92 |
| - scope.$digest(); |
93 |
| - let wc = root.querySelector("#wc"); |
94 |
| - let handled = root.querySelector("#caps"); |
95 |
| - expect(handled.textContent).to.eql("false"); |
96 |
| - wc.click(); |
97 |
| - scope.$digest(); |
98 |
| - expect(handled.textContent).to.eql("true"); |
99 |
| - }); |
100 |
| - |
101 |
| - it("can declaratively listen to a PascalCase DOM event dispatched by a Custom Element", function() { |
102 |
| - this.weight = 1; |
103 |
| - const root = compile("<comp-with-declarative-event>")(scope)[0]; |
104 |
| - scope.$digest(); |
105 |
| - let wc = root.querySelector("#wc"); |
106 |
| - let handled = root.querySelector("#pascal"); |
107 |
| - expect(handled.textContent).to.eql("false"); |
108 |
| - wc.click(); |
109 |
| - scope.$digest(); |
110 |
| - expect(handled.textContent).to.eql("true"); |
111 |
| - }); |
112 | 39 | });
|
113 |
| - |
114 | 40 | });
|
0 commit comments