@angular-wave/angular.ts 0.4.3 → 0.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/angular-ts.umd.js +10 -0
- package/index.html +74 -3
- package/package.json +1 -1
- package/src/angular.spec.js +0 -5
- package/src/animations/animate-css.js +5 -13
- package/src/animations/animate-queue.js +22 -21
- package/src/animations/animate-runner.js +4 -8
- package/src/animations/animate.md +1 -1
- package/src/animations/animate.spec.js +0 -21
- package/src/animations/animation.js +1 -1
- package/src/binding.spec.js +0 -1
- package/src/core/cache/cache.js +2 -29
- package/src/core/compile/compile.js +26 -27
- package/src/core/compile/compile.spec.js +17 -266
- package/src/core/compile/compile.test.js +1 -1
- package/src/core/controller/controller.js +2 -0
- package/src/core/di/injector.md +1 -1
- package/src/core/di/injector.spec.js +0 -2
- package/src/core/di/internal-injector.js +2 -1
- package/src/core/interpolate/interpolate.js +16 -3
- package/src/core/interpolate/interpolate.spec.js +70 -16
- package/src/core/interval/interval.test.js +1 -1
- package/src/core/location/location.js +0 -2
- package/src/core/location/location.spec.js +27 -27
- package/src/core/{scope/scope.html → model/model.html} +1 -1
- package/src/core/model/model.js +944 -0
- package/src/core/model/model.spec.js +3012 -0
- package/src/core/on.spec.js +0 -7
- package/src/core/parse/interpreter.js +10 -7
- package/src/core/parse/parse.js +26 -5
- package/src/core/parse/parse.spec.js +95 -91
- package/src/core/prop.spec.js +4 -60
- package/src/core/sce/sce.spec.js +0 -8
- package/src/core/scope/scope.js +61 -30
- package/src/core/scope/scope.spec.js +25 -1960
- package/src/directive/aria/aria.js +3 -6
- package/src/directive/aria/aria.spec.js +0 -87
- package/src/directive/attrs/attrs.spec.js +0 -5
- package/src/directive/attrs/boolean.spec.js +0 -15
- package/src/directive/attrs/element-style.spec.js +0 -8
- package/src/directive/attrs/src.spec.js +0 -7
- package/src/directive/bind/bind.spec.js +0 -33
- package/src/directive/bind/bing-html.spec.js +0 -3
- package/src/{core/q/q.html → directive/channel/channel.html} +1 -1
- package/src/directive/channel/channel.js +29 -0
- package/src/directive/channel/channel.spec.js +52 -0
- package/src/directive/{list/list.test.js → channel/channel.test.js} +2 -4
- package/src/directive/class/class.js +3 -3
- package/src/directive/class/class.spec.js +9 -75
- package/src/directive/controller/controller.spec.js +0 -13
- package/src/directive/events/click.spec.js +0 -3
- package/src/directive/events/event.spec.js +0 -6
- package/src/directive/form/form.js +2 -3
- package/src/directive/form/form.spec.js +0 -65
- package/src/directive/if/if.spec.js +0 -4
- package/src/directive/include/include.spec.js +8 -59
- package/src/directive/init/init.js +6 -2
- package/src/directive/init/init.spec.js +0 -2
- package/src/directive/input/input.spec.js +0 -136
- package/src/directive/messages/messages.spec.js +4 -35
- package/src/directive/model/model.js +18 -25
- package/src/directive/model/model.spec.js +2 -49
- package/src/directive/model-options/model-options.spec.js +0 -6
- package/src/directive/non-bindable/non-bindable.spec.js +0 -1
- package/src/directive/observe/observe.js +0 -1
- package/src/directive/observe/observe.spec.js +0 -1
- package/src/directive/options/options.spec.js +0 -34
- package/src/directive/ref/href.spec.js +0 -15
- package/src/directive/repeat/repeat.spec.js +8 -135
- package/src/directive/script/script.spec.js +0 -2
- package/src/directive/select/select.js +3 -3
- package/src/directive/select/select.spec.js +0 -96
- package/src/directive/show-hide/show-hide.js +2 -2
- package/src/directive/show-hide/show-hide.spec.js +8 -19
- package/src/directive/style/style.spec.js +0 -7
- package/src/directive/switch/switch.spec.js +5 -5
- package/src/directive/validators/validators.spec.js +0 -1
- package/src/loader.js +0 -1
- package/src/public.js +75 -80
- package/src/router/common/coreservices.js +0 -2
- package/src/router/directives/state-directives.js +6 -14
- package/src/router/directives/state-directives.spec.js +0 -83
- package/src/router/directives/view-directive.js +4 -13
- package/src/router/directives/view-directive.spec.js +25 -71
- package/src/router/hooks/lazy-load.js +2 -2
- package/src/router/hooks/views.js +3 -5
- package/src/router/resolve/resolvable.js +3 -6
- package/src/router/resolve/resolve-context.js +2 -2
- package/src/router/state/state-service.js +4 -4
- package/src/router/state/state.spec.js +2 -5
- package/src/router/state/views.js +7 -10
- package/src/router/template-factory.js +3 -6
- package/src/router/template-factory.spec.js +0 -4
- package/src/router/transition/transition-hook.js +1 -1
- package/src/router/transition/transition.js +1 -1
- package/src/router/view-hook.spec.js +2 -2
- package/src/router/view-scroll.js +4 -6
- package/src/services/http/http.js +6 -9
- package/src/services/http/http.spec.js +30 -31
- package/src/services/http/template-request.spec.js +0 -10
- package/src/services/http-backend/http-backend.spec.js +3 -3
- package/src/services/template-request.js +2 -4
- package/src/shared/common.js +1 -2
- package/src/shared/jqlite/jqlite.js +0 -3
- package/types/core/cache/cache.d.ts +1 -1
- package/types/core/model/model.d.ts +204 -0
- package/types/core/parse/parse.d.ts +26 -0
- package/types/core/scope/scope.d.ts +22 -21
- package/types/directive/channel/channel.d.ts +11 -0
- package/src/core/interval/interval-factory.js +0 -50
- package/src/core/interval/interval.html +0 -18
- package/src/core/interval/interval.js +0 -77
- package/src/core/interval/interval.md +0 -123
- package/src/core/interval/interval.spec.js +0 -280
- package/src/core/q/q.js +0 -472
- package/src/core/q/q.md +0 -211
- package/src/core/q/q.spec.js +0 -2748
- package/src/core/q/q.test.js +0 -12
- package/src/core/scope/scope.test.js +0 -12
- package/src/core/timeout/timeout.html +0 -18
- package/src/core/timeout/timeout.js +0 -109
- package/src/core/timeout/timeout.spec.js +0 -354
- package/src/core/timeout/timout.test.js +0 -12
- package/src/directive/list/list.html +0 -18
- package/src/directive/list/list.js +0 -46
- package/src/directive/list/list.md +0 -22
- package/src/directive/list/list.spec.js +0 -172
- package/types/directive/list/list.d.ts +0 -4
|
@@ -24,7 +24,6 @@ describe("ngSrc", () => {
|
|
|
24
24
|
it("should not result empty string in img src", () => {
|
|
25
25
|
$scope.image = {};
|
|
26
26
|
element = $compile('<img ng-src="{{image.url}}">')($scope);
|
|
27
|
-
$scope.$digest();
|
|
28
27
|
expect(element.attr("src")).not.toBe("");
|
|
29
28
|
expect(element.attr("src")).toBeUndefined();
|
|
30
29
|
});
|
|
@@ -32,20 +31,17 @@ describe("ngSrc", () => {
|
|
|
32
31
|
it("should sanitize interpolated url", () => {
|
|
33
32
|
$scope.imageUrl = "javascript:alert(1);";
|
|
34
33
|
element = $compile('<img ng-src="{{imageUrl}}">')($scope);
|
|
35
|
-
$scope.$digest();
|
|
36
34
|
expect(element.attr("src")).toBe("unsafe:javascript:alert(1);");
|
|
37
35
|
});
|
|
38
36
|
|
|
39
37
|
it("should sanitize non-interpolated url", () => {
|
|
40
38
|
element = $compile('<img ng-src="javascript:alert(1);">')($scope);
|
|
41
|
-
$scope.$digest();
|
|
42
39
|
expect(element.attr("src")).toBe("unsafe:javascript:alert(1);");
|
|
43
40
|
});
|
|
44
41
|
|
|
45
42
|
it("should interpolate the expression and bind to src with raw same-domain value", () => {
|
|
46
43
|
element = $compile('<img ng-src="{{id}}"></img>')($scope);
|
|
47
44
|
|
|
48
|
-
$scope.$digest();
|
|
49
45
|
expect(element.attr("src")).toBeUndefined();
|
|
50
46
|
|
|
51
47
|
$scope.$apply(() => {
|
|
@@ -67,13 +63,11 @@ describe("ngSrc", () => {
|
|
|
67
63
|
$scope.imageUrl = "dynamic";
|
|
68
64
|
element = $compile('<img ng-src="{{imageUrl}}" src="static">')($scope);
|
|
69
65
|
expect(element.attr("src")).toBe("static");
|
|
70
|
-
$scope.$digest();
|
|
71
66
|
expect(element.attr("src")).toBe("dynamic");
|
|
72
67
|
dealoc(element);
|
|
73
68
|
|
|
74
69
|
element = $compile('<img src="static" ng-src="{{imageUrl}}">')($scope);
|
|
75
70
|
expect(element.attr("src")).toBe("static");
|
|
76
|
-
$scope.$digest();
|
|
77
71
|
expect(element.attr("src")).toBe("dynamic");
|
|
78
72
|
});
|
|
79
73
|
});
|
|
@@ -135,7 +129,6 @@ describe("ngSrc", () => {
|
|
|
135
129
|
it("should interpolate the expression and bind to src with a trusted value", () => {
|
|
136
130
|
element = $compile('<iframe ng-src="{{id}}"></iframe>')($scope);
|
|
137
131
|
|
|
138
|
-
$scope.$digest();
|
|
139
132
|
expect(element.attr("src")).toBeUndefined();
|
|
140
133
|
|
|
141
134
|
$scope.$apply(() => {
|
|
@@ -35,20 +35,16 @@ describe("ng-bind", () => {
|
|
|
35
35
|
element = $compile('<div ng-bind="a"></div>')($rootScope);
|
|
36
36
|
expect(element.text()).toEqual("");
|
|
37
37
|
$rootScope.a = "misko";
|
|
38
|
-
$rootScope.$digest();
|
|
39
38
|
expect(element.text()).toEqual("misko");
|
|
40
39
|
});
|
|
41
40
|
|
|
42
41
|
it("should set text to blank if undefined", () => {
|
|
43
42
|
element = $compile('<div ng-bind="a"></div>')($rootScope);
|
|
44
43
|
$rootScope.a = "misko";
|
|
45
|
-
$rootScope.$digest();
|
|
46
44
|
expect(element.text()).toEqual("misko");
|
|
47
45
|
$rootScope.a = undefined;
|
|
48
|
-
$rootScope.$digest();
|
|
49
46
|
expect(element.text()).toEqual("");
|
|
50
47
|
$rootScope.a = null;
|
|
51
|
-
$rootScope.$digest();
|
|
52
48
|
expect(element.text()).toEqual("");
|
|
53
49
|
});
|
|
54
50
|
|
|
@@ -61,7 +57,6 @@ describe("ng-bind", () => {
|
|
|
61
57
|
'<span ng-bind="false"></span>' +
|
|
62
58
|
"</div>",
|
|
63
59
|
)($rootScope);
|
|
64
|
-
$rootScope.$digest();
|
|
65
60
|
expect(element.text()).toEqual("-0false");
|
|
66
61
|
});
|
|
67
62
|
|
|
@@ -74,7 +69,6 @@ describe("ng-bind", () => {
|
|
|
74
69
|
() => {
|
|
75
70
|
$rootScope.value = prop[0];
|
|
76
71
|
element = $compile('<div ng-bind="value"></div>')($rootScope);
|
|
77
|
-
$rootScope.$digest();
|
|
78
72
|
expect(element.text()).toEqual(prop[1]);
|
|
79
73
|
};
|
|
80
74
|
});
|
|
@@ -87,21 +81,18 @@ describe("ng-bind", () => {
|
|
|
87
81
|
},
|
|
88
82
|
};
|
|
89
83
|
element = $compile('<div ng-bind="value"></div>')($rootScope);
|
|
90
|
-
$rootScope.$digest();
|
|
91
84
|
expect(element.text()).toEqual("foo");
|
|
92
85
|
});
|
|
93
86
|
|
|
94
87
|
it("should NOT use toString on array objects", () => {
|
|
95
88
|
$rootScope.value = [];
|
|
96
89
|
element = $compile('<div ng-bind="value"></div>')($rootScope);
|
|
97
|
-
$rootScope.$digest();
|
|
98
90
|
expect(element.text()).toEqual("[]");
|
|
99
91
|
});
|
|
100
92
|
|
|
101
93
|
it("should NOT use toString on Date objects", () => {
|
|
102
94
|
$rootScope.value = new Date(2014, 10, 10, 0, 0, 0);
|
|
103
95
|
element = $compile('<div ng-bind="value"></div>')($rootScope);
|
|
104
|
-
$rootScope.$digest();
|
|
105
96
|
expect(element.text()).toBe(JSON.stringify($rootScope.value));
|
|
106
97
|
expect(element.text()).not.toEqual($rootScope.value.toString());
|
|
107
98
|
});
|
|
@@ -110,11 +101,9 @@ describe("ng-bind", () => {
|
|
|
110
101
|
element = $compile('<div ng-bind="::a"></div>')($rootScope);
|
|
111
102
|
$rootScope.a = "lucas";
|
|
112
103
|
expect($rootScope.$$watchers.length).toEqual(1);
|
|
113
|
-
$rootScope.$digest();
|
|
114
104
|
expect(element.text()).toEqual("lucas");
|
|
115
105
|
expect($rootScope.$$watchers.length).toEqual(0);
|
|
116
106
|
$rootScope.a = undefined;
|
|
117
|
-
$rootScope.$digest();
|
|
118
107
|
expect(element.text()).toEqual("lucas");
|
|
119
108
|
});
|
|
120
109
|
|
|
@@ -126,10 +115,8 @@ describe("ng-bind", () => {
|
|
|
126
115
|
}
|
|
127
116
|
});
|
|
128
117
|
$rootScope.a = "foo";
|
|
129
|
-
$rootScope.$digest();
|
|
130
118
|
expect(element.text()).toEqual("bar");
|
|
131
119
|
$rootScope.a = undefined;
|
|
132
|
-
$rootScope.$digest();
|
|
133
120
|
expect(element.text()).toEqual("bar");
|
|
134
121
|
});
|
|
135
122
|
|
|
@@ -141,13 +128,10 @@ describe("ng-bind", () => {
|
|
|
141
128
|
}
|
|
142
129
|
});
|
|
143
130
|
$rootScope.a = "foo";
|
|
144
|
-
$rootScope.$digest();
|
|
145
131
|
expect(element.text()).toEqual("");
|
|
146
132
|
$rootScope.a = "bar";
|
|
147
|
-
$rootScope.$digest();
|
|
148
133
|
expect(element.text()).toEqual("bar");
|
|
149
134
|
$rootScope.a = "man";
|
|
150
|
-
$rootScope.$digest();
|
|
151
135
|
expect(element.text()).toEqual("bar");
|
|
152
136
|
});
|
|
153
137
|
});
|
|
@@ -158,7 +142,6 @@ describe("ng-bind", () => {
|
|
|
158
142
|
$rootScope,
|
|
159
143
|
);
|
|
160
144
|
$rootScope.name = "Misko";
|
|
161
|
-
$rootScope.$digest();
|
|
162
145
|
expect(element.text()).toEqual("Hello Misko!");
|
|
163
146
|
});
|
|
164
147
|
|
|
@@ -168,12 +151,10 @@ describe("ng-bind", () => {
|
|
|
168
151
|
)($rootScope);
|
|
169
152
|
$rootScope.name = "Misko";
|
|
170
153
|
expect($rootScope.$$watchers.length).toEqual(2);
|
|
171
|
-
$rootScope.$digest();
|
|
172
154
|
expect(element.text()).toEqual(" Misko!");
|
|
173
155
|
expect($rootScope.$$watchers.length).toEqual(1);
|
|
174
156
|
$rootScope.hello = "Hello";
|
|
175
157
|
$rootScope.name = "Lucas";
|
|
176
|
-
$rootScope.$digest();
|
|
177
158
|
expect(element.text()).toEqual("Hello Misko!");
|
|
178
159
|
expect($rootScope.$$watchers.length).toEqual(0);
|
|
179
160
|
});
|
|
@@ -182,8 +163,6 @@ describe("ng-bind", () => {
|
|
|
182
163
|
element = $compile('<pre>{{ {key:"value", $$key:"hide"} }}</pre>')(
|
|
183
164
|
$rootScope,
|
|
184
165
|
);
|
|
185
|
-
$rootScope.$digest();
|
|
186
|
-
|
|
187
166
|
expect(JSON.parse(element.text())).toEqual({ key: "value" });
|
|
188
167
|
});
|
|
189
168
|
});
|
|
@@ -192,7 +171,6 @@ describe("ng-bind", () => {
|
|
|
192
171
|
it("should complain about accidental use of interpolation", () => {
|
|
193
172
|
expect(() => {
|
|
194
173
|
$compile('<div ng-bind-html="{{myHtml}}"></div>');
|
|
195
|
-
$rootScope.$digest();
|
|
196
174
|
}).toThrowError(/syntax/);
|
|
197
175
|
});
|
|
198
176
|
|
|
@@ -225,17 +203,14 @@ describe("ng-bind", () => {
|
|
|
225
203
|
it("should set html", () => {
|
|
226
204
|
element = $compile('<div ng-bind-html="html"></div>')($rootScope);
|
|
227
205
|
$rootScope.html = '<div onclick="">hello</div>';
|
|
228
|
-
$rootScope.$digest();
|
|
229
206
|
expect(element.html()).toEqual('<div onclick="">hello</div>');
|
|
230
207
|
});
|
|
231
208
|
|
|
232
209
|
it("should update html", () => {
|
|
233
210
|
element = $compile('<div ng-bind-html="html"></div>')($rootScope);
|
|
234
211
|
$rootScope.html = "hello";
|
|
235
|
-
$rootScope.$digest();
|
|
236
212
|
expect(element.html()).toEqual("hello");
|
|
237
213
|
$rootScope.html = "goodbye";
|
|
238
|
-
$rootScope.$digest();
|
|
239
214
|
expect(element.html()).toEqual("goodbye");
|
|
240
215
|
});
|
|
241
216
|
|
|
@@ -243,11 +218,9 @@ describe("ng-bind", () => {
|
|
|
243
218
|
element = $compile('<div ng-bind-html="::html"></div>')($rootScope);
|
|
244
219
|
$rootScope.html = '<div onclick="">hello</div>';
|
|
245
220
|
expect($rootScope.$$watchers.length).toEqual(1);
|
|
246
|
-
$rootScope.$digest();
|
|
247
221
|
expect(element.text()).toEqual("hello");
|
|
248
222
|
expect($rootScope.$$watchers.length).toEqual(0);
|
|
249
223
|
$rootScope.html = '<div onclick="">hello</div>';
|
|
250
|
-
$rootScope.$digest();
|
|
251
224
|
expect(element.text()).toEqual("hello");
|
|
252
225
|
});
|
|
253
226
|
});
|
|
@@ -282,17 +255,14 @@ describe("ng-bind", () => {
|
|
|
282
255
|
it("should set html for trusted values", () => {
|
|
283
256
|
element = $compile('<div ng-bind-html="html"></div>')($rootScope);
|
|
284
257
|
$rootScope.html = $sce.trustAsHtml('<div onclick="">hello</div>');
|
|
285
|
-
$rootScope.$digest();
|
|
286
258
|
expect(element.html()).toEqual('<div onclick="">hello</div>');
|
|
287
259
|
});
|
|
288
260
|
|
|
289
261
|
it("should update html", () => {
|
|
290
262
|
element = $compile('<div ng-bind-html="html"></div>')(scope);
|
|
291
263
|
scope.html = $sce.trustAsHtml("hello");
|
|
292
|
-
scope.$digest();
|
|
293
264
|
expect(element.html()).toEqual("hello");
|
|
294
265
|
scope.html = $sce.trustAsHtml("goodbye");
|
|
295
|
-
scope.$digest();
|
|
296
266
|
expect(element.html()).toEqual("goodbye");
|
|
297
267
|
});
|
|
298
268
|
|
|
@@ -304,7 +274,6 @@ describe("ng-bind", () => {
|
|
|
304
274
|
$rootScope.getHtml = function () {
|
|
305
275
|
return $sce.trustAsHtml('<div onclick="">hello</div>');
|
|
306
276
|
};
|
|
307
|
-
$rootScope.$digest();
|
|
308
277
|
expect(element.html()).toEqual('<div onclick="">hello</div>');
|
|
309
278
|
});
|
|
310
279
|
|
|
@@ -361,10 +330,8 @@ describe("ng-bind", () => {
|
|
|
361
330
|
$rootScope.getHtml = function () {
|
|
362
331
|
return $sce.trustAsHtml(html);
|
|
363
332
|
};
|
|
364
|
-
$rootScope.$digest();
|
|
365
333
|
expect(element.html()).toEqual("hello");
|
|
366
334
|
html = "goodbye";
|
|
367
|
-
$rootScope.$digest();
|
|
368
335
|
expect(element.html()).toEqual("goodbye");
|
|
369
336
|
};
|
|
370
337
|
});
|
|
@@ -16,7 +16,6 @@ describe("ngBindHtml", () => {
|
|
|
16
16
|
it("should set html", () => {
|
|
17
17
|
const element = $compile('<div ng-bind-html="html"></div>')($rootScope);
|
|
18
18
|
$rootScope.html = "<div>hello</div>";
|
|
19
|
-
$rootScope.$digest();
|
|
20
19
|
expect(element.html()).toEqual("<div>hello</div>");
|
|
21
20
|
});
|
|
22
21
|
|
|
@@ -25,11 +24,9 @@ describe("ngBindHtml", () => {
|
|
|
25
24
|
|
|
26
25
|
[null, undefined, ""].forEach((val) => {
|
|
27
26
|
$rootScope.html = "some val";
|
|
28
|
-
$rootScope.$digest();
|
|
29
27
|
expect(element.html()).toEqual("some val");
|
|
30
28
|
|
|
31
29
|
$rootScope.html = val;
|
|
32
|
-
$rootScope.$digest();
|
|
33
30
|
expect(element.html()).toEqual("");
|
|
34
31
|
});
|
|
35
32
|
});
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
<script src="/jasmine/jasmine-5.1.2/jasmine-html.js"></script>
|
|
11
11
|
<script src="/jasmine/jasmine-5.1.2/boot0.js"></script>
|
|
12
12
|
<script src="/jasmine/jasmine-5.1.2/boot1.js"></script>
|
|
13
|
-
<script type="module" src="/src/
|
|
13
|
+
<script type="module" src="/src/directive/channel/channel.spec.js"></script>
|
|
14
14
|
</head>
|
|
15
15
|
<body>
|
|
16
16
|
<div id="dummy"></div>
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { EventBus } from "../../core/pubsub/pubsub";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Dynamically updates an element's content based on events published on a specified channel.
|
|
5
|
+
* When the directive is applied, it listens for data sent via `EventBus` and
|
|
6
|
+
* updates the inner HTML of the element accordingly.
|
|
7
|
+
*
|
|
8
|
+
* When the scope is destroyed, the directive automatically unsubscribes from the channel.
|
|
9
|
+
*
|
|
10
|
+
*
|
|
11
|
+
* @returns {import("../../types").Directive}
|
|
12
|
+
*/
|
|
13
|
+
export function ngChannelDirective() {
|
|
14
|
+
return {
|
|
15
|
+
restrict: "EA",
|
|
16
|
+
link: (scope, element, attrs) => {
|
|
17
|
+
const targetElement = element[0];
|
|
18
|
+
const channel = attrs["ngChannel"];
|
|
19
|
+
|
|
20
|
+
const key = EventBus.subscribe(channel, (val) => {
|
|
21
|
+
targetElement.innerHTML = val;
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
scope.$on("$destroy", () => {
|
|
25
|
+
EventBus.unsubscribeByKey(key);
|
|
26
|
+
});
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { Angular } from "../../loader";
|
|
2
|
+
import { EventBus } from "../../core/pubsub/pubsub";
|
|
3
|
+
import { wait } from "../../shared/test-utils";
|
|
4
|
+
|
|
5
|
+
describe("channel", () => {
|
|
6
|
+
let $compile, $scope, element, unsubscribeSpy;
|
|
7
|
+
|
|
8
|
+
beforeEach(() => {
|
|
9
|
+
window.angular = new Angular();
|
|
10
|
+
angular.module("myModule", ["ng"]);
|
|
11
|
+
angular
|
|
12
|
+
.bootstrap(document.getElementById("dummy"), ["myModule"])
|
|
13
|
+
.invoke((_$compile_, _$rootScope_) => {
|
|
14
|
+
$compile = _$compile_;
|
|
15
|
+
$scope = _$rootScope_;
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
spyOn(EventBus, "subscribe").and.callThrough();
|
|
19
|
+
unsubscribeSpy = spyOn(EventBus, "unsubscribeByKey").and.callThrough();
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it("should subscribe to the specified EventBus channel", () => {
|
|
23
|
+
element = $compile('<div ng-channel="testChannel"></div>')($scope);
|
|
24
|
+
$scope.$digest();
|
|
25
|
+
|
|
26
|
+
expect(EventBus.subscribe).toHaveBeenCalledWith(
|
|
27
|
+
"testChannel",
|
|
28
|
+
jasmine.any(Function),
|
|
29
|
+
);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it("should update innerHtml when EventBus emits a value", async () => {
|
|
33
|
+
element = $compile('<div ng-channel="testChannel"></div>')($scope);
|
|
34
|
+
$scope.$digest();
|
|
35
|
+
|
|
36
|
+
expect(element[0].innerHTML).toBe("");
|
|
37
|
+
|
|
38
|
+
EventBus.publish("testChannel", "New Content");
|
|
39
|
+
await wait(10);
|
|
40
|
+
|
|
41
|
+
expect(element[0].innerHTML).toBe("New Content");
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it("should unsubscribe from the EventBus when the scope is destroyed", () => {
|
|
45
|
+
element = $compile('<div ng-channel="testChannel"></div>')($scope);
|
|
46
|
+
$scope.$digest();
|
|
47
|
+
|
|
48
|
+
$scope.$destroy();
|
|
49
|
+
|
|
50
|
+
expect(unsubscribeSpy).toHaveBeenCalled();
|
|
51
|
+
});
|
|
52
|
+
});
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { test, expect } from "@playwright/test";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
test("unit tests contain no errors", async ({ page }) => {
|
|
6
|
-
await page.goto(TEST_URL);
|
|
3
|
+
test("unit observer tests contain no errors", async ({ page }) => {
|
|
4
|
+
await page.goto("src/directive/channel/channel.html");
|
|
7
5
|
await page.content();
|
|
8
6
|
await expect(page.locator(".jasmine-overall-result")).toHaveText(
|
|
9
7
|
/0 failures/,
|
|
@@ -47,7 +47,7 @@ function classDirective(name, selector) {
|
|
|
47
47
|
if (hasAnimate(element[0])) {
|
|
48
48
|
attr.$addClass(classString);
|
|
49
49
|
} else {
|
|
50
|
-
scope
|
|
50
|
+
scope.$postUpdate(() => {
|
|
51
51
|
if (classString !== "") {
|
|
52
52
|
element[0].classList.add(...classString.trim().split(" "));
|
|
53
53
|
}
|
|
@@ -60,7 +60,7 @@ function classDirective(name, selector) {
|
|
|
60
60
|
if (hasAnimate(element[0])) {
|
|
61
61
|
attr.$removeClass(classString);
|
|
62
62
|
} else {
|
|
63
|
-
scope
|
|
63
|
+
scope.$postUpdate(() => {
|
|
64
64
|
if (classString !== "") {
|
|
65
65
|
element[0].classList.remove(...classString.trim().split(" "));
|
|
66
66
|
}
|
|
@@ -82,7 +82,7 @@ function classDirective(name, selector) {
|
|
|
82
82
|
attr.$addClass(toAddString);
|
|
83
83
|
attr.$removeClass(toRemoveString);
|
|
84
84
|
} else {
|
|
85
|
-
scope
|
|
85
|
+
scope.$postUpdate(() => {
|
|
86
86
|
if (toAddString !== "") {
|
|
87
87
|
element[0].classList.add(...toAddString.trim().split(" "));
|
|
88
88
|
}
|