@angular-wave/angular.ts 0.0.19 → 0.0.20

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/index.html CHANGED
@@ -100,7 +100,9 @@
100
100
 
101
101
  <!-- Router specs-->
102
102
  <script type="module" src="test/router/glob.spec.js"></script>
103
+ <script type="module" src="test/router/state-filter.spec.js"></script>
103
104
  <script type="module" src="test/router/state.spec.js"></script>
105
+
104
106
 
105
107
 
106
108
  <!-- Run asyncs last to prevent digest polution-->
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@angular-wave/angular.ts",
3
3
  "license": "MIT",
4
- "version": "0.0.19",
4
+ "version": "0.0.20",
5
5
  "type": "module",
6
6
  "main": "dist/angular-ts.esm.js",
7
7
  "browser": "dist/angular-ts.umd.js",
@@ -6,6 +6,8 @@ import { minErr } from "../shared/utils";
6
6
 
7
7
  const err = minErr("$stateProvider");
8
8
  const validKeys = [
9
+ "$$state",
10
+ "__stateObjectCache",
9
11
  "controller",
10
12
  "controllerProvider",
11
13
  "component",
@@ -0,0 +1,146 @@
1
+ import { Angular } from "../../src/loader";
2
+ import { publishExternalAPI } from "../../src/public";
3
+
4
+ describe("router filters", function () {
5
+ let module, $parse, $state, $q, $rootScope, $location;
6
+
7
+ beforeEach(() => {
8
+ window.angular = new Angular();
9
+ publishExternalAPI();
10
+ });
11
+
12
+ afterEach(() => (window.location.hash = "#!"));
13
+
14
+ describe("isState filter", () => {
15
+ beforeEach(() => {
16
+ module = window.angular.module("defaultModule", ["ui.router"]);
17
+ module.config(function ($stateProvider) {
18
+ $stateProvider
19
+ .state({ name: "a", url: "/" })
20
+ .state({ name: "a.b", url: "/b" })
21
+ .state({ name: "with-param", url: "/with/:param" });
22
+ });
23
+ let $injector = window.angular.bootstrap(
24
+ document.getElementById("dummy"),
25
+ ["defaultModule"],
26
+ );
27
+
28
+ $injector.invoke(
29
+ (
30
+ _$parse_,
31
+ _$state_,
32
+ _$rootScope_,
33
+ _$transitions_,
34
+ _$q_,
35
+ _$location_,
36
+ _$compile_,
37
+ _$router_,
38
+ ) => {
39
+ $parse = _$parse_;
40
+ $state = _$state_;
41
+ $rootScope = _$rootScope_;
42
+ $q = _$q_;
43
+ $location = _$location_;
44
+ },
45
+ );
46
+ });
47
+ it("should return true if the current state exactly matches the input state", async () => {
48
+ await $state.go("a");
49
+ expect($parse('"a" | isState')($rootScope)).toBe(true);
50
+ });
51
+
52
+ it("should return false if the current state does not exactly match the input state", async () => {
53
+ await $state.go("a.b");
54
+ expect($parse('"a" | isState')($rootScope)).toBe(false);
55
+ });
56
+
57
+ it("should return true if the current state and param matches the input state", async () => {
58
+ await $state.go("with-param", { param: "a" });
59
+
60
+ expect($parse('"with-param" | isState: {param: "a"}')($rootScope)).toBe(
61
+ true,
62
+ );
63
+ });
64
+
65
+ it("should return false if the current state and param does not match the input state", async () => {
66
+ await $state.go("with-param", { param: "b" });
67
+
68
+ expect($parse('"with-param" | isState: {param: "a"}')($rootScope)).toBe(
69
+ false,
70
+ );
71
+ });
72
+ });
73
+
74
+ describe("includedByState filter", function () {
75
+ beforeEach(() => {
76
+ module = window.angular.module("defaultModule", ["ui.router"]);
77
+ module.config(function ($stateProvider) {
78
+ $stateProvider
79
+ .state({ name: "a", url: "/" })
80
+ .state({ name: "a.b", url: "/b" })
81
+ .state({ name: "c", url: "/c" })
82
+ .state({ name: "d", url: "/d/:id" });
83
+ });
84
+
85
+ let $injector = window.angular.bootstrap(
86
+ document.getElementById("dummy"),
87
+ ["defaultModule"],
88
+ );
89
+
90
+ $injector.invoke(
91
+ (
92
+ _$parse_,
93
+ _$state_,
94
+ _$rootScope_,
95
+ _$transitions_,
96
+ _$q_,
97
+ _$location_,
98
+ _$compile_,
99
+ _$router_,
100
+ ) => {
101
+ $parse = _$parse_;
102
+ $state = _$state_;
103
+ $rootScope = _$rootScope_;
104
+ $q = _$q_;
105
+ $location = _$location_;
106
+ },
107
+ );
108
+ });
109
+
110
+ afterEach(() => (window.location.hash = "#!"));
111
+
112
+ it("should return true if the current state exactly matches the input state", async () => {
113
+ await $state.go("a");
114
+
115
+ expect($parse('"a" | includedByState')($rootScope)).toBe(true);
116
+ });
117
+
118
+ it("should return true if the current state includes the input state", async () => {
119
+ await $state.go("a.b");
120
+
121
+ expect($parse('"a" | includedByState')($rootScope)).toBe(true);
122
+ });
123
+
124
+ it("should return false if the current state does not include input state", async () => {
125
+ await $state.go("c");
126
+
127
+ expect($parse('"a" | includedByState')($rootScope)).toBe(false);
128
+ });
129
+
130
+ it("should return true if the current state include input state and params", async () => {
131
+ await $state.go("d", { id: 123 });
132
+
133
+ expect($parse('"d" | includedByState:{ id: 123 }')($rootScope)).toBe(
134
+ true,
135
+ );
136
+ });
137
+
138
+ it("should return false if the current state does not include input state and params", async () => {
139
+ await $state.go("d", { id: 2377 });
140
+
141
+ expect($parse('"d" | includedByState:{ id: 123 }')($rootScope)).toBe(
142
+ false,
143
+ );
144
+ });
145
+ });
146
+ });