@angular-wave/angular.ts 0.0.16 → 0.0.17

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 (298) hide show
  1. package/README.md +5 -3
  2. package/dist/angular-ts.esm.js +1 -1
  3. package/dist/angular-ts.umd.js +1 -1
  4. package/index.html +66 -57
  5. package/package.json +1 -1
  6. package/rollup.config.js +2 -6
  7. package/src/animations/animate-children-directive.js +1 -1
  8. package/src/animations/animate-css-driver.js +1 -1
  9. package/src/animations/animate-css.js +220 -15
  10. package/src/animations/animate-js-driver.js +1 -1
  11. package/src/animations/animate-js.js +2 -2
  12. package/src/animations/animate-queue.js +3 -4
  13. package/src/animations/animation.js +1 -1
  14. package/src/animations/module.js +750 -0
  15. package/src/animations/shared.js +15 -4
  16. package/src/core/animate-runner.js +1 -1
  17. package/src/core/animate.js +4 -5
  18. package/src/core/compile.js +6 -7
  19. package/src/core/controller.js +4 -3
  20. package/src/core/filter.js +1 -1
  21. package/src/core/interpolate.js +1 -1
  22. package/src/core/interval-factory.js +1 -1
  23. package/src/core/interval.js +1 -1
  24. package/src/core/location.js +1 -1
  25. package/src/core/parser/parse.js +1 -1
  26. package/src/core/q.js +2 -3
  27. package/src/core/root-scope.js +1 -1
  28. package/src/core/sanitize-uri.js +1 -1
  29. package/src/core/sce.js +1 -1
  30. package/src/core/task-tracker-factory.js +1 -1
  31. package/src/core/timeout.js +1 -1
  32. package/src/core/urlUtils.js +1 -1
  33. package/src/directive/attrs.js +1 -1
  34. package/src/directive/bind.js +1 -1
  35. package/src/directive/class.js +2 -2
  36. package/src/directive/events.js +1 -1
  37. package/src/directive/form.js +1 -1
  38. package/src/directive/include.js +1 -1
  39. package/src/directive/input.js +1 -1
  40. package/src/directive/list.js +2 -2
  41. package/src/directive/model-options.js +1 -1
  42. package/src/directive/model.js +1 -1
  43. package/src/directive/options.js +2 -3
  44. package/src/directive/ref.js +1 -1
  45. package/src/directive/repeat.js +1 -1
  46. package/src/directive/select.js +1 -1
  47. package/src/directive/switch.js +1 -1
  48. package/src/directive/transclude.js +1 -1
  49. package/src/directive/validators.js +1 -1
  50. package/src/exts/aria.js +1 -1
  51. package/src/exts/messages.js +3 -3
  52. package/src/exts/messages.md +28 -31
  53. package/src/filters/filter.js +2 -3
  54. package/src/filters/filters.js +1 -1
  55. package/src/filters/limit-to.js +1 -1
  56. package/src/filters/order-by.js +2 -3
  57. package/src/injector.js +8 -9
  58. package/src/jqLite.js +3 -4
  59. package/src/loader.js +1 -3
  60. package/src/public.js +1 -1
  61. package/src/router/common/coreservices.js +5 -0
  62. package/src/router/{core/common → common}/queue.js +1 -1
  63. package/src/router/{core/common → common}/trace.js +21 -19
  64. package/src/router/{adapter/directives → directives}/stateDirectives.js +24 -28
  65. package/src/router/{adapter/directives → directives}/viewDirective.js +10 -9
  66. package/src/router/{core/globals.js → globals.js} +13 -3
  67. package/src/router/{core/hooks → hooks}/coreResolvables.js +6 -4
  68. package/src/router/{core/hooks → hooks}/lazyLoad.js +5 -2
  69. package/src/router/{core/hooks → hooks}/redirectTo.js +1 -1
  70. package/src/router/{core/hooks → hooks}/resolve.js +5 -4
  71. package/src/router/{core/hooks → hooks}/updateGlobals.js +1 -1
  72. package/src/router/{core/hooks → hooks}/views.js +2 -3
  73. package/src/router/index.js +60 -0
  74. package/src/router/{adapter/injectables.js → injectables.js} +9 -9
  75. package/src/router/{adapter/locationServices.js → locationServices.js} +19 -12
  76. package/src/router/{core/params → params}/param.js +5 -10
  77. package/src/router/{core/params → params}/paramType.js +4 -4
  78. package/src/router/{core/params → params}/paramTypes.js +4 -3
  79. package/src/router/{core/params → params}/stateParams.js +1 -1
  80. package/src/router/{core/path → path}/pathNode.js +2 -2
  81. package/src/router/{core/path → path}/pathUtils.js +13 -7
  82. package/src/router/{core/resolve → resolve}/resolvable.js +5 -5
  83. package/src/router/{core/resolve → resolve}/resolveContext.js +16 -6
  84. package/src/router/router.js +171 -72
  85. package/src/router/{adapter/services.js → services.js} +47 -27
  86. package/src/router/{core/state → state}/stateBuilder.js +14 -10
  87. package/src/router/{core/state → state}/stateMatcher.js +2 -3
  88. package/src/router/{core/state → state}/stateObject.js +8 -6
  89. package/src/router/{core/state → state}/stateQueueManager.js +3 -3
  90. package/src/router/{core/state → state}/stateRegistry.js +6 -7
  91. package/src/router/{core/state → state}/stateService.js +12 -15
  92. package/src/router/{core/state → state}/targetState.js +2 -2
  93. package/src/router/{adapter/statebuilders → state}/views.js +17 -15
  94. package/src/router/{adapter/stateProvider.js → stateProvider.js} +52 -9
  95. package/src/router/{adapter/templateFactory.js → templateFactory.js} +10 -19
  96. package/src/router/{core/transition → transition}/hookBuilder.js +4 -3
  97. package/src/router/{core/transition → transition}/hookRegistry.js +3 -6
  98. package/src/router/{core/transition → transition}/rejectFactory.js +4 -5
  99. package/src/router/{core/transition → transition}/transition.js +10 -12
  100. package/src/router/{core/transition → transition}/transitionHook.js +4 -4
  101. package/src/router/{core/transition → transition}/transitionService.js +13 -13
  102. package/src/router/{core/url → url}/urlConfig.js +28 -19
  103. package/src/router/{core/url → url}/urlMatcher.js +14 -16
  104. package/src/router/{core/url → url}/urlMatcherFactory.js +7 -6
  105. package/src/router/{core/url → url}/urlRouter.js +6 -30
  106. package/src/router/{core/url → url}/urlRule.js +3 -3
  107. package/src/router/{core/url → url}/urlRules.js +10 -11
  108. package/src/router/{core/url → url}/urlService.js +12 -6
  109. package/src/router/{core/view → view}/view.js +32 -27
  110. package/src/router/{adapter/viewScroll.js → viewScroll.js} +3 -0
  111. package/src/services/anchor-scroll.js +1 -1
  112. package/src/services/browser.js +1 -1
  113. package/src/services/cache-factory.js +7 -1
  114. package/src/services/cookie-reader.js +1 -1
  115. package/src/services/http-backend.js +6 -1
  116. package/src/services/http.js +4 -5
  117. package/src/services/log.js +1 -1
  118. package/src/services/template-request.js +2 -2
  119. package/src/{router/core/common → shared}/common.js +35 -16
  120. package/src/{router/core/common → shared}/predicates.js +2 -12
  121. package/src/{router/core/common → shared}/strings.js +5 -13
  122. package/src/{core → shared}/utils.js +13 -29
  123. package/test/angular.spec.js +1 -31
  124. package/test/{ng → core}/animate.spec.js +1 -1
  125. package/test/{ng → core}/compile.spec.js +2 -3
  126. package/test/{ng → core}/http.spec.js +2 -2
  127. package/test/{ng → core}/on.spec.js +1 -1
  128. package/test/{ng → core}/parse.spec.js +1 -1
  129. package/test/{ng → core}/prop.spec.js +1 -1
  130. package/test/{ng → core}/scope.spec.js +1 -1
  131. package/test/{ng/directive → directive}/a.spec.js +4 -4
  132. package/test/{ng/directive → directive}/bind.spec.js +3 -3
  133. package/test/{ng/directive → directive}/boolean.spec.js +2 -2
  134. package/test/{ng/directive → directive}/change.spec.js +3 -3
  135. package/test/{ng/directive → directive}/class.spec.js +4 -4
  136. package/test/{ng/directive → directive}/click.spec.js +3 -3
  137. package/test/{ng/directive → directive}/cloak.spec.js +4 -4
  138. package/test/{ng/directive → directive}/constoller.spec.js +5 -5
  139. package/test/{ng/directive → directive}/element-style.spec.js +3 -3
  140. package/test/{ng/directive → directive}/event.spec.js +4 -4
  141. package/test/{ng/directive → directive}/form.spec.js +5 -5
  142. package/test/{ng/directive → directive}/href.spec.js +4 -4
  143. package/test/{ng/directive → directive}/if.spec.js +5 -5
  144. package/test/{ng/directive → directive}/include.spec.js +5 -5
  145. package/test/{ng/directive → directive}/init.spec.js +4 -4
  146. package/test/{ng/directive → directive}/input.spec.js +5 -5
  147. package/test/{ng/directive → directive}/list.spec.js +3 -3
  148. package/test/{ng/directive → directive}/model-options.spec.js +6 -6
  149. package/test/{ng/directive → directive}/model.spec.js +8 -8
  150. package/test/{ng/directive → directive}/non-bindable.spec.js +3 -3
  151. package/test/{ng/directive → directive}/options.spec.js +5 -5
  152. package/test/{ng/directive → directive}/ref.spec.js +2 -2
  153. package/test/{ng/directive → directive}/repeat.spec.js +5 -5
  154. package/test/{ng/directive → directive}/script.spec.js +3 -3
  155. package/test/{ng/directive → directive}/scrset.spec.js +3 -3
  156. package/test/{ng/directive → directive}/select.spec.js +5 -5
  157. package/test/{ng/directive → directive}/show-hide.spec.js +3 -3
  158. package/test/{ng/directive → directive}/src.spec.js +3 -3
  159. package/test/{ng/directive → directive}/style.spec.js +3 -3
  160. package/test/{ng/directive → directive}/switch.spec.js +3 -3
  161. package/test/{ng/directive → directive}/validators.spec.js +3 -3
  162. package/test/{ng/filter → filter}/filter.spec.js +4 -4
  163. package/test/{ng/filter → filter}/filters.spec.js +3 -3
  164. package/test/{ng/filter → filter}/limit-to.spec.js +3 -3
  165. package/test/{ng/filter → filter}/order-by.spec.js +2 -2
  166. package/test/injector.spec.js +1 -1
  167. package/test/jqlite.spec.js +1 -1
  168. package/test/messages/messages.spec.js +1 -1
  169. package/test/min-err.spec.js +1 -1
  170. package/test/original-test.html +4 -4
  171. package/test/router/glob.spec.js +78 -0
  172. package/test/router/state.spec.js +931 -0
  173. package/test/sanitize/bing-html.spec.js +1 -1
  174. package/test/shared/common.spec.js +283 -0
  175. package/test/shared/hof.spec.js +60 -0
  176. package/test/shared/strings.spec.js +40 -0
  177. package/test/{ng → shared}/utils.spec.js +1 -1
  178. package/types/router/angular.d.ts +1 -0
  179. package/types/router/core/common/common.d.ts +370 -0
  180. package/types/router/core/common/coreservices.d.ts +80 -0
  181. package/types/router/core/common/glob.d.ts +60 -0
  182. package/types/router/core/common/hof.d.ts +160 -0
  183. package/types/router/core/common/index.d.ts +8 -0
  184. package/types/router/core/common/predicates.d.ts +25 -0
  185. package/types/router/core/common/queue.d.ts +15 -0
  186. package/types/router/core/common/safeConsole.d.ts +5 -0
  187. package/types/router/core/common/strings.d.ts +64 -0
  188. package/types/router/core/common/trace.d.ts +114 -0
  189. package/types/router/core/globals.d.ts +45 -0
  190. package/types/router/core/hooks/coreResolvables.d.ts +4 -0
  191. package/types/router/core/hooks/ignoredTransition.d.ts +2 -0
  192. package/types/router/core/hooks/invalidTransition.d.ts +2 -0
  193. package/types/router/core/hooks/lazyLoad.d.ts +12 -0
  194. package/types/router/core/hooks/onEnterExitRetain.d.ts +4 -0
  195. package/types/router/core/hooks/redirectTo.d.ts +2 -0
  196. package/types/router/core/hooks/resolve.d.ts +5 -0
  197. package/types/router/core/hooks/updateGlobals.d.ts +2 -0
  198. package/types/router/core/hooks/url.d.ts +2 -0
  199. package/types/router/core/hooks/views.d.ts +3 -0
  200. package/types/router/core/index.d.ts +12 -0
  201. package/types/router/core/interface.d.ts +102 -0
  202. package/types/router/core/params/index.d.ts +12 -0
  203. package/types/router/core/params/interface.d.ts +606 -0
  204. package/types/router/core/params/param.d.ts +65 -0
  205. package/types/router/core/params/paramType.d.ts +65 -0
  206. package/types/router/core/params/paramTypes.d.ts +190 -0
  207. package/types/router/core/params/stateParams.d.ts +15 -0
  208. package/types/router/core/path/index.d.ts +2 -0
  209. package/types/router/core/path/pathNode.d.ts +60 -0
  210. package/types/router/core/path/pathUtils.d.ts +79 -0
  211. package/types/router/core/resolve/index.d.ts +3 -0
  212. package/types/router/core/resolve/interface.d.ts +210 -0
  213. package/types/router/core/resolve/resolvable.d.ts +69 -0
  214. package/types/router/core/resolve/resolveContext.d.ts +92 -0
  215. package/types/router/core/router.d.ts +95 -0
  216. package/types/router/core/state/index.d.ts +28 -0
  217. package/types/router/core/state/interface.d.ts +708 -0
  218. package/types/router/core/state/stateBuilder.d.ts +104 -0
  219. package/types/router/core/state/stateMatcher.d.ts +11 -0
  220. package/types/router/core/state/stateObject.d.ts +155 -0
  221. package/types/router/core/state/stateQueueManager.d.ts +24 -0
  222. package/types/router/core/state/stateRegistry.d.ts +136 -0
  223. package/types/router/core/state/stateService.d.ts +350 -0
  224. package/types/router/core/state/targetState.d.ts +100 -0
  225. package/types/router/core/transition/hookBuilder.d.ts +45 -0
  226. package/types/router/core/transition/hookRegistry.d.ts +93 -0
  227. package/types/router/core/transition/index.d.ts +20 -0
  228. package/types/router/core/transition/interface.d.ts +819 -0
  229. package/types/router/core/transition/rejectFactory.d.ts +103 -0
  230. package/types/router/core/transition/transition.d.ts +527 -0
  231. package/types/router/core/transition/transitionEventType.d.ts +17 -0
  232. package/types/router/core/transition/transitionHook.d.ts +88 -0
  233. package/types/router/core/transition/transitionService.d.ts +187 -0
  234. package/types/router/core/url/index.d.ts +8 -0
  235. package/types/router/core/url/interface.d.ts +156 -0
  236. package/types/router/core/url/urlConfig.d.ts +141 -0
  237. package/types/router/core/url/urlMatcher.d.ts +180 -0
  238. package/types/router/core/url/urlMatcherFactory.d.ts +52 -0
  239. package/types/router/core/url/urlRouter.d.ts +85 -0
  240. package/types/router/core/url/urlRule.d.ts +120 -0
  241. package/types/router/core/url/urlRules.d.ts +244 -0
  242. package/types/router/core/url/urlService.d.ts +206 -0
  243. package/types/router/core/vanilla.d.ts +1 -0
  244. package/types/router/core/view/index.d.ts +2 -0
  245. package/types/router/core/view/interface.d.ts +46 -0
  246. package/types/router/core/view/view.d.ts +167 -0
  247. package/types/router/directives/stateDirectives.d.ts +3 -0
  248. package/types/router/directives/viewDirective.d.ts +143 -0
  249. package/types/router/index.d.ts +19 -0
  250. package/types/router/interface.d.ts +491 -0
  251. package/types/router/legacy/resolveService.d.ts +44 -0
  252. package/types/router/legacy/stateEvents.d.ts +123 -0
  253. package/types/router/locationServices.d.ts +43 -0
  254. package/types/router/services.d.ts +15 -0
  255. package/types/router/stateFilters.d.ts +11 -0
  256. package/types/router/stateProvider.d.ts +254 -0
  257. package/types/router/statebuilders/onEnterExitRetain.d.ts +12 -0
  258. package/types/router/statebuilders/views.d.ts +41 -0
  259. package/types/router/templateFactory.d.ts +84 -0
  260. package/types/router/viewScroll.d.ts +9 -0
  261. package/src/animations/animate.css.md +0 -263
  262. package/src/animations/animate.md +0 -933
  263. package/src/router/adapter/statebuilders/onEnterExitRetain.js +0 -29
  264. package/src/router/core/common/coreservices.js +0 -15
  265. package/src/router/core/common/safeConsole.js +0 -37
  266. package/src/router/core/interface.js +0 -3
  267. package/src/router/core/resolve/interface.js +0 -10
  268. package/src/router/core/router.js +0 -203
  269. package/src/router/core/url/interface.js +0 -1
  270. package/src/router/core/view/interface.js +0 -1
  271. /package/src/router/{core/common → common}/glob.js +0 -0
  272. /package/src/router/{core/hooks → hooks}/ignoredTransition.js +0 -0
  273. /package/src/router/{core/hooks → hooks}/invalidTransition.js +0 -0
  274. /package/src/router/{core/hooks → hooks}/onEnterExitRetain.js +0 -0
  275. /package/src/router/{core/hooks → hooks}/url.js +0 -0
  276. /package/src/router/{core/params → params}/README.md +0 -0
  277. /package/src/router/{core/state → state}/README.md +0 -0
  278. /package/src/router/{adapter/stateFilters.js → stateFilters.js} +0 -0
  279. /package/src/router/{core/transition → transition}/interface.js +0 -0
  280. /package/src/router/{core/transition → transition}/transitionEventType.js +0 -0
  281. /package/src/{router/core/common → shared}/hof.js +0 -0
  282. /package/test/{ng → core}/cache-factor.spec.js +0 -0
  283. /package/test/{ng → core}/controller-provider.spec.js +0 -0
  284. /package/test/{ng → core}/cookie-reader.spec.js +0 -0
  285. /package/test/{ng → core}/document.spec.js +0 -0
  286. /package/test/{ng → core}/filter.spec.js +0 -0
  287. /package/test/{ng → core}/http-backend.spec.js +0 -0
  288. /package/test/{ng → core}/interpolate.spec.js +0 -0
  289. /package/test/{ng → core}/interval.spec.js +0 -0
  290. /package/test/{ng → core}/location.spec.js +0 -0
  291. /package/test/{ng → core}/q.spec.js +0 -0
  292. /package/test/{ng → core}/root-element.spec.js +0 -0
  293. /package/test/{ng → core}/sanitize-uri.spec.js +0 -0
  294. /package/test/{ng → core}/sce.spec.js +0 -0
  295. /package/test/{ng → core}/template-request.spec.js +0 -0
  296. /package/test/{ng → core}/timeout.spec.js +0 -0
  297. /package/test/{ng → core}/url-utils.spec.js +0 -0
  298. /package/{src/router/adapter/interface.js → types/router/injectables.d.ts} +0 -0
@@ -0,0 +1,931 @@
1
+ import { dealoc } from "../../src/jqLite";
2
+ import { Angular } from "../../src/loader";
3
+ import { publishExternalAPI } from "../../src/public";
4
+ import { isFunction } from "../../src/shared/utils";
5
+
6
+ describe("$state", () => {
7
+ let $uiRouter,
8
+ $injector,
9
+ locationProvider,
10
+ templateParams,
11
+ template,
12
+ ctrlName,
13
+ errors,
14
+ $provide,
15
+ $compile,
16
+ module;
17
+
18
+ /** @type {import("../../src/router/stateProvider").StateProvider} */
19
+ let $stateProvider;
20
+
21
+ function $get(what) {
22
+ return $injector.get(what);
23
+ }
24
+
25
+ async function initStateTo(state, params) {
26
+ const $state = $get("$state"),
27
+ $q = $get("$q");
28
+ return $state.transitionTo(state, params || {});
29
+ }
30
+
31
+ const A = {
32
+ name: "A",
33
+ data: {},
34
+ controller: function () {
35
+ log += "controller;";
36
+ },
37
+ template: "a",
38
+ },
39
+ B = { name: "B", template: "b" },
40
+ C = { name: "C", template: "c" },
41
+ D = { name: "D", params: { x: null, y: null }, template: "d" },
42
+ DD = {
43
+ name: "DD",
44
+ parent: D,
45
+ params: { x: null, y: null, z: null },
46
+ template: "dd",
47
+ },
48
+ DDDD = {
49
+ name: "DDDD",
50
+ parent: D,
51
+ controller: function () {},
52
+ template: "hey",
53
+ },
54
+ E = { name: "E", params: { i: {} }, template: "e" },
55
+ F = {
56
+ name: "F",
57
+ params: { a: "", b: false, c: 0, d: undefined, e: -1 },
58
+ template: "f",
59
+ },
60
+ H = { name: "H", data: { propA: "propA", propB: "propB" }, template: "h" },
61
+ HH = { name: "HH", parent: H, template: "hh" },
62
+ HHH = {
63
+ name: "HHH",
64
+ parent: HH,
65
+ data: { propA: "overriddenA", propC: "propC" },
66
+ template: "hhh",
67
+ },
68
+ RS = {
69
+ name: "RS",
70
+ url: "^/search?term",
71
+ reloadOnSearch: false,
72
+ template: "rs",
73
+ },
74
+ OPT = {
75
+ name: "OPT",
76
+ url: "/opt/:param",
77
+ params: { param: "100" },
78
+ template: "opt",
79
+ },
80
+ OPT2 = {
81
+ name: "OPT2",
82
+ url: "/opt2/:param2/:param3",
83
+ params: { param3: "300", param4: "400" },
84
+ template: "opt2",
85
+ },
86
+ ISS2101 = {
87
+ name: "ISS2101",
88
+ params: { bar: { squash: false, value: "qux" } },
89
+ url: "/2101/{bar:string}",
90
+ },
91
+ URLLESS = {
92
+ name: "URLLESS",
93
+ url: "/urllessparams",
94
+ params: { myparam: { type: "int" } },
95
+ },
96
+ AppInjectable = {};
97
+
98
+ let log, logEvents, logEnterExit;
99
+ function callbackLogger(state, what) {
100
+ return function () {
101
+ if (logEnterExit) log += state.name + "." + what + ";";
102
+ };
103
+ }
104
+
105
+ window.angular = new Angular();
106
+ publishExternalAPI();
107
+
108
+ afterEach(() => {
109
+ dealoc(document.getElementById("dummy"));
110
+ });
111
+
112
+ describe("provider", () => {
113
+ beforeEach(() => {
114
+ module = window.angular.module("defaultModule", ["ui.router"]);
115
+ module.config((_$stateProvider_, _$provide_) => {
116
+ $stateProvider = _$stateProvider_;
117
+ });
118
+ angular.bootstrap(document.getElementById("dummy"), ["defaultModule"]);
119
+ });
120
+
121
+ afterEach(() => {
122
+ dealoc(document.getElementById("dummy"));
123
+ });
124
+
125
+ it("should be available at config", () => {
126
+ expect($stateProvider).toBeDefined();
127
+ });
128
+
129
+ it("should should not allow states that are already registerred", () => {
130
+ expect(() => {
131
+ $stateProvider.state({ name: "toString", url: "/to-string" });
132
+ }).not.toThrow();
133
+ expect(() => {
134
+ $stateProvider.state({ name: "toString", url: "/to-string" });
135
+ }).toThrowError(/stateinvalid/);
136
+ });
137
+
138
+ it("should should not allow states that have invalid keys", () => {
139
+ expect(() => {
140
+ $stateProvider.state({ name: "faulty", faulturl: "/to-string" });
141
+ }).toThrowError(/stateinvalid/);
142
+ });
143
+
144
+ it("should requred `name` if state definition object is passed", () => {
145
+ expect(() => {
146
+ $stateProvider.state({ url: "/to-string" });
147
+ }).toThrowError(/stateinvalid/);
148
+ expect(() => {
149
+ $stateProvider.state({ name: "hasName", url: "/to-string" });
150
+ }).not.toThrowError(/stateinvalid/);
151
+ });
152
+ });
153
+
154
+ describe(".transitionTo()", function () {
155
+ let $rootScope, $state, $stateParams, $transitions, $q, $location;
156
+
157
+ beforeEach(() => {
158
+ module = window.angular.module("defaultModule", ["ui.router"]);
159
+ module.config((_$stateProvider_, _$provide_) => {
160
+ $stateProvider = _$stateProvider_;
161
+ $provide = _$provide_;
162
+
163
+ [A, B, C, D, DD, E, H, HH, HHH].forEach(function (state) {
164
+ state.onEnter = callbackLogger(state, "onEnter");
165
+ state.onExit = callbackLogger(state, "onExit");
166
+ });
167
+
168
+ $stateProvider
169
+ .state(A)
170
+ .state(B)
171
+ .state(C)
172
+ .state(D)
173
+ .state(DD)
174
+ .state(DDDD)
175
+ .state(E)
176
+ .state(F)
177
+ .state(H)
178
+ .state(HH)
179
+ .state(HHH)
180
+ .state(RS)
181
+ .state(OPT)
182
+ .state(OPT2)
183
+ .state(ISS2101)
184
+ .state(URLLESS)
185
+ .state({ name: "home", url: "/" })
186
+ .state({ name: "home.item", url: "front/:id" })
187
+ .state({
188
+ name: "about",
189
+ url: "/about",
190
+ resolve: {
191
+ stateInfo: function ($transition$) {
192
+ return [$transition$.from().name, $transition$.to().name];
193
+ },
194
+ },
195
+ onEnter: function (stateInfo) {
196
+ log = stateInfo.join(" => ");
197
+ },
198
+ })
199
+ .state({ name: "about.person", url: "/:person" })
200
+ .state({ name: "about.person.item", url: "/:id" })
201
+ .state({ name: "about.sidebar" })
202
+ .state({
203
+ name: "about.sidebar.item",
204
+ url: "/:item",
205
+ templateUrl: function (params) {
206
+ templateParams = params;
207
+ return "/templates/" + params.item + ".html";
208
+ },
209
+ })
210
+ .state({
211
+ name: "dynamicTemplate",
212
+ url: "/dynamicTemplate/:type",
213
+ templateProvider: function ($stateParams, foo) {
214
+ template = $stateParams.type + foo + "Template";
215
+ return template;
216
+ },
217
+ resolve: {
218
+ foo: function () {
219
+ return "Foo";
220
+ },
221
+ },
222
+ })
223
+ .state({
224
+ name: "dynamicController",
225
+ url: "/dynamicController/:type",
226
+ template: "a",
227
+ controllerProvider: [
228
+ "$stateParams",
229
+ function ($stateParams) {
230
+ ctrlName = $stateParams.type + "Controller";
231
+ return ctrlName;
232
+ },
233
+ ],
234
+ })
235
+ .state({
236
+ name: "home.redirect",
237
+ url: "redir",
238
+ onEnter: function ($state) {
239
+ $state.transitionTo("about");
240
+ },
241
+ })
242
+ .state({
243
+ name: "resolveFail",
244
+ url: "/resolve-fail",
245
+ resolve: {
246
+ badness: function ($q) {
247
+ return $q.reject("!");
248
+ },
249
+ },
250
+ onEnter: function (badness) {},
251
+ })
252
+ .state({
253
+ name: "resolveTimeout",
254
+ url: "/resolve-timeout/:foo",
255
+ resolve: {
256
+ value: function ($timeout) {
257
+ return $timeout(function () {
258
+ log += "Success!";
259
+ }, 1);
260
+ },
261
+ },
262
+ onEnter: function (value) {},
263
+ template: "-",
264
+ controller: function () {
265
+ log += "controller;";
266
+ },
267
+ })
268
+ .state({ name: "badParam", url: "/bad/{param:int}" })
269
+ .state({ name: "badParam2", url: "/bad2/{param:[0-9]{5}}" })
270
+
271
+ .state({ name: "json", url: "/jsonstate/{param:json}" })
272
+
273
+ .state({ name: "first", url: "^/first/subpath" })
274
+ .state({ name: "second", url: "^/second" })
275
+
276
+ // State param inheritance tests. param1 is inherited by sub1 & sub2;
277
+ // param2 should not be transferred (unless explicitly set).
278
+ .state({ name: "root", url: "^/root?param1" })
279
+ .state({ name: "root.sub1", url: "/1?param2" })
280
+ .state({
281
+ name: "logA",
282
+ url: "/logA",
283
+ template: "<div> <div ui-view/></div>",
284
+ controller: function () {
285
+ log += "logA;";
286
+ },
287
+ })
288
+ .state({
289
+ name: "logA.logB",
290
+ url: "/logB",
291
+ views: {
292
+ $default: {
293
+ template: "<div> <div ui-view/></div>",
294
+ controller: function () {
295
+ log += "logB;";
296
+ },
297
+ },
298
+ },
299
+ })
300
+ .state({
301
+ name: "logA.logB.logC",
302
+ url: "/logC",
303
+ views: {
304
+ $default: {
305
+ template: "<div> <div ui-view/></div>",
306
+ controller: function () {
307
+ log += "logC;";
308
+ },
309
+ },
310
+ },
311
+ })
312
+ .state({ name: "root.sub2", url: "/2?param2" });
313
+
314
+ $provide.value("AppInjectable", AppInjectable);
315
+ });
316
+ $injector = angular.bootstrap(document.getElementById("dummy"), [
317
+ "defaultModule",
318
+ ]);
319
+
320
+ $injector.invoke(
321
+ (
322
+ _$rootScope_,
323
+ _$state_,
324
+ _$stateParams_,
325
+ _$transitions_,
326
+ _$q_,
327
+ _$location_,
328
+ _$compile_,
329
+ ) => {
330
+ $rootScope = _$rootScope_;
331
+ $state = _$state_;
332
+ $stateParams = _$stateParams_;
333
+ $transitions = _$transitions_;
334
+ $q = _$q_;
335
+ $location = _$location_;
336
+ $compile = _$compile_;
337
+ },
338
+ );
339
+ });
340
+
341
+ it("returns a promise for the target state", () => {
342
+ const promise = $state.transitionTo(A, {});
343
+ expect(isFunction(promise.then)).toBeTruthy();
344
+ expect(promise.transition.to()).toBe(A);
345
+ });
346
+
347
+ it("returns a promise for the target state", () => {
348
+ const promise = $state.transitionTo(A, {});
349
+ expect(isFunction(promise.then)).toBeTruthy();
350
+ expect(promise.transition.to()).toBe(A);
351
+ });
352
+
353
+ it("show return promise with an error on invalid state", (done) => {
354
+ let res = $state.transitionTo("about.person.item", { id: 5 });
355
+ setTimeout(() => {
356
+ expect(res.$$state.status).toEqual(2);
357
+ done();
358
+ }, 100);
359
+ });
360
+
361
+ it("allows transitions by name", (done) => {
362
+ $state.transitionTo("A", {});
363
+ setTimeout(() => {
364
+ expect($state.current).toBe(A);
365
+ done();
366
+ });
367
+ });
368
+
369
+ describe("dynamic transitions", function () {
370
+ let dynlog, paramsChangedLog;
371
+ let dynamicstate, childWithParam, childNoParam;
372
+
373
+ beforeEach(async () => {
374
+ dynlog = paramsChangedLog = "";
375
+ dynamicstate = {
376
+ name: "dyn",
377
+ url: "^/dynstate/:path/:pathDyn?search&searchDyn",
378
+ params: {
379
+ pathDyn: { dynamic: true },
380
+ searchDyn: { dynamic: true },
381
+ },
382
+ template: "dyn state. <div ui-view></div>",
383
+ controller: function () {
384
+ this.uiOnParamsChanged = function (updatedParams) {
385
+ const paramNames = Object.keys(updatedParams).sort();
386
+ const keyValues = paramNames.map(function (key) {
387
+ return key + "=" + updatedParams[key];
388
+ });
389
+ dynlog += "[" + keyValues.join(",") + "];";
390
+ paramsChangedLog += paramNames.join(",") + ";";
391
+ };
392
+ },
393
+ };
394
+
395
+ childWithParam = {
396
+ name: "dyn.child",
397
+ url: "/child",
398
+ params: {
399
+ config: "c1", // allow empty
400
+ configDyn: { value: null, dynamic: true },
401
+ },
402
+ template: "dyn.child state",
403
+ controller: function () {
404
+ this.uiOnParamsChanged = function (updatedParams) {
405
+ const paramNames = Object.keys(updatedParams).sort();
406
+ const keyValues = paramNames.map(function (key) {
407
+ return key + "=" + updatedParams[key];
408
+ });
409
+ dynlog += "{" + keyValues.join(",") + "};";
410
+ paramsChangedLog += paramNames.join(",") + ";";
411
+ };
412
+ },
413
+ };
414
+
415
+ childNoParam = {
416
+ name: "dyn.noparams",
417
+ url: "/noparams",
418
+ template: "dyn.noparams state",
419
+ controller: function () {
420
+ this.uiOnParamsChanged = function (updatedParams) {
421
+ const paramNames = Object.keys(updatedParams).sort();
422
+ const keyValues = paramNames.map(function (key) {
423
+ return key + "=" + updatedParams[key];
424
+ });
425
+ dynlog += "<" + keyValues.join(",") + ">;";
426
+ paramsChangedLog += paramNames.join(",") + ";";
427
+ };
428
+ },
429
+ };
430
+
431
+ $stateProvider.state(dynamicstate);
432
+ $stateProvider.state(childWithParam);
433
+ $stateProvider.state(childNoParam);
434
+
435
+ $transitions.onEnter({}, function (trans, state) {
436
+ dynlog += "enter:" + state.name + ";";
437
+ });
438
+ $transitions.onExit({}, function (trans, state) {
439
+ dynlog += "exit:" + state.name + ";";
440
+ });
441
+ $transitions.onSuccess({}, function () {
442
+ dynlog += "success;";
443
+ });
444
+
445
+ $compile("<div><ui-view></ui-view></div>")($rootScope.$new());
446
+ await initStateTo(dynamicstate, {
447
+ path: "p1",
448
+ pathDyn: "pd1",
449
+ search: "s1",
450
+ searchDyn: "sd1",
451
+ });
452
+ expect(dynlog).toBe("enter:dyn;success;");
453
+ // dynlog = '';
454
+ // expect(obj($stateParams)).toEqual({ path: 'p1', pathDyn: 'pd1', search: 's1', searchDyn: 'sd1' });
455
+ // expect($location.url()).toEqual('/dynstate/p1/pd1?search=s1&searchDyn=sd1');
456
+ });
457
+
458
+ describe("[ transition.dynamic() ]:", function () {
459
+ it("is considered fully dynamic when only dynamic params have changed", function () {
460
+ const promise = $state.go(".", { pathDyn: "pd2", searchDyn: "sd2" });
461
+ expect(promise.transition.dynamic()).toBeTruthy();
462
+ });
463
+
464
+ it("is not considered fully dynamic if any state is entered", function () {
465
+ const promise = $state.go(childWithParam);
466
+ expect(promise.transition.dynamic()).toBeFalsy();
467
+ });
468
+
469
+ it("is not considered fully dynamic if any state is exited", async function () {
470
+ await initStateTo(childWithParam, {
471
+ config: "p1",
472
+ path: "p1",
473
+ pathDyn: "pd1",
474
+ search: "s1",
475
+ searchDyn: "sd1",
476
+ });
477
+ const promise = $state.go(dynamicstate);
478
+ expect(promise.transition.dynamic()).toBeFalsy();
479
+ });
480
+
481
+ it("is not considered fully dynamic if any state is reloaded", function () {
482
+ const promise = $state.go(dynamicstate, null, { reload: true });
483
+ expect(promise.transition.dynamic()).toBeFalsy();
484
+ });
485
+
486
+ it("is not considered fully dynamic if any non-dynamic parameter changes", function () {
487
+ const promise = $state.go(dynamicstate, { path: "p2" });
488
+ expect(promise.transition.dynamic()).toBeFalsy();
489
+ });
490
+ });
491
+
492
+ // describe('[ promises ]', function () {
493
+ // it('runs successful transition when fully dynamic', function () {
494
+ // let transSuccess,
495
+ // promise = $state.go(dynamicstate, { searchDyn: 'sd2' }),
496
+ // transition = promise.transition;
497
+ // transition.promise.then(function (result) {
498
+ // transSuccess = true;
499
+ // });
500
+ // $q.flush();
501
+ // expect(transition.dynamic()).toBeTruthy();
502
+ // expect(transSuccess).toBeTruthy();
503
+ // expect(dynlog).toBe('success;[searchDyn=sd2];');
504
+ // });
505
+
506
+ // it('resolves the $state.go() promise with the original/final state, when fully dynamic', function () {
507
+ // initStateTo(dynamicstate, { path: 'p1', pathDyn: 'pd1', search: 's1', searchDyn: 'sd1' });
508
+ // let destState,
509
+ // promise = $state.go(dynamicstate, { pathDyn: 'pd2', searchDyn: 'sd2' });
510
+ // promise.then(function (result) {
511
+ // destState = result;
512
+ // });
513
+ // $q.flush();
514
+ // expect(promise.transition.dynamic()).toBeTruthy();
515
+ // expect($state.current).toBe(dynamicstate);
516
+ // expect(destState).toBe(dynamicstate);
517
+ // });
518
+ // });
519
+
520
+ // describe('[ enter/exit ]', function () {
521
+ // it('does not exit nor enter any states when fully dynamic', function () {
522
+ // const promise = $state.go(dynamicstate, { searchDyn: 'sd2' });
523
+ // $q.flush();
524
+ // expect(promise.transition.dynamic()).toBeTruthy();
525
+ // expect(promise.transition.treeChanges().entering.length).toBe(0);
526
+ // expect(promise.transition.treeChanges().exiting.length).toBe(0);
527
+ // expect(promise.transition.treeChanges().retained.length).toBe(2);
528
+ // expect(dynlog).toBe('success;[searchDyn=sd2];');
529
+ // expect(obj($stateParams)).toEqual({ path: 'p1', pathDyn: 'pd1', search: 's1', searchDyn: 'sd2' });
530
+ // });
531
+
532
+ // it('does not exit nor enter the state when only dynamic search params change', function () {
533
+ // const promise = $state.go(dynamicstate, { searchDyn: 'sd2' });
534
+ // $q.flush();
535
+ // expect(promise.transition.dynamic()).toBeTruthy();
536
+ // expect(dynlog).toBe('success;[searchDyn=sd2];');
537
+ // expect(obj($stateParams)).toEqual({ path: 'p1', pathDyn: 'pd1', search: 's1', searchDyn: 'sd2' });
538
+ // });
539
+
540
+ // it('does not exit nor enter the state when only dynamic path params change', function () {
541
+ // const promise = $state.go(dynamicstate, { pathDyn: 'pd2' });
542
+ // $q.flush();
543
+ // expect(promise.transition.dynamic()).toBeTruthy();
544
+ // expect(dynlog).toBe('success;[pathDyn=pd2];');
545
+ // expect(obj($stateParams)).toEqual({ path: 'p1', pathDyn: 'pd2', search: 's1', searchDyn: 'sd1' });
546
+ // });
547
+
548
+ // it('exits and enters a state when a non-dynamic search param changes', function () {
549
+ // const promise = $state.go(dynamicstate, { search: 's2' });
550
+ // $q.flush();
551
+ // expect(promise.transition.dynamic()).toBeFalsy();
552
+ // expect(dynlog).toBe('exit:dyn;enter:dyn;success;');
553
+ // expect(obj($stateParams)).toEqual({ path: 'p1', pathDyn: 'pd1', search: 's2', searchDyn: 'sd1' });
554
+ // });
555
+
556
+ // it('exits and enters a state when a non-dynamic path param changes', function () {
557
+ // const promise = $state.go(dynamicstate, { path: 'p2' });
558
+ // $q.flush();
559
+ // expect(promise.transition.dynamic()).toBeFalsy();
560
+ // expect(dynlog).toBe('exit:dyn;enter:dyn;success;');
561
+ // expect(obj($stateParams)).toEqual({ path: 'p2', pathDyn: 'pd1', search: 's1', searchDyn: 'sd1' });
562
+ // });
563
+
564
+ // it('does not exit nor enter a state when only dynamic params change (triggered via url)', function () {
565
+ // $location.search({ search: 's1', searchDyn: 'sd2' });
566
+ // $rootScope.$broadcast('$locationChangeSuccess');
567
+ // $q.flush();
568
+ // expect(dynlog).toBe('success;[searchDyn=sd2];');
569
+ // });
570
+
571
+ // it('exits and enters a state when any non-dynamic params change (triggered via url)', function () {
572
+ // $location.search({ search: 's2', searchDyn: 'sd2' });
573
+ // $rootScope.$broadcast('$locationChangeSuccess');
574
+ // $q.flush();
575
+ // expect(dynlog).toBe('exit:dyn;enter:dyn;success;');
576
+ // });
577
+
578
+ // it('does not exit nor enter a state when only dynamic params change (triggered via $state transition)', function () {
579
+ // $state.go('.', { searchDyn: 'sd2' }, { inherit: true });
580
+ // $q.flush();
581
+ // expect(dynlog).toBe('success;[searchDyn=sd2];');
582
+ // });
583
+ // });
584
+
585
+ // describe('[ global $stateParams service ]', function () {
586
+ // it('updates the global $stateParams object', function () {
587
+ // $state.go(dynamicstate, { searchDyn: 'sd2' });
588
+ // $q.flush();
589
+ // expect(obj($stateParams)).toEqual({ path: 'p1', pathDyn: 'pd1', search: 's1', searchDyn: 'sd2' });
590
+ // });
591
+
592
+ // it('updates $stateParams and $location.search when only dynamic params change (triggered via url)', function () {
593
+ // $location.search({ search: 's1', searchDyn: 'sd2' });
594
+ // $rootScope.$broadcast('$locationChangeSuccess');
595
+ // $q.flush();
596
+ // expect($stateParams.search).toBe('s1');
597
+ // expect($stateParams.searchDyn).toBe('sd2');
598
+ // expect($location.search()).toEqual({ search: 's1', searchDyn: 'sd2' });
599
+ // });
600
+
601
+ // it('updates $stateParams and $location.search when only dynamic params change (triggered via $state transition)', function () {
602
+ // $state.go('.', { searchDyn: 'sd2' });
603
+ // $q.flush();
604
+ // expect($stateParams.search).toBe('s1');
605
+ // expect($stateParams.searchDyn).toBe('sd2');
606
+ // expect($location.search()).toEqual({ search: 's1', searchDyn: 'sd2' });
607
+ // });
608
+
609
+ // it('dynamic param changes can be observed by watching the global $stateParams', function () {
610
+ // let observedParamValue;
611
+ // function stateParamsTerm() {
612
+ // return $stateParams.searchDyn;
613
+ // }
614
+ // $rootScope.$watch(stateParamsTerm, function (newval, oldval) {
615
+ // if (newval === oldval) return;
616
+ // observedParamValue = newval;
617
+ // });
618
+ // $q.flush();
619
+
620
+ // $location.search({ search: 's1', searchDyn: 'sd2' });
621
+ // $rootScope.$broadcast('$locationChangeSuccess');
622
+ // $q.flush();
623
+ // expect(observedParamValue).toBe('sd2');
624
+ // });
625
+ // });
626
+
627
+ // describe('[ uiOnParamsChanged ]', function () {
628
+ // it('should be called when dynamic parameter values change', function () {
629
+ // $state.go('.', { searchDyn: 'sd2' });
630
+ // $q.flush();
631
+ // expect(paramsChangedLog).toBe('searchDyn;');
632
+ // });
633
+
634
+ // it("should not be called if a non-dynamic parameter changes (causing the controller's state to exit/enter)", function () {
635
+ // $state.go('.', { search: 's2', searchDyn: 'sd2' });
636
+ // $q.flush();
637
+ // expect(paramsChangedLog).toBe('');
638
+ // });
639
+
640
+ // it('should not be called, when entering a new state, if no parameter values change', function () {
641
+ // $state.go(childNoParam);
642
+ // $q.flush();
643
+ // expect(paramsChangedLog).toBe('');
644
+ // });
645
+
646
+ // it('should be called, when entering a new state, if any dynamic parameter value changed', function () {
647
+ // $state.go(childNoParam, { searchDyn: 'sd2' });
648
+ // $q.flush();
649
+ // expect(paramsChangedLog).toBe('searchDyn;');
650
+ // });
651
+
652
+ // it('should be called, when entering a new state, if a new parameter value is added', function () {
653
+ // $state.go(childWithParam, { config: 'c2' });
654
+ // $q.flush();
655
+ // expect(paramsChangedLog).toBe('config,configDyn;');
656
+ // });
657
+
658
+ // it('should be called, when reactivating the uiOnParamsChanged state, if a dynamic parameter changed', function () {
659
+ // initStateTo(childNoParam, { path: 'p1', pathDyn: 'pd1', search: 's1', searchDyn: 'sd1' });
660
+ // dynlog = paramsChangedLog = '';
661
+
662
+ // $state.go(dynamicstate, { pathDyn: 'pd2' });
663
+ // $q.flush();
664
+ // expect(paramsChangedLog).toBe('pathDyn;');
665
+ // });
666
+
667
+ // it('should not be called, when reactivating the uiOnParamsChanged state "dyn", if any of dyns non-dynamic parameters changed', function () {
668
+ // initStateTo(childNoParam, { path: 'p1', pathDyn: 'pd1', search: 's1', searchDyn: 'sd1' });
669
+ // dynlog = paramsChangedLog = '';
670
+
671
+ // $state.go(dynamicstate, { path: 'p2' });
672
+ // $q.flush();
673
+ // expect(paramsChangedLog).toBe('');
674
+ // });
675
+
676
+ // it('should be called with an object containing only the changed params', function () {
677
+ // $state.go(dynamicstate, { pathDyn: 'pd2' });
678
+ // $q.flush();
679
+ // expect(dynlog).toBe('success;[pathDyn=pd2];');
680
+
681
+ // $state.go(dynamicstate, { pathDyn: 'pd3', searchDyn: 'sd2' });
682
+ // $q.flush();
683
+ // expect(dynlog).toBe('success;[pathDyn=pd2];success;[pathDyn=pd3,searchDyn=sd2];');
684
+ // });
685
+
686
+ // it('should be called on all active controllers that have a uiOnParamsChanged', function () {
687
+ // initStateTo(childWithParam, {
688
+ // path: 'p1',
689
+ // pathDyn: 'pd1',
690
+ // search: 's1',
691
+ // searchDyn: 'sd1',
692
+ // config: 'p1',
693
+ // configDyn: 'c1',
694
+ // });
695
+ // dynlog = paramsChangedLog = '';
696
+
697
+ // $state.go(childWithParam, { pathDyn: 'pd2' });
698
+ // $q.flush();
699
+ // expect(dynlog).toBe('success;[pathDyn=pd2];{pathDyn=pd2};');
700
+
701
+ // dynlog = paramsChangedLog = '';
702
+ // $state.go(childWithParam, { pathDyn: 'pd2', searchDyn: 'sd2', configDyn: 'cd2' });
703
+ // $q.flush();
704
+ // expect(dynlog).toBe('success;[configDyn=cd2,searchDyn=sd2];{configDyn=cd2,searchDyn=sd2};');
705
+ // });
706
+ // });
707
+ });
708
+
709
+ // describe('(with dynamic params because reloadOnSearch=false)', function () {
710
+ // describe('and only query params changed', function () {
711
+ // let entered = false;
712
+ // beforeEach(function () {
713
+ // initStateTo(RS);
714
+ // $transitions.onEnter({ entering: 'RS' }, function () {
715
+ // entered = true;
716
+ // });
717
+ // });
718
+
719
+ // it("doesn't re-enter state (triggered by url change)", function () {
720
+ // $location.search({ term: 'hello' });
721
+ // $rootScope.$broadcast('$locationChangeSuccess');
722
+ // $q.flush();
723
+ // expect($location.search()).toEqual({ term: 'hello' });
724
+ // expect(entered).toBeFalsy();
725
+ // });
726
+
727
+ // it("doesn't re-enter state (triggered by $state transition)", function () {
728
+ // initStateTo(RS);
729
+ // const promise = $state.go('.', { term: 'hello' });
730
+ // let success = false,
731
+ // transition = promise.transition;
732
+ // transition.promise.then(function () {
733
+ // success = true;
734
+ // });
735
+ // $q.flush();
736
+ // expect($state.current).toBe(RS);
737
+ // expect(entered).toBeFalsy();
738
+ // expect(success).toBeTruthy();
739
+ // expect($location.search()).toEqual({ term: 'hello' });
740
+ // });
741
+
742
+ // it('updates $stateParams', function () {
743
+ // initStateTo(RS);
744
+ // $location.search({ term: 'hello' });
745
+ // $rootScope.$broadcast('$locationChangeSuccess');
746
+ // $q.flush();
747
+ // expect(obj($stateParams)).toEqual({ term: 'hello' });
748
+ // expect(entered).toBeFalsy();
749
+ // });
750
+
751
+ // it('updates URL when (triggered by $state transition)', function () {
752
+ // initStateTo(RS);
753
+ // $state.go('.', { term: 'goodbye' });
754
+ // $q.flush();
755
+ // expect(obj($stateParams)).toEqual({ term: 'goodbye' });
756
+ // expect($location.url()).toEqual('/search?term=goodbye');
757
+ // expect(entered).toBeFalsy();
758
+ // });
759
+ // });
760
+ // });
761
+
762
+ // it('ignores non-applicable state parameters', () => {
763
+ // $state.transitionTo('A', { w00t: 'hi mom!' });
764
+ // $q.flush();
765
+ // expect($state.current).toBe(A);
766
+ // }));
767
+
768
+ // it('is a no-op when passing the current state and identical parameters', () => {
769
+ // initStateTo(A);
770
+ // const promise = $state.transitionTo(A, {}); // no-op
771
+ // expect(promise).toBeDefined(); // but we still get a valid promise
772
+ // $q.flush();
773
+ // expect(resolvedValue(promise)).toBe(A);
774
+ // expect($state.current).toBe(A);
775
+ // expect(log).toBe('');
776
+ // }));
777
+
778
+ // it('aborts pending transitions (last call wins)', () => {
779
+ // initStateTo(A);
780
+ // logEvents = true;
781
+
782
+ // const superseded = $state.transitionTo(B, {});
783
+ // $state.transitionTo(C, {});
784
+ // $q.flush();
785
+ // expect($state.current).toBe(C);
786
+ // expect(resolvedError(superseded)).toBeTruthy();
787
+ // }));
788
+
789
+ // it('aborts pending transitions even when going back to the current state', () => {
790
+ // initStateTo(A);
791
+ // logEvents = true;
792
+
793
+ // const superseded = $state.transitionTo(B, {});
794
+ // $state.transitionTo(A, {});
795
+ // $q.flush();
796
+ // expect($state.current).toBe(A);
797
+ // expect(resolvedError(superseded)).toBeTruthy();
798
+ // }));
799
+
800
+ // it('aborts pending transitions when aborted from callbacks', () => {
801
+ // const superseded = $state.transitionTo('home.redirect');
802
+ // $q.flush();
803
+ // expect($state.current.name).toBe('about');
804
+ // }));
805
+
806
+ // it('triggers onEnter and onExit callbacks', () => {
807
+ // initStateTo(A);
808
+ // logEnterExit = true;
809
+ // $state.transitionTo(D, {});
810
+ // $q.flush();
811
+ // log += $state.current.name + ';';
812
+ // $state.transitionTo(DD, {});
813
+ // $q.flush();
814
+ // log += $state.current.name + ';';
815
+ // $state.transitionTo(A, {});
816
+ // $q.flush();
817
+ // expect(log).toBe(
818
+ // 'A.onExit;' + 'D.onEnter;' + 'D;' + 'DD.onEnter;' + 'DD;' + 'DD.onExit;' + 'D.onExit;' + 'A.onEnter;'
819
+ // );
820
+ // }));
821
+
822
+ // // test for #3081
823
+ // it('injects resolve values from the exited state into onExit', function (done) {
824
+ // const registry = $uiRouter.stateRegistry;
825
+ // registry.register({
826
+ // name: 'design',
827
+ // url: '/design',
828
+ // resolve: {
829
+ // cc: function () {
830
+ // return 'cc resolve';
831
+ // },
832
+ // },
833
+ // onExit: function (cc, $state$, $transition$) {
834
+ // expect($transition$.to().name).toBe('A');
835
+ // expect($transition$.from().name).toBe('design');
836
+
837
+ // expect($state$).toBe(registry.get('design'));
838
+
839
+ // expect(cc).toBe('cc resolve');
840
+
841
+ // done();
842
+ // },
843
+ // });
844
+
845
+ // $state.go('design');
846
+ // $q.flush();
847
+
848
+ // $state.go('A');
849
+ // $q.flush();
850
+ // });
851
+
852
+ // it("doesn't transition to parent state when child has no URL", () => {
853
+ // $state.transitionTo('about.sidebar');
854
+ // $q.flush();
855
+ // expect($state.current.name).toEqual('about.sidebar');
856
+ // }));
857
+
858
+ // it('notifies on failed relative state resolution', () => {
859
+ // $state.transitionTo(DD);
860
+ // $q.flush();
861
+
862
+ // let actual,
863
+ // err = "Could not resolve '^.Z' from state 'DD'";
864
+ // $state.transitionTo('^.Z', null, { relative: $state.$current }).catch(function (err) {
865
+ // actual = err;
866
+ // });
867
+ // $q.flush();
868
+ // expect(actual.detail).toEqual(err);
869
+ // }));
870
+
871
+ // it('uses the templateProvider to get template dynamically', () => {
872
+ // $state.transitionTo('dynamicTemplate', { type: 'Acme' });
873
+ // $q.flush();
874
+ // expect(template).toEqual('AcmeFooTemplate');
875
+ // }));
876
+
877
+ // it('uses the controllerProvider to get controller dynamically', () => {
878
+ // $state.transitionTo('dynamicController', { type: 'Acme' });
879
+ // $q.flush();
880
+ // expect(ctrlName).toEqual('AcmeController');
881
+ // }));
882
+
883
+ // it('updates the location #fragment, if specified', inject(function ($state, $q, $location) {
884
+ // // html5mode disabled
885
+ // locationProvider.html5Mode(false);
886
+ // expect(html5Compat(locationProvider.html5Mode())).toBe(false);
887
+ // $state.transitionTo('home.item', { id: 'world', '#': 'frag' });
888
+ // $q.flush();
889
+ // expect($location.url()).toBe('/front/world#frag');
890
+ // expect($location.hash()).toBe('frag');
891
+
892
+ // // html5mode enabled
893
+ // locationProvider.html5Mode(true);
894
+ // expect(html5Compat(locationProvider.html5Mode())).toBe(true);
895
+ // $state.transitionTo('home.item', { id: 'world', '#': 'frag' });
896
+ // $q.flush();
897
+ // expect($location.url()).toBe('/front/world#frag');
898
+ // expect($location.hash()).toBe('frag');
899
+ // }));
900
+
901
+ // it('runs a transition when the location #fragment is updated', inject(function (
902
+ // $state,
903
+ // $q,
904
+ // $location,
905
+ // $transitions
906
+ // ) {
907
+ // let transitionCount = 0;
908
+ // $transitions.onSuccess({}, function () {
909
+ // transitionCount++;
910
+ // });
911
+
912
+ // $state.transitionTo('home.item', { id: 'world', '#': 'frag' });
913
+ // $q.flush();
914
+ // expect($location.hash()).toBe('frag');
915
+ // expect(transitionCount).toBe(1);
916
+
917
+ // $state.transitionTo('home.item', { id: 'world', '#': 'blarg' });
918
+ // $q.flush();
919
+ // expect($location.hash()).toBe('blarg');
920
+ // expect(transitionCount).toBe(2);
921
+ // }));
922
+
923
+ // it('injects $transition$ into resolves', () => {
924
+ // $state.transitionTo('home');
925
+ // $q.flush();
926
+ // $state.transitionTo('about');
927
+ // $q.flush();
928
+ // expect(log).toBe('home => about');
929
+ // }));
930
+ });
931
+ });