@angular-wave/angular.ts 0.0.27 → 0.0.28

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.
Files changed (73) hide show
  1. package/README.md +1 -2
  2. package/dist/angular-ts.esm.js +1 -1
  3. package/dist/angular-ts.umd.js +1 -1
  4. package/e2e/unit.spec.ts +2 -1
  5. package/index.html +8 -9
  6. package/package.json +1 -1
  7. package/src/core/pubsub.js +329 -0
  8. package/src/router/hooks/core-resolvables.js +12 -11
  9. package/src/router/hooks/ignored-transition.js +1 -1
  10. package/src/router/hooks/lazy-load.js +40 -41
  11. package/src/router/hooks/redirect-to.js +32 -29
  12. package/src/router/hooks/update-globals.js +1 -1
  13. package/src/router/hooks/url.js +33 -24
  14. package/src/router/hooks/views.js +21 -20
  15. package/src/router/params/param-factory.js +17 -0
  16. package/src/router/router.js +74 -10
  17. package/src/router/state/state-queue-manager.js +5 -4
  18. package/src/router/state/state-registry.js +8 -5
  19. package/src/router/state/state-service.js +34 -29
  20. package/src/router/transition/hook-builder.js +2 -2
  21. package/src/router/transition/transition-hook.js +2 -1
  22. package/src/router/transition/transition-service.js +12 -18
  23. package/src/router/transition/transition.js +28 -25
  24. package/src/router/url/url-config.js +1 -49
  25. package/src/router/url/url-matcher-factory.js +10 -51
  26. package/src/router/url/url-router.js +27 -17
  27. package/src/router/url/url-rule.js +9 -13
  28. package/src/router/url/url-rules.js +3 -3
  29. package/src/router/url/url-service.js +22 -18
  30. package/src/router/view/view.js +3 -3
  31. package/src/shared/hof.js +1 -1
  32. package/test/angular.spec.js +1 -0
  33. package/test/aria/aria.spec.js +2 -1
  34. package/test/core/pubsub.spec.js +314 -0
  35. package/test/directive/bind.spec.js +2 -1
  36. package/test/directive/boolean.spec.js +4 -2
  37. package/test/directive/change.spec.js +1 -1
  38. package/test/directive/class.spec.js +1 -0
  39. package/test/directive/click.spec.js +2 -1
  40. package/test/directive/cloak.spec.js +1 -2
  41. package/test/directive/{constoller.spec.js → controller.spec.js} +1 -0
  42. package/test/directive/element-style.spec.js +1 -0
  43. package/test/directive/event.spec.js +1 -1
  44. package/test/directive/href.spec.js +2 -1
  45. package/test/directive/init.spec.js +1 -0
  46. package/test/directive/input.spec.js +200 -285
  47. package/test/directive/list.spec.js +2 -1
  48. package/test/directive/model.spec.js +1 -0
  49. package/test/directive/non-bindable.spec.js +2 -1
  50. package/test/directive/script.spec.js +1 -0
  51. package/test/directive/scrset.spec.js +2 -1
  52. package/test/directive/show-hide.spec.js +1 -0
  53. package/test/directive/src.spec.js +2 -1
  54. package/test/directive/style.spec.js +1 -0
  55. package/test/directive/switch.spec.js +2 -1
  56. package/test/directive/validators.spec.js +1 -1
  57. package/test/router/view-hook.spec.js +2 -2
  58. package/test/router/view-scroll.spec.js +1 -1
  59. package/test/router/view.spec.js +1 -1
  60. package/types/router/core/common/coreservices.d.ts +2 -3
  61. package/types/router/core/globals.d.ts +1 -4
  62. package/types/router/core/interface.d.ts +2 -8
  63. package/types/router/core/params/paramTypes.d.ts +0 -1
  64. package/types/router/core/router.d.ts +2 -3
  65. package/types/router/core/state/stateQueueManager.d.ts +1 -3
  66. package/types/router/core/state/stateRegistry.d.ts +0 -2
  67. package/types/router/core/state/stateService.d.ts +1 -2
  68. package/types/router/core/transition/interface.d.ts +3 -3
  69. package/types/router/core/transition/transitionService.d.ts +1 -2
  70. package/types/router/core/url/urlConfig.d.ts +1 -2
  71. package/types/router/core/url/urlRules.d.ts +1 -2
  72. package/types/router/core/url/urlService.d.ts +1 -2
  73. package/types/router/locationServices.d.ts +0 -1
@@ -0,0 +1,314 @@
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
+ });
@@ -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, $document, $rootElement;
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
- // dealoc(element);
23
+ dealoc(element);
24
+ jqLite.CACHE.clear();
23
25
  });
24
26
 
25
27
  it("should properly evaluate 0 as false", () => {
@@ -1,5 +1,5 @@
1
1
  import { createInjector } from "../../src/injector";
2
- import { dealoc } from "../../src/jqLite";
2
+ import { dealoc, jqLite } from "../../src/jqLite";
3
3
  import { publishExternalAPI } from "../../src/public";
4
4
 
5
5
  describe("ngChange", () => {
@@ -18,6 +18,7 @@ describe("ngClass", () => {
18
18
 
19
19
  afterEach(() => {
20
20
  dealoc(element);
21
+ jqLite.CACHE.clear();
21
22
  });
22
23
 
23
24
  it("should add new and remove old classes dynamically", () => {
@@ -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", () => {
@@ -64,6 +64,7 @@ describe("ngController", () => {
64
64
 
65
65
  afterEach(() => {
66
66
  dealoc(element);
67
+ jqLite.CACHE.clear();
67
68
  });
68
69
 
69
70
  it("should instantiate controller and bind methods", () => {
@@ -17,6 +17,7 @@ describe("style", () => {
17
17
 
18
18
  afterEach(() => {
19
19
  dealoc(element);
20
+ jqLite.CACHE.clear();
20
21
  });
21
22
 
22
23
  it("should compile style element without binding", () => {
@@ -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", () => {
@@ -22,6 +22,7 @@ describe("ngInit", () => {
22
22
 
23
23
  afterEach(() => {
24
24
  dealoc(element);
25
+ jqLite.CACHE.clear();
25
26
  });
26
27
 
27
28
  it("should init model", () => {