@angular-wave/angular.ts 0.0.27 → 0.0.29
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/README.md +1 -2
- package/dist/angular-ts.esm.js +1 -1
- package/dist/angular-ts.umd.js +1 -1
- package/e2e/unit.spec.ts +2 -1
- package/index.html +6 -6
- package/package.json +1 -1
- package/src/core/pubsub.js +329 -0
- package/src/router/common/trace.js +6 -6
- package/src/router/directives/state-directives.js +74 -74
- package/src/router/directives/view-directive.js +21 -21
- package/src/router/hooks/core-resolvables.js +12 -11
- package/src/router/hooks/ignored-transition.js +1 -1
- package/src/router/hooks/lazy-load.js +40 -41
- package/src/router/hooks/redirect-to.js +32 -29
- package/src/router/hooks/update-globals.js +1 -1
- package/src/router/hooks/url.js +33 -24
- package/src/router/hooks/views.js +21 -20
- package/src/router/index.js +12 -12
- package/src/router/injectables.js +3 -3
- package/src/router/params/param-factory.js +17 -0
- package/src/router/router.js +75 -10
- package/src/router/services.js +4 -8
- package/src/router/state/state-builder.js +1 -0
- package/src/router/state/state-queue-manager.js +5 -4
- package/src/router/state/state-registry.js +63 -7
- package/src/router/state/state-service.js +47 -51
- package/src/router/state/views.js +4 -4
- package/src/router/state-filters.js +0 -2
- package/src/router/state-provider.js +0 -2
- package/src/router/template-factory.js +4 -4
- package/src/router/transition/hook-builder.js +2 -2
- package/src/router/transition/transition-hook.js +2 -1
- package/src/router/transition/transition-service.js +11 -18
- package/src/router/transition/transition.js +28 -25
- package/src/router/url/url-config.js +1 -49
- package/src/router/url/url-matcher-factory.js +10 -51
- package/src/router/url/url-router.js +31 -17
- package/src/router/url/url-rule.js +9 -13
- package/src/router/url/url-rules.js +3 -3
- package/src/router/url/url-service.js +22 -18
- package/src/router/view/view.js +67 -67
- package/src/services/browser.js +1 -5
- package/src/shared/hof.js +1 -1
- package/test/angular.spec.js +1 -0
- package/test/aria/aria.spec.js +2 -1
- package/test/core/pubsub.spec.js +387 -0
- package/test/directive/bind.spec.js +2 -1
- package/test/directive/boolean.spec.js +4 -2
- package/test/directive/change.spec.js +1 -1
- package/test/directive/class.spec.js +1 -0
- package/test/directive/click.spec.js +2 -1
- package/test/directive/cloak.spec.js +1 -2
- package/test/directive/{constoller.spec.js → controller.spec.js} +1 -0
- package/test/directive/element-style.spec.js +1 -0
- package/test/directive/event.spec.js +1 -1
- package/test/directive/href.spec.js +2 -1
- package/test/directive/init.spec.js +1 -0
- package/test/directive/input.spec.js +200 -285
- package/test/directive/list.spec.js +2 -1
- package/test/directive/model.spec.js +1 -0
- package/test/directive/non-bindable.spec.js +2 -1
- package/test/directive/script.spec.js +1 -0
- package/test/directive/scrset.spec.js +2 -1
- package/test/directive/show-hide.spec.js +1 -0
- package/test/directive/src.spec.js +2 -1
- package/test/directive/style.spec.js +1 -0
- package/test/directive/switch.spec.js +2 -1
- package/test/directive/validators.spec.js +1 -1
- package/test/module-test.html +5 -5
- package/test/original-test.html +3 -3
- package/test/router/services.spec.js +1 -1
- package/test/router/state-directives.spec.js +72 -80
- package/test/router/state-filter.spec.js +6 -4
- package/test/router/state.spec.js +15 -13
- package/test/router/template-factory.spec.js +4 -4
- package/test/router/url-matcher-factory.spec.js +2 -2
- package/test/router/view-directive.spec.js +165 -163
- package/test/router/view-hook.spec.js +4 -4
- package/test/router/view-scroll.spec.js +15 -15
- package/test/router/view.spec.js +3 -3
- package/types/router/core/common/coreservices.d.ts +2 -3
- package/types/router/core/globals.d.ts +1 -4
- package/types/router/core/interface.d.ts +2 -8
- package/types/router/core/params/paramTypes.d.ts +0 -1
- package/types/router/core/router.d.ts +2 -3
- package/types/router/core/state/interface.d.ts +6 -6
- package/types/router/core/state/stateQueueManager.d.ts +1 -3
- package/types/router/core/state/stateRegistry.d.ts +1 -2
- package/types/router/core/state/stateService.d.ts +5 -6
- package/types/router/core/transition/interface.d.ts +4 -4
- package/types/router/core/transition/transitionService.d.ts +1 -2
- package/types/router/core/url/urlConfig.d.ts +1 -2
- package/types/router/core/url/urlRules.d.ts +1 -2
- package/types/router/core/url/urlService.d.ts +1 -2
- package/types/router/core/view/interface.d.ts +2 -2
- package/types/router/core/view/view.d.ts +16 -16
- package/types/router/directives/viewDirective.d.ts +3 -3
- package/types/router/interface.d.ts +4 -4
- package/types/router/locationServices.d.ts +0 -1
- package/types/router/stateProvider.d.ts +3 -3
- package/types/router/statebuilders/views.d.ts +1 -1
- package/types/router/templateFactory.d.ts +2 -2
- package/types/router/viewScroll.d.ts +1 -1
package/test/aria/aria.spec.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createInjector } from "../../src/injector";
|
|
2
2
|
import { publishExternalAPI } from "../../src/public";
|
|
3
|
-
import { dealoc } from "../../src/jqLite";
|
|
3
|
+
import { dealoc, jqLite } from "../../src/jqLite";
|
|
4
4
|
|
|
5
5
|
describe("$aria", () => {
|
|
6
6
|
let scope;
|
|
@@ -17,6 +17,7 @@ describe("$aria", () => {
|
|
|
17
17
|
|
|
18
18
|
afterEach(() => {
|
|
19
19
|
dealoc(element);
|
|
20
|
+
jqLite.CACHE.clear();
|
|
20
21
|
});
|
|
21
22
|
|
|
22
23
|
describe("with `ngAriaDisable`", () => {
|
|
@@ -0,0 +1,387 @@
|
|
|
1
|
+
import { PubSub } from "../../src/core/pubsub";
|
|
2
|
+
|
|
3
|
+
describe("PubSub", function () {
|
|
4
|
+
let pubsub;
|
|
5
|
+
let asyncPubsub;
|
|
6
|
+
|
|
7
|
+
beforeEach(function () {
|
|
8
|
+
pubsub = new PubSub();
|
|
9
|
+
asyncPubsub = new PubSub(true);
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
afterEach(function () {
|
|
13
|
+
asyncPubsub.dispose();
|
|
14
|
+
pubsub.dispose();
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it("should create a PubSub instance", function () {
|
|
18
|
+
expect(pubsub).not.toBeNull();
|
|
19
|
+
expect(pubsub instanceof PubSub).toBe(true);
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it("should dispose of the PubSub instance", function () {
|
|
23
|
+
expect(pubsub.isDisposed()).toBe(false);
|
|
24
|
+
pubsub.dispose();
|
|
25
|
+
expect(pubsub.isDisposed()).toBe(true);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it("should subscribe and unsubscribe correctly", function () {
|
|
29
|
+
function foo1() {}
|
|
30
|
+
function bar1() {}
|
|
31
|
+
function foo2() {}
|
|
32
|
+
function bar2() {}
|
|
33
|
+
|
|
34
|
+
expect(pubsub.getCount("foo")).toBe(0);
|
|
35
|
+
expect(pubsub.getCount("bar")).toBe(0);
|
|
36
|
+
|
|
37
|
+
pubsub.subscribe("foo", foo1);
|
|
38
|
+
expect(pubsub.getCount("foo")).toBe(1);
|
|
39
|
+
expect(pubsub.getCount("bar")).toBe(0);
|
|
40
|
+
|
|
41
|
+
pubsub.subscribe("bar", bar1);
|
|
42
|
+
expect(pubsub.getCount("foo")).toBe(1);
|
|
43
|
+
expect(pubsub.getCount("bar")).toBe(1);
|
|
44
|
+
|
|
45
|
+
pubsub.subscribe("foo", foo2);
|
|
46
|
+
expect(pubsub.getCount("foo")).toBe(2);
|
|
47
|
+
expect(pubsub.getCount("bar")).toBe(1);
|
|
48
|
+
|
|
49
|
+
pubsub.subscribe("bar", bar2);
|
|
50
|
+
expect(pubsub.getCount("foo")).toBe(2);
|
|
51
|
+
expect(pubsub.getCount("bar")).toBe(2);
|
|
52
|
+
|
|
53
|
+
expect(pubsub.unsubscribe("foo", foo1)).toBe(true);
|
|
54
|
+
expect(pubsub.getCount("foo")).toBe(1);
|
|
55
|
+
expect(pubsub.getCount("bar")).toBe(2);
|
|
56
|
+
|
|
57
|
+
expect(pubsub.unsubscribe("foo", foo2)).toBe(true);
|
|
58
|
+
expect(pubsub.getCount("foo")).toBe(0);
|
|
59
|
+
expect(pubsub.getCount("bar")).toBe(2);
|
|
60
|
+
|
|
61
|
+
expect(pubsub.unsubscribe("bar", bar1)).toBe(true);
|
|
62
|
+
expect(pubsub.getCount("foo")).toBe(0);
|
|
63
|
+
expect(pubsub.getCount("bar")).toBe(1);
|
|
64
|
+
|
|
65
|
+
expect(pubsub.unsubscribe("bar", bar2)).toBe(true);
|
|
66
|
+
expect(pubsub.getCount("foo")).toBe(0);
|
|
67
|
+
expect(pubsub.getCount("bar")).toBe(0);
|
|
68
|
+
|
|
69
|
+
expect(pubsub.unsubscribe("baz", foo1)).toBe(false);
|
|
70
|
+
expect(pubsub.unsubscribe("foo", () => {})).toBe(false);
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it("should subscribe and unsubscribe with context correctly", function () {
|
|
74
|
+
function foo() {}
|
|
75
|
+
function bar() {}
|
|
76
|
+
|
|
77
|
+
const contextA = {};
|
|
78
|
+
const contextB = {};
|
|
79
|
+
|
|
80
|
+
expect(pubsub.getCount("X")).toBe(0);
|
|
81
|
+
|
|
82
|
+
pubsub.subscribe("X", foo, contextA);
|
|
83
|
+
expect(pubsub.getCount("X")).toBe(1);
|
|
84
|
+
|
|
85
|
+
pubsub.subscribe("X", bar);
|
|
86
|
+
expect(pubsub.getCount("X")).toBe(2);
|
|
87
|
+
|
|
88
|
+
pubsub.subscribe("X", bar, contextB);
|
|
89
|
+
expect(pubsub.getCount("X")).toBe(3);
|
|
90
|
+
|
|
91
|
+
expect(pubsub.unsubscribe("X", foo, contextB)).toBe(false);
|
|
92
|
+
|
|
93
|
+
expect(pubsub.unsubscribe("X", foo, contextA)).toBe(true);
|
|
94
|
+
expect(pubsub.getCount("X")).toBe(2);
|
|
95
|
+
|
|
96
|
+
expect(pubsub.unsubscribe("X", bar)).toBe(true);
|
|
97
|
+
expect(pubsub.getCount("X")).toBe(1);
|
|
98
|
+
|
|
99
|
+
expect(pubsub.unsubscribe("X", bar, contextB)).toBe(true);
|
|
100
|
+
expect(pubsub.getCount("X")).toBe(0);
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
it("should subscribe once correctly", function () {
|
|
104
|
+
let called;
|
|
105
|
+
let context;
|
|
106
|
+
|
|
107
|
+
called = false;
|
|
108
|
+
pubsub.subscribeOnce("someTopic", () => {
|
|
109
|
+
called = true;
|
|
110
|
+
});
|
|
111
|
+
expect(pubsub.getCount("someTopic")).toBe(1);
|
|
112
|
+
expect(called).toBe(false);
|
|
113
|
+
|
|
114
|
+
pubsub.publish("someTopic");
|
|
115
|
+
expect(pubsub.getCount("someTopic")).toBe(0);
|
|
116
|
+
expect(called).toBe(true);
|
|
117
|
+
|
|
118
|
+
context = { called: false };
|
|
119
|
+
pubsub.subscribeOnce(
|
|
120
|
+
"someTopic",
|
|
121
|
+
function () {
|
|
122
|
+
this.called = true;
|
|
123
|
+
},
|
|
124
|
+
context,
|
|
125
|
+
);
|
|
126
|
+
expect(pubsub.getCount("someTopic")).toBe(1);
|
|
127
|
+
expect(context.called).toBe(false);
|
|
128
|
+
|
|
129
|
+
pubsub.publish("someTopic");
|
|
130
|
+
expect(pubsub.getCount("someTopic")).toBe(0);
|
|
131
|
+
expect(context.called).toBe(true);
|
|
132
|
+
|
|
133
|
+
context = { called: false, value: 0 };
|
|
134
|
+
pubsub.subscribeOnce(
|
|
135
|
+
"someTopic",
|
|
136
|
+
function (value) {
|
|
137
|
+
this.called = true;
|
|
138
|
+
this.value = value;
|
|
139
|
+
},
|
|
140
|
+
context,
|
|
141
|
+
);
|
|
142
|
+
expect(pubsub.getCount("someTopic")).toBe(1);
|
|
143
|
+
expect(context.called).toBe(false);
|
|
144
|
+
expect(context.value).toBe(0);
|
|
145
|
+
|
|
146
|
+
pubsub.publish("someTopic", 17);
|
|
147
|
+
expect(pubsub.getCount("someTopic")).toBe(0);
|
|
148
|
+
expect(context.called).toBe(true);
|
|
149
|
+
expect(context.value).toBe(17);
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
it("should async subscribe once correctly", function (done) {
|
|
153
|
+
let callCount = 0;
|
|
154
|
+
asyncPubsub.subscribeOnce("someTopic", () => {
|
|
155
|
+
callCount++;
|
|
156
|
+
});
|
|
157
|
+
expect(asyncPubsub.getCount("someTopic")).toBe(1);
|
|
158
|
+
|
|
159
|
+
asyncPubsub.publish("someTopic");
|
|
160
|
+
asyncPubsub.publish("someTopic");
|
|
161
|
+
|
|
162
|
+
setTimeout(() => {
|
|
163
|
+
expect(asyncPubsub.getCount("someTopic")).toBe(0);
|
|
164
|
+
expect(callCount).toBe(1);
|
|
165
|
+
done();
|
|
166
|
+
}, 0);
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
it("should async subscribe once with context correctly", function (done) {
|
|
170
|
+
const context = { callCount: 0 };
|
|
171
|
+
asyncPubsub.subscribeOnce(
|
|
172
|
+
"someTopic",
|
|
173
|
+
function () {
|
|
174
|
+
this.callCount++;
|
|
175
|
+
},
|
|
176
|
+
context,
|
|
177
|
+
);
|
|
178
|
+
expect(asyncPubsub.getCount("someTopic")).toBe(1);
|
|
179
|
+
|
|
180
|
+
asyncPubsub.publish("someTopic");
|
|
181
|
+
asyncPubsub.publish("someTopic");
|
|
182
|
+
|
|
183
|
+
setTimeout(() => {
|
|
184
|
+
expect(asyncPubsub.getCount("someTopic")).toBe(0);
|
|
185
|
+
expect(context.callCount).toBe(1);
|
|
186
|
+
done();
|
|
187
|
+
}, 0);
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
it("should async subscribe once with context and value correctly", function (done) {
|
|
191
|
+
const context = { callCount: 0, value: 0 };
|
|
192
|
+
asyncPubsub.subscribeOnce(
|
|
193
|
+
"someTopic",
|
|
194
|
+
function (value) {
|
|
195
|
+
this.callCount++;
|
|
196
|
+
this.value = value;
|
|
197
|
+
},
|
|
198
|
+
context,
|
|
199
|
+
);
|
|
200
|
+
expect(asyncPubsub.getCount("someTopic")).toBe(1);
|
|
201
|
+
|
|
202
|
+
asyncPubsub.publish("someTopic", 17);
|
|
203
|
+
asyncPubsub.publish("someTopic", 42);
|
|
204
|
+
|
|
205
|
+
setTimeout(() => {
|
|
206
|
+
expect(asyncPubsub.getCount("someTopic")).toBe(0);
|
|
207
|
+
expect(context.callCount).toBe(1);
|
|
208
|
+
expect(context.value).toBe(17);
|
|
209
|
+
done();
|
|
210
|
+
}, 0);
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
it("should subscribe once with bound function correctly", function () {
|
|
214
|
+
const context = { called: false, value: 0 };
|
|
215
|
+
|
|
216
|
+
function subscriber(value) {
|
|
217
|
+
this.called = true;
|
|
218
|
+
this.value = value;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
pubsub.subscribeOnce("someTopic", subscriber.bind(context));
|
|
222
|
+
expect(pubsub.getCount("someTopic")).toBe(1);
|
|
223
|
+
expect(context.called).toBe(false);
|
|
224
|
+
expect(context.value).toBe(0);
|
|
225
|
+
|
|
226
|
+
pubsub.publish("someTopic", 17);
|
|
227
|
+
expect(pubsub.getCount("someTopic")).toBe(0);
|
|
228
|
+
expect(context.called).toBe(true);
|
|
229
|
+
expect(context.value).toBe(17);
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
it("should subscribe once with partial function correctly", function () {
|
|
233
|
+
let called = false;
|
|
234
|
+
let value = 0;
|
|
235
|
+
|
|
236
|
+
function subscriber(hasBeenCalled, newValue) {
|
|
237
|
+
called = hasBeenCalled;
|
|
238
|
+
value = newValue;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
pubsub.subscribeOnce("someTopic", subscriber.bind(null, true));
|
|
242
|
+
expect(pubsub.getCount("someTopic")).toBe(1);
|
|
243
|
+
expect(called).toBe(false);
|
|
244
|
+
expect(value).toBe(0);
|
|
245
|
+
|
|
246
|
+
pubsub.publish("someTopic", 17);
|
|
247
|
+
expect(pubsub.getCount("someTopic")).toBe(0);
|
|
248
|
+
expect(called).toBe(true);
|
|
249
|
+
expect(value).toBe(17);
|
|
250
|
+
});
|
|
251
|
+
|
|
252
|
+
it("should handle self resubscribe correctly", function () {
|
|
253
|
+
let value = null;
|
|
254
|
+
|
|
255
|
+
function resubscribe(iteration, newValue) {
|
|
256
|
+
pubsub.subscribeOnce("someTopic", resubscribe.bind(null, iteration + 1));
|
|
257
|
+
value = `${newValue}:${iteration}`;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
pubsub.subscribeOnce("someTopic", resubscribe.bind(null, 0));
|
|
261
|
+
expect(pubsub.getCount("someTopic")).toBe(1);
|
|
262
|
+
expect(value).toBeNull();
|
|
263
|
+
|
|
264
|
+
pubsub.publish("someTopic", "foo");
|
|
265
|
+
expect(pubsub.getCount("someTopic")).toBe(1);
|
|
266
|
+
expect(value).toBe("foo:0");
|
|
267
|
+
|
|
268
|
+
pubsub.publish("someTopic", "bar");
|
|
269
|
+
expect(pubsub.getCount("someTopic")).toBe(1);
|
|
270
|
+
expect(value).toBe("bar:1");
|
|
271
|
+
|
|
272
|
+
pubsub.publish("someTopic", "baz");
|
|
273
|
+
expect(pubsub.getCount("someTopic")).toBe(1);
|
|
274
|
+
expect(value).toBe("baz:2");
|
|
275
|
+
});
|
|
276
|
+
|
|
277
|
+
it("should handle async self resubscribe correctly", function (done) {
|
|
278
|
+
let value = null;
|
|
279
|
+
|
|
280
|
+
function resubscribe(iteration, newValue) {
|
|
281
|
+
asyncPubsub.subscribeOnce(
|
|
282
|
+
"someTopic",
|
|
283
|
+
resubscribe.bind(null, iteration + 1),
|
|
284
|
+
);
|
|
285
|
+
value = `${newValue}:${iteration}`;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
asyncPubsub.subscribeOnce("someTopic", resubscribe.bind(null, 0));
|
|
289
|
+
expect(asyncPubsub.getCount("someTopic")).toBe(1);
|
|
290
|
+
expect(value).toBeNull();
|
|
291
|
+
|
|
292
|
+
asyncPubsub.publish("someTopic", "foo");
|
|
293
|
+
|
|
294
|
+
setTimeout(() => {
|
|
295
|
+
expect(asyncPubsub.getCount("someTopic")).toBe(1);
|
|
296
|
+
expect(value).toBe("foo:0");
|
|
297
|
+
|
|
298
|
+
asyncPubsub.publish("someTopic", "bar");
|
|
299
|
+
|
|
300
|
+
setTimeout(() => {
|
|
301
|
+
expect(asyncPubsub.getCount("someTopic")).toBe(1);
|
|
302
|
+
expect(value).toBe("bar:1");
|
|
303
|
+
|
|
304
|
+
asyncPubsub.publish("someTopic", "baz");
|
|
305
|
+
|
|
306
|
+
setTimeout(() => {
|
|
307
|
+
expect(asyncPubsub.getCount("someTopic")).toBe(1);
|
|
308
|
+
expect(value).toBe("baz:2");
|
|
309
|
+
done();
|
|
310
|
+
}, 0);
|
|
311
|
+
}, 0);
|
|
312
|
+
}, 0);
|
|
313
|
+
});
|
|
314
|
+
|
|
315
|
+
describe("publish", () => {
|
|
316
|
+
let context, fooCalled, barCalled, SOME_TOPIC;
|
|
317
|
+
|
|
318
|
+
beforeEach(function () {
|
|
319
|
+
context = {};
|
|
320
|
+
fooCalled = false;
|
|
321
|
+
barCalled = false;
|
|
322
|
+
SOME_TOPIC = "someTopic";
|
|
323
|
+
});
|
|
324
|
+
|
|
325
|
+
function foo(record) {
|
|
326
|
+
fooCalled = true;
|
|
327
|
+
expect(record.x).toBe("x");
|
|
328
|
+
expect(record.y).toBe("y");
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
function bar(record) {
|
|
332
|
+
barCalled = true;
|
|
333
|
+
expect(this).toBe(context);
|
|
334
|
+
expect(record.x).toBe("x");
|
|
335
|
+
expect(record.y).toBe("y");
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
it("should call subscribed functions on publish", function () {
|
|
339
|
+
pubsub.subscribe(SOME_TOPIC, foo);
|
|
340
|
+
pubsub.subscribe(SOME_TOPIC, bar, context);
|
|
341
|
+
|
|
342
|
+
expect(pubsub.publish(SOME_TOPIC, { x: "x", y: "y" })).toBe(true);
|
|
343
|
+
expect(fooCalled).toBe(true, "foo() must have been called");
|
|
344
|
+
expect(barCalled).toBe(true, "bar() must have been called");
|
|
345
|
+
});
|
|
346
|
+
|
|
347
|
+
it("should not call unsubscribed functions on publish", function () {
|
|
348
|
+
pubsub.subscribe(SOME_TOPIC, foo);
|
|
349
|
+
pubsub.subscribe(SOME_TOPIC, bar, context);
|
|
350
|
+
|
|
351
|
+
pubsub.publish(SOME_TOPIC, { x: "x", y: "y" });
|
|
352
|
+
fooCalled = false;
|
|
353
|
+
barCalled = false;
|
|
354
|
+
expect(pubsub.unsubscribe(SOME_TOPIC, foo)).toBe(true);
|
|
355
|
+
|
|
356
|
+
expect(pubsub.publish(SOME_TOPIC, { x: "x", y: "y" })).toBe(true);
|
|
357
|
+
expect(fooCalled).toBe(false, "foo() must not have been called");
|
|
358
|
+
expect(barCalled).toBe(true, "bar() must have been called");
|
|
359
|
+
});
|
|
360
|
+
|
|
361
|
+
it("should only call functions subscribed to the correct topic", function () {
|
|
362
|
+
pubsub.subscribe(SOME_TOPIC, bar, context);
|
|
363
|
+
pubsub.subscribe("differentTopic", foo);
|
|
364
|
+
|
|
365
|
+
pubsub.publish(SOME_TOPIC, { x: "x", y: "y" });
|
|
366
|
+
fooCalled = false;
|
|
367
|
+
barCalled = false;
|
|
368
|
+
|
|
369
|
+
expect(pubsub.publish(SOME_TOPIC, { x: "x", y: "y" })).toBe(true);
|
|
370
|
+
expect(fooCalled).toBe(false, "foo() must not have been called");
|
|
371
|
+
expect(barCalled).toBe(true, "bar() must have been called");
|
|
372
|
+
});
|
|
373
|
+
|
|
374
|
+
it("should trigger functions if not arguments are provided", function () {
|
|
375
|
+
let called = false;
|
|
376
|
+
pubsub.subscribe(SOME_TOPIC, () => {
|
|
377
|
+
called = true;
|
|
378
|
+
0;
|
|
379
|
+
});
|
|
380
|
+
|
|
381
|
+
pubsub.publish(SOME_TOPIC);
|
|
382
|
+
|
|
383
|
+
expect(pubsub.publish(SOME_TOPIC)).toBe(true);
|
|
384
|
+
expect(called).toBeTrue();
|
|
385
|
+
});
|
|
386
|
+
});
|
|
387
|
+
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { publishExternalAPI } from "../../src/public";
|
|
2
2
|
import { createInjector } from "../../src/injector";
|
|
3
|
-
import { dealoc } from "../../src/jqLite";
|
|
3
|
+
import { dealoc, jqLite } from "../../src/jqLite";
|
|
4
4
|
|
|
5
5
|
describe("ng-bind", () => {
|
|
6
6
|
let $rootScope;
|
|
@@ -24,6 +24,7 @@ describe("ng-bind", () => {
|
|
|
24
24
|
|
|
25
25
|
afterEach(() => {
|
|
26
26
|
dealoc(element);
|
|
27
|
+
jqLite.CACHE.clear();
|
|
27
28
|
});
|
|
28
29
|
|
|
29
30
|
describe("ngBind", () => {
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { publishExternalAPI } from "../../src/public";
|
|
2
2
|
import { createInjector } from "../../src/injector";
|
|
3
|
+
import { dealoc, jqLite } from "../../src/jqLite";
|
|
3
4
|
|
|
4
5
|
describe("boolean attr directives", () => {
|
|
5
|
-
let element, $rootScope, $compile, $
|
|
6
|
+
let element, $rootScope, $compile, $rootElement;
|
|
6
7
|
|
|
7
8
|
beforeEach(() => {
|
|
8
9
|
publishExternalAPI();
|
|
@@ -19,7 +20,8 @@ describe("boolean attr directives", () => {
|
|
|
19
20
|
});
|
|
20
21
|
|
|
21
22
|
afterEach(() => {
|
|
22
|
-
|
|
23
|
+
dealoc(element);
|
|
24
|
+
jqLite.CACHE.clear();
|
|
23
25
|
});
|
|
24
26
|
|
|
25
27
|
it("should properly evaluate 0 as false", () => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { dealoc } from "../../src/jqLite";
|
|
1
|
+
import { dealoc, jqLite } from "../../src/jqLite";
|
|
2
2
|
import { publishExternalAPI } from "../../src/public";
|
|
3
3
|
import { createInjector } from "../../src/injector";
|
|
4
4
|
|
|
@@ -17,6 +17,7 @@ describe("ngClick", () => {
|
|
|
17
17
|
|
|
18
18
|
afterEach(() => {
|
|
19
19
|
dealoc(element);
|
|
20
|
+
jqLite.CACHE.clear();
|
|
20
21
|
});
|
|
21
22
|
|
|
22
23
|
it("should get called on a click", () => {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { dealoc, jqLite } from "../../src/jqLite";
|
|
2
|
-
import { setupModuleLoader } from "../../src/loader";
|
|
3
2
|
import { publishExternalAPI } from "../../src/public";
|
|
4
3
|
import { createInjector } from "../../src/injector";
|
|
5
4
|
|
|
@@ -10,7 +9,6 @@ describe("ngCloak", () => {
|
|
|
10
9
|
let injector;
|
|
11
10
|
|
|
12
11
|
beforeEach(() => {
|
|
13
|
-
setupModuleLoader(window);
|
|
14
12
|
publishExternalAPI();
|
|
15
13
|
injector = createInjector(["ng"]);
|
|
16
14
|
$compile = injector.get("$compile");
|
|
@@ -19,6 +17,7 @@ describe("ngCloak", () => {
|
|
|
19
17
|
|
|
20
18
|
afterEach(() => {
|
|
21
19
|
dealoc(element);
|
|
20
|
+
jqLite.CACHE.clear();
|
|
22
21
|
});
|
|
23
22
|
|
|
24
23
|
it("should get removed when an element is compiled", () => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { publishExternalAPI } from "../../src/public";
|
|
2
2
|
import { createInjector } from "../../src/injector";
|
|
3
|
-
import { dealoc } from "../../src/jqLite";
|
|
3
|
+
import { dealoc, jqLite } from "../../src/jqLite";
|
|
4
4
|
import { Angular } from "../../src/loader";
|
|
5
5
|
|
|
6
6
|
describe("event directives", () => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { publishExternalAPI } from "../../src/public";
|
|
2
2
|
import { createInjector } from "../../src/injector";
|
|
3
|
-
import { dealoc } from "../../src/jqLite";
|
|
3
|
+
import { dealoc, jqLite } from "../../src/jqLite";
|
|
4
4
|
import { isDefined } from "../../src/shared/utils";
|
|
5
5
|
|
|
6
6
|
describe("ngHref", () => {
|
|
@@ -22,6 +22,7 @@ describe("ngHref", () => {
|
|
|
22
22
|
|
|
23
23
|
afterEach(() => {
|
|
24
24
|
dealoc(element);
|
|
25
|
+
jqLite.CACHE.clear();
|
|
25
26
|
});
|
|
26
27
|
|
|
27
28
|
it("should interpolate the expression and bind to href", () => {
|