@angular-wave/angular.ts 0.9.3 → 0.9.5

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 (703) hide show
  1. package/@types/angular.d.ts +4 -19
  2. package/@types/animations/animate.d.ts +2 -2
  3. package/@types/animations/animation.d.ts +1 -1
  4. package/@types/core/compile/attributes.d.ts +1 -1
  5. package/@types/core/compile/compile.d.ts +2 -2
  6. package/@types/core/controller/controller.d.ts +1 -1
  7. package/@types/core/controller/interface.d.ts +6 -0
  8. package/@types/core/di/ng-module.d.ts +27 -26
  9. package/@types/core/filter/filter.d.ts +5 -5
  10. package/@types/core/interpolate/interface.d.ts +13 -0
  11. package/@types/core/interpolate/interpolate.d.ts +1 -13
  12. package/@types/core/scope/scope.d.ts +4 -1
  13. package/@types/directive/http/http.d.ts +16 -16
  14. package/@types/directive/http/interface.d.ts +27 -0
  15. package/@types/directive/include/include.d.ts +4 -4
  16. package/@types/directive/inject/inject.d.ts +12 -0
  17. package/@types/directive/model/model.d.ts +1 -1
  18. package/@types/directive/script/script.d.ts +2 -2
  19. package/@types/directive/setter/setter.d.ts +4 -4
  20. package/@types/filters/filter.d.ts +2 -2
  21. package/@types/filters/filters.d.ts +2 -2
  22. package/@types/filters/interface.d.ts +8 -0
  23. package/@types/filters/limit-to.d.ts +2 -2
  24. package/@types/filters/order-by.d.ts +2 -2
  25. package/@types/interface.d.ts +105 -82
  26. package/@types/namespace.d.ts +76 -0
  27. package/@types/router/state/interface.d.ts +8 -8
  28. package/@types/router/state-filters.d.ts +4 -4
  29. package/@types/router/template-factory.d.ts +8 -8
  30. package/@types/router/transition/hook-builder.d.ts +5 -2
  31. package/@types/router/transition/hook-registry.d.ts +11 -2
  32. package/@types/router/transition/transition-service.d.ts +6 -2
  33. package/@types/router/transition/transition.d.ts +2 -2
  34. package/@types/router/view/view.d.ts +1 -8
  35. package/@types/router/view-scroll.d.ts +4 -2
  36. package/@types/services/{anchor-scroll.d.ts → anchor-scroll/anchor-scroll.d.ts} +2 -2
  37. package/@types/services/exception/exception-handler.d.ts +2 -2
  38. package/@types/services/exception/interface.d.ts +1 -1
  39. package/@types/services/http/http.d.ts +40 -2
  40. package/@types/services/http/interface.d.ts +11 -0
  41. package/@types/services/location/location.d.ts +1 -4
  42. package/@types/services/sce/sce.d.ts +3 -4
  43. package/@types/services/template-cache/template-cache.d.ts +4 -4
  44. package/@types/services/template-request/interface.d.ts +22 -0
  45. package/@types/services/{template-request.d.ts → template-request/template-request.d.ts} +4 -7
  46. package/@types/shared/common.d.ts +8 -69
  47. package/@types/shared/hof.d.ts +7 -7
  48. package/dist/angular-ts.esm.js +510 -570
  49. package/dist/angular-ts.umd.js +510 -570
  50. package/dist/angular-ts.umd.min.js +1 -1
  51. package/package.json +8 -1
  52. package/.github/workflows/ci.yml +0 -104
  53. package/.github/workflows/gh-pages.yml +0 -75
  54. package/.husky/pre-commit +0 -5
  55. package/.prettierignore +0 -9
  56. package/@types/services/cookie-reader.d.ts +0 -4
  57. package/@types/services/http-backend/http-backend.d.ts +0 -58
  58. package/@types/services/template-cache/interface.d.ts +0 -10
  59. package/CHANGELOG.md +0 -17667
  60. package/CODE_OF_CONDUCT.md +0 -3
  61. package/CONTRIBUTING.md +0 -247
  62. package/DEVELOPERS.md +0 -499
  63. package/Makefile +0 -60
  64. package/RELEASE.md +0 -86
  65. package/TRIAGING.md +0 -127
  66. package/docs/.cspell.yml +0 -8
  67. package/docs/.github/dependabot.yml +0 -14
  68. package/docs/.nvmrc +0 -1
  69. package/docs/CONTRIBUTING.md +0 -28
  70. package/docs/Dockerfile +0 -4
  71. package/docs/LICENSE +0 -201
  72. package/docs/README.md +0 -217
  73. package/docs/assets/icons/logo.svg +0 -1
  74. package/docs/assets/scss/_variables_project.scss +0 -12
  75. package/docs/assets/scss/_variables_project_after_bs.scss +0 -8
  76. package/docs/assets/scss/index.scss +0 -48
  77. package/docs/config.yaml +0 -15
  78. package/docs/content/_index.md +0 -28
  79. package/docs/content/docs/_index.md +0 -61
  80. package/docs/content/docs/directive/_index.md +0 -4
  81. package/docs/content/docs/directive/app.md +0 -11
  82. package/docs/content/docs/directive/aria.md +0 -0
  83. package/docs/content/docs/directive/bind.md +0 -72
  84. package/docs/content/docs/directive/blur.md +0 -38
  85. package/docs/content/docs/directive/channel.md +0 -37
  86. package/docs/content/docs/directive/class-even.md +0 -47
  87. package/docs/content/docs/directive/class-odd.md +0 -48
  88. package/docs/content/docs/directive/class.md +0 -64
  89. package/docs/content/docs/directive/click.md +0 -41
  90. package/docs/content/docs/directive/cloak.md +0 -74
  91. package/docs/content/docs/directive/copy.md +0 -38
  92. package/docs/content/docs/directive/cut.md +0 -40
  93. package/docs/content/docs/directive/dblclick.md +0 -41
  94. package/docs/content/docs/directive/focus.md +0 -38
  95. package/docs/content/docs/directive/get.md +0 -203
  96. package/docs/content/docs/directive/include.md +0 -7
  97. package/docs/content/docs/directive/keydown.md +0 -38
  98. package/docs/content/docs/directive/keyup.md +0 -38
  99. package/docs/content/docs/directive/load.md +0 -43
  100. package/docs/content/docs/directive/mousedown.md +0 -38
  101. package/docs/content/docs/directive/mouseenter.md +0 -38
  102. package/docs/content/docs/directive/mouseleave.md +0 -38
  103. package/docs/content/docs/directive/mousemove.md +0 -38
  104. package/docs/content/docs/directive/mouseout.md +0 -38
  105. package/docs/content/docs/directive/mouseover.md +0 -38
  106. package/docs/content/docs/directive/mouseup.md +0 -38
  107. package/docs/content/docs/directive/non-bindable.md +0 -28
  108. package/docs/content/docs/filter/_index.md +0 -4
  109. package/docs/content/docs/provider/_index.md +0 -4
  110. package/docs/content/docs/provider/eventBusProvider.md +0 -35
  111. package/docs/content/docs/provider/locationProvider.md +0 -26
  112. package/docs/content/docs/provider/logProvider.md +0 -59
  113. package/docs/content/docs/provider/templateCacheProvider.md +0 -100
  114. package/docs/content/docs/service/_index.md +0 -4
  115. package/docs/content/docs/service/eventBus.md +0 -56
  116. package/docs/content/docs/service/location.md +0 -57
  117. package/docs/content/docs/service/log.md +0 -113
  118. package/docs/content/docs/service/templateCache.md +0 -64
  119. package/docs/content/docs/service/url.md +0 -5
  120. package/docs/docker-compose.yaml +0 -12
  121. package/docs/docsy.work +0 -5
  122. package/docs/docsy.work.sum +0 -0
  123. package/docs/go.mod +0 -5
  124. package/docs/go.sum +0 -6
  125. package/docs/hugo-disabled.toml +0 -220
  126. package/docs/hugo.yaml +0 -200
  127. package/docs/layouts/404.html +0 -13
  128. package/docs/layouts/_markup/render-heading.html +0 -1
  129. package/docs/layouts/partials/hooks/head-end.html +0 -3
  130. package/docs/layouts/shortcodes/showcss.html +0 -2
  131. package/docs/layouts/shortcodes/showhtml.html +0 -2
  132. package/docs/layouts/shortcodes/showjs.html +0 -2
  133. package/docs/layouts/shortcodes/showraw.html +0 -1
  134. package/docs/layouts/shortcodes/version.html +0 -1
  135. package/docs/package-lock.json +0 -2293
  136. package/docs/package.json +0 -53
  137. package/docs/static/examples/counter/counter-test.html +0 -13
  138. package/docs/static/examples/counter/counter.html +0 -5
  139. package/docs/static/examples/counter/counter.test.js +0 -28
  140. package/docs/static/examples/eventbus/eventbus-test.html +0 -15
  141. package/docs/static/examples/eventbus/eventbus.html +0 -13
  142. package/docs/static/examples/eventbus/eventbus.js +0 -15
  143. package/docs/static/examples/eventbus/eventbus.test.js +0 -19
  144. package/docs/static/examples/ng-bind/ng-bind.html +0 -9
  145. package/docs/static/examples/ng-blur/ng-blur.html +0 -9
  146. package/docs/static/examples/ng-channel/ng-channel-test.html +0 -17
  147. package/docs/static/examples/ng-channel/ng-channel.html +0 -24
  148. package/docs/static/examples/ng-channel/ng-channel.test.js +0 -31
  149. package/docs/static/examples/ng-class/ng-class.html +0 -71
  150. package/docs/static/examples/ng-class-even/ng-class-even.html +0 -8
  151. package/docs/static/examples/ng-class-odd/ng-class-odd.html +0 -8
  152. package/docs/static/examples/ng-click/ng-click.html +0 -6
  153. package/docs/static/examples/ng-copy/ng-copy.html +0 -6
  154. package/docs/static/examples/ng-cut/ng-cut.html +0 -6
  155. package/docs/static/examples/ng-dblclick/ng-dblclick.html +0 -10
  156. package/docs/static/examples/ng-focus/ng-focus.html +0 -9
  157. package/docs/static/examples/ng-keydown/ng-keydown.html +0 -9
  158. package/docs/static/examples/ng-keyup/ng-keyup.html +0 -9
  159. package/docs/static/examples/ng-load/ng-load.html +0 -8
  160. package/docs/static/examples/ng-mousedown/ng-mousedown.html +0 -6
  161. package/docs/static/examples/ng-mouseenter/ng-mouseenter.html +0 -4
  162. package/docs/static/examples/ng-mouseleave/ng-mouseleave.html +0 -4
  163. package/docs/static/examples/ng-mousemove/ng-mousemove.html +0 -4
  164. package/docs/static/examples/ng-mouseout/ng-mouseout.html +0 -4
  165. package/docs/static/examples/ng-mouseover/ng-mouseover.html +0 -4
  166. package/docs/static/examples/ng-mouseup/ng-mouseup.html +0 -4
  167. package/docs/static/examples/ng-non-bindable/ng-non-bindable-test.html +0 -13
  168. package/docs/static/examples/ng-non-bindable/ng-non-bindable.html +0 -3
  169. package/docs/static/examples/ng-non-bindable/ng-non-bindable.test.js +0 -11
  170. package/docs/static/typedoc/.nojekyll +0 -1
  171. package/docs/static/typedoc/assets/hierarchy.js +0 -1
  172. package/docs/static/typedoc/assets/highlight.css +0 -78
  173. package/docs/static/typedoc/assets/icons.js +0 -18
  174. package/docs/static/typedoc/assets/icons.svg +0 -1
  175. package/docs/static/typedoc/assets/main.js +0 -60
  176. package/docs/static/typedoc/assets/navigation.js +0 -1
  177. package/docs/static/typedoc/assets/search.js +0 -1
  178. package/docs/static/typedoc/assets/style.css +0 -1633
  179. package/docs/static/typedoc/classes/Location.html +0 -55
  180. package/docs/static/typedoc/classes/LocationProvider.html +0 -20
  181. package/docs/static/typedoc/classes/LogProvider.html +0 -6
  182. package/docs/static/typedoc/classes/PubSub.html +0 -71
  183. package/docs/static/typedoc/classes/PubSubProvider.html +0 -3
  184. package/docs/static/typedoc/classes/TemplateCacheProvider.html +0 -5
  185. package/docs/static/typedoc/hierarchy.html +0 -1
  186. package/docs/static/typedoc/index.html +0 -1
  187. package/docs/static/typedoc/interfaces/ChangesObject.html +0 -6
  188. package/docs/static/typedoc/interfaces/ComponentOptions.html +0 -16
  189. package/docs/static/typedoc/interfaces/Controller.html +0 -12
  190. package/docs/static/typedoc/interfaces/DefaultPorts.html +0 -5
  191. package/docs/static/typedoc/interfaces/Directive.html +0 -37
  192. package/docs/static/typedoc/interfaces/DirectivePrePost.html +0 -4
  193. package/docs/static/typedoc/interfaces/Html5Mode.html +0 -23
  194. package/docs/static/typedoc/interfaces/HttpHeadersGetter.html +0 -1
  195. package/docs/static/typedoc/interfaces/HttpProviderDefaults.html +0 -31
  196. package/docs/static/typedoc/interfaces/HttpRequestConfigHeaders.html +0 -6
  197. package/docs/static/typedoc/interfaces/HttpRequestTransformer.html +0 -1
  198. package/docs/static/typedoc/interfaces/HttpResponse.html +0 -7
  199. package/docs/static/typedoc/interfaces/HttpResponseTransformer.html +0 -1
  200. package/docs/static/typedoc/interfaces/HttpService.html +0 -38
  201. package/docs/static/typedoc/interfaces/LogService.html +0 -12
  202. package/docs/static/typedoc/interfaces/NgModelController.html +0 -30
  203. package/docs/static/typedoc/interfaces/NgModelOptions.html +0 -16
  204. package/docs/static/typedoc/interfaces/Provider.html +0 -34
  205. package/docs/static/typedoc/interfaces/RequestConfig.html +0 -48
  206. package/docs/static/typedoc/interfaces/RequestShortcutConfig.html +0 -38
  207. package/docs/static/typedoc/interfaces/ServiceProvider.html +0 -5
  208. package/docs/static/typedoc/interfaces/TemplateCache.html +0 -7
  209. package/docs/static/typedoc/interfaces/TranscludeFunctionObject.html +0 -8
  210. package/docs/static/typedoc/interfaces/UrlParts.html +0 -9
  211. package/docs/static/typedoc/types/AnnotatedDirectiveFactory.html +0 -1
  212. package/docs/static/typedoc/types/AnnotatedFactory.html +0 -8
  213. package/docs/static/typedoc/types/CloneAttachFunction.html +0 -2
  214. package/docs/static/typedoc/types/ControllerConstructor.html +0 -2
  215. package/docs/static/typedoc/types/DirectiveCompileFn.html +0 -2
  216. package/docs/static/typedoc/types/DirectiveController.html +0 -2
  217. package/docs/static/typedoc/types/DirectiveFactory.html +0 -1
  218. package/docs/static/typedoc/types/DirectiveFactoryFn.html +0 -1
  219. package/docs/static/typedoc/types/DirectiveLinkFn.html +0 -2
  220. package/docs/static/typedoc/types/ExpandoStore.html +0 -2
  221. package/docs/static/typedoc/types/Expression.html +0 -6
  222. package/docs/static/typedoc/types/FilterFactory.html +0 -2
  223. package/docs/static/typedoc/types/FilterFn.html +0 -2
  224. package/docs/static/typedoc/types/HttpPromise.html +0 -1
  225. package/docs/static/typedoc/types/HttpResponseStatus.html +0 -1
  226. package/docs/static/typedoc/types/Injectable.html +0 -4
  227. package/docs/static/typedoc/types/InjectableClass.html +0 -1
  228. package/docs/static/typedoc/types/InjectableFactory.html +0 -1
  229. package/docs/static/typedoc/types/LogCall.html +0 -2
  230. package/docs/static/typedoc/types/LogServiceFactory.html +0 -2
  231. package/docs/static/typedoc/types/OnChangesObject.html +0 -2
  232. package/docs/static/typedoc/types/SwapModeType.html +0 -2
  233. package/docs/static/typedoc/types/TController.html +0 -2
  234. package/docs/static/typedoc/types/UrlChangeListener.html +0 -5
  235. package/docs/static/typedoc/variables/EventBus.html +0 -1
  236. package/docs/static/typedoc/variables/SwapMode.html +0 -11
  237. package/docs/static/version.js +0 -13
  238. package/docs/test-results/.last-run.json +0 -4
  239. package/docs/test-results/static-examples-counter-counter-counter-example/error-context.md +0 -50
  240. package/eslint.config.js +0 -26
  241. package/images/android-chrome-192x192.png +0 -0
  242. package/images/android-chrome-512x512.png +0 -0
  243. package/images/apple-touch-icon.png +0 -0
  244. package/images/favicon-16x16.png +0 -0
  245. package/images/favicon-32x32.png +0 -0
  246. package/images/favicon.ico +0 -0
  247. package/images/site.webmanifest +0 -19
  248. package/index.html +0 -86
  249. package/legacy.d.ts +0 -2599
  250. package/playwright.config.ts +0 -81
  251. package/public/jasmine/boot0.js +0 -66
  252. package/public/jasmine/boot1.js +0 -134
  253. package/public/jasmine/jasmine-html.js +0 -970
  254. package/public/jasmine/jasmine.css +0 -323
  255. package/public/jasmine/jasmine.js +0 -11406
  256. package/public/public/README.md +0 -1
  257. package/public/public/circle.html +0 -1
  258. package/public/public/jasmine-helper.css +0 -9
  259. package/public/public/my_child_directive.html +0 -1
  260. package/public/public/my_directive.html +0 -1
  261. package/public/public/my_other_directive.html +0 -1
  262. package/public/public/test.html +0 -1
  263. package/rollup.config.js +0 -51
  264. package/src/angular.js +0 -293
  265. package/src/angular.spec.js +0 -1191
  266. package/src/animations/animate-cache.js +0 -80
  267. package/src/animations/animate-children-directive.js +0 -32
  268. package/src/animations/animate-children-directive.md +0 -80
  269. package/src/animations/animate-css-driver.js +0 -284
  270. package/src/animations/animate-css.html +0 -58
  271. package/src/animations/animate-css.js +0 -915
  272. package/src/animations/animate-css.md +0 -263
  273. package/src/animations/animate-js-driver.js +0 -60
  274. package/src/animations/animate-js.html +0 -47
  275. package/src/animations/animate-js.js +0 -371
  276. package/src/animations/animate-queue.js +0 -859
  277. package/src/animations/animate-runner.js +0 -193
  278. package/src/animations/animate-swap.js +0 -33
  279. package/src/animations/animate-swap.md +0 -88
  280. package/src/animations/animate.html +0 -19
  281. package/src/animations/animate.js +0 -546
  282. package/src/animations/animate.md +0 -933
  283. package/src/animations/animate.spec.js +0 -490
  284. package/src/animations/animation.js +0 -519
  285. package/src/animations/animations.test.js +0 -10
  286. package/src/animations/interface.ts +0 -19
  287. package/src/animations/raf-scheduler.html +0 -19
  288. package/src/animations/raf-scheduler.js +0 -92
  289. package/src/animations/raf-scheduler.spec.js +0 -98
  290. package/src/animations/shared.js +0 -341
  291. package/src/binding.html +0 -19
  292. package/src/binding.spec.js +0 -474
  293. package/src/binding.test.js +0 -10
  294. package/src/core/compile/attributes.js +0 -337
  295. package/src/core/compile/compile.html +0 -19
  296. package/src/core/compile/compile.js +0 -3270
  297. package/src/core/compile/compile.md +0 -1128
  298. package/src/core/compile/compile.spec.js +0 -15574
  299. package/src/core/compile/compile.test.js +0 -12
  300. package/src/core/controller/controller.html +0 -22
  301. package/src/core/controller/controller.js +0 -189
  302. package/src/core/controller/controller.spec.js +0 -334
  303. package/src/core/controller/controller.test.js +0 -12
  304. package/src/core/core.html +0 -20
  305. package/src/core/core.test.js +0 -12
  306. package/src/core/di/injector.html +0 -19
  307. package/src/core/di/injector.js +0 -307
  308. package/src/core/di/injector.md +0 -740
  309. package/src/core/di/injector.spec.js +0 -2310
  310. package/src/core/di/injector.test.js +0 -12
  311. package/src/core/di/internal-injector.js +0 -284
  312. package/src/core/di/ng-module.html +0 -19
  313. package/src/core/di/ng-module.js +0 -226
  314. package/src/core/di/ng-module.spec.js +0 -263
  315. package/src/core/di/ng-module.test.js +0 -12
  316. package/src/core/filter/filter.html +0 -19
  317. package/src/core/filter/filter.js +0 -55
  318. package/src/core/filter/filter.md +0 -132
  319. package/src/core/filter/filter.spec.js +0 -149
  320. package/src/core/filter/filter.test.js +0 -12
  321. package/src/core/interpolate/interpolate.html +0 -22
  322. package/src/core/interpolate/interpolate.js +0 -408
  323. package/src/core/interpolate/interpolate.spec.js +0 -601
  324. package/src/core/interpolate/interpolate.test.js +0 -12
  325. package/src/core/parse/ast/ast-node.ts +0 -81
  326. package/src/core/parse/ast/ast.html +0 -19
  327. package/src/core/parse/ast/ast.js +0 -574
  328. package/src/core/parse/ast/ast.spec.js +0 -1453
  329. package/src/core/parse/ast/ast.test.js +0 -10
  330. package/src/core/parse/ast-type.js +0 -23
  331. package/src/core/parse/interface.ts +0 -84
  332. package/src/core/parse/interpreter.js +0 -915
  333. package/src/core/parse/lexer/lexer.html +0 -19
  334. package/src/core/parse/lexer/lexer.js +0 -338
  335. package/src/core/parse/lexer/lexer.spec.js +0 -303
  336. package/src/core/parse/lexer/lexer.test.js +0 -10
  337. package/src/core/parse/lexer/token.ts +0 -22
  338. package/src/core/parse/parse.html +0 -19
  339. package/src/core/parse/parse.js +0 -337
  340. package/src/core/parse/parse.md +0 -57
  341. package/src/core/parse/parse.spec.js +0 -2107
  342. package/src/core/parse/parse.test.js +0 -10
  343. package/src/core/parse/parser/parser.html +0 -19
  344. package/src/core/parse/parser/parser.js +0 -64
  345. package/src/core/parse/parser/parser.spec.js +0 -8
  346. package/src/core/parse/parser/parser.test.js +0 -10
  347. package/src/core/prop.spec.js +0 -775
  348. package/src/core/root-element.spec.js +0 -14
  349. package/src/core/sanitize/interface.ts +0 -10
  350. package/src/core/sanitize/sanitize-uri.js +0 -75
  351. package/src/core/sanitize/sanitize-uri.spec.js +0 -249
  352. package/src/core/sanitize/sanitize-uri.test.js +0 -12
  353. package/src/core/sanitize/sanitize.html +0 -22
  354. package/src/core/scope/scope.html +0 -19
  355. package/src/core/scope/scope.js +0 -1249
  356. package/src/core/scope/scope.spec.js +0 -3000
  357. package/src/core/scope/scope.test.js +0 -12
  358. package/src/directive/aria/aria.html +0 -19
  359. package/src/directive/aria/aria.js +0 -382
  360. package/src/directive/aria/aria.md +0 -145
  361. package/src/directive/aria/aria.spec.js +0 -1241
  362. package/src/directive/aria/aria.test.js +0 -12
  363. package/src/directive/attrs/attrs.html +0 -19
  364. package/src/directive/attrs/attrs.js +0 -106
  365. package/src/directive/attrs/attrs.md +0 -224
  366. package/src/directive/attrs/attrs.spec.js +0 -71
  367. package/src/directive/attrs/attrs.test.js +0 -12
  368. package/src/directive/attrs/boolean.html +0 -19
  369. package/src/directive/attrs/boolean.spec.js +0 -137
  370. package/src/directive/attrs/boolean.test.js +0 -12
  371. package/src/directive/attrs/element-style.html +0 -22
  372. package/src/directive/attrs/element-style.spec.js +0 -85
  373. package/src/directive/attrs/element-style.test.js +0 -12
  374. package/src/directive/attrs/src.html +0 -19
  375. package/src/directive/attrs/src.spec.js +0 -163
  376. package/src/directive/attrs/src.test.js +0 -12
  377. package/src/directive/bind/bind-html.spec.js +0 -36
  378. package/src/directive/bind/bind.html +0 -20
  379. package/src/directive/bind/bind.js +0 -78
  380. package/src/directive/bind/bind.md +0 -142
  381. package/src/directive/bind/bind.spec.js +0 -314
  382. package/src/directive/bind/bind.test.js +0 -12
  383. package/src/directive/channel/channel.html +0 -19
  384. package/src/directive/channel/channel.js +0 -30
  385. package/src/directive/channel/channel.spec.js +0 -67
  386. package/src/directive/channel/channel.test.js +0 -10
  387. package/src/directive/class/class-test.html +0 -23
  388. package/src/directive/class/class.html +0 -19
  389. package/src/directive/class/class.js +0 -184
  390. package/src/directive/class/class.spec.js +0 -704
  391. package/src/directive/class/class.test.js +0 -12
  392. package/src/directive/cloak/cloak.html +0 -19
  393. package/src/directive/cloak/cloak.js +0 -11
  394. package/src/directive/cloak/cloak.spec.js +0 -44
  395. package/src/directive/cloak/cloak.test.js +0 -12
  396. package/src/directive/controller/controller.html +0 -22
  397. package/src/directive/controller/controller.js +0 -11
  398. package/src/directive/controller/controller.md +0 -46
  399. package/src/directive/controller/controller.spec.js +0 -175
  400. package/src/directive/controller/controller.test.js +0 -12
  401. package/src/directive/events/click.spec.js +0 -35
  402. package/src/directive/events/event.spec.js +0 -267
  403. package/src/directive/events/events-test.html +0 -36
  404. package/src/directive/events/events.html +0 -20
  405. package/src/directive/events/events.js +0 -65
  406. package/src/directive/events/events.md +0 -125
  407. package/src/directive/events/events.test.js +0 -12
  408. package/src/directive/form/form.html +0 -19
  409. package/src/directive/form/form.js +0 -669
  410. package/src/directive/form/form.spec.js +0 -1515
  411. package/src/directive/form/form.test.js +0 -12
  412. package/src/directive/http/delete.spec.js +0 -26
  413. package/src/directive/http/form-router-test.html +0 -44
  414. package/src/directive/http/form-test.html +0 -18
  415. package/src/directive/http/get.spec.js +0 -488
  416. package/src/directive/http/http.html +0 -22
  417. package/src/directive/http/http.js +0 -342
  418. package/src/directive/http/http.test.js +0 -12
  419. package/src/directive/http/post-example.html +0 -30
  420. package/src/directive/http/post.spec.js +0 -521
  421. package/src/directive/http/put.spec.js +0 -26
  422. package/src/directive/if/if-animate-css.html +0 -57
  423. package/src/directive/if/if-animate-svg.html +0 -25
  424. package/src/directive/if/if.html +0 -19
  425. package/src/directive/if/if.js +0 -72
  426. package/src/directive/if/if.md +0 -76
  427. package/src/directive/if/if.spec.js +0 -293
  428. package/src/directive/if/if.test.js +0 -114
  429. package/src/directive/include/include.html +0 -19
  430. package/src/directive/include/include.js +0 -151
  431. package/src/directive/include/include.md +0 -87
  432. package/src/directive/include/include.spec.js +0 -734
  433. package/src/directive/include/include.test.js +0 -12
  434. package/src/directive/init/init.html +0 -19
  435. package/src/directive/init/init.js +0 -22
  436. package/src/directive/init/init.md +0 -41
  437. package/src/directive/init/init.spec.js +0 -68
  438. package/src/directive/init/init.test.js +0 -12
  439. package/src/directive/input/input-example.html +0 -15
  440. package/src/directive/input/input.html +0 -19
  441. package/src/directive/input/input.js +0 -1078
  442. package/src/directive/input/input.md +0 -706
  443. package/src/directive/input/input.spec.js +0 -3700
  444. package/src/directive/input/input.test.js +0 -12
  445. package/src/directive/messages/messages.html +0 -22
  446. package/src/directive/messages/messages.js +0 -349
  447. package/src/directive/messages/messages.md +0 -543
  448. package/src/directive/messages/messages.spec.js +0 -1083
  449. package/src/directive/messages/messages.test.js +0 -12
  450. package/src/directive/model/change.md +0 -25
  451. package/src/directive/model/model.html +0 -19
  452. package/src/directive/model/model.js +0 -1170
  453. package/src/directive/model/model.spec.js +0 -1976
  454. package/src/directive/model/model.test.js +0 -12
  455. package/src/directive/model-options/model-option.test.js +0 -12
  456. package/src/directive/model-options/model-options.html +0 -22
  457. package/src/directive/model-options/model-options.js +0 -142
  458. package/src/directive/model-options/model-options.md +0 -407
  459. package/src/directive/model-options/model-options.spec.js +0 -1022
  460. package/src/directive/non-bindable/non-bindable.html +0 -22
  461. package/src/directive/non-bindable/non-bindable.js +0 -9
  462. package/src/directive/non-bindable/non-bindable.spec.js +0 -59
  463. package/src/directive/non-bindable/non-bindable.test.js +0 -12
  464. package/src/directive/observe/observe-demo.html +0 -184
  465. package/src/directive/observe/observe.html +0 -19
  466. package/src/directive/observe/observe.js +0 -41
  467. package/src/directive/observe/observe.spec.js +0 -106
  468. package/src/directive/observe/observe.test.js +0 -10
  469. package/src/directive/on/on.html +0 -19
  470. package/src/directive/on/on.spec.js +0 -215
  471. package/src/directive/on/on.test.js +0 -12
  472. package/src/directive/options/options-example.html +0 -17
  473. package/src/directive/options/options.html +0 -22
  474. package/src/directive/options/options.js +0 -542
  475. package/src/directive/options/options.md +0 -179
  476. package/src/directive/options/options.spec.js +0 -3554
  477. package/src/directive/options/options.test.js +0 -12
  478. package/src/directive/ref/href.html +0 -19
  479. package/src/directive/ref/href.spec.js +0 -141
  480. package/src/directive/ref/href.test.js +0 -19
  481. package/src/directive/ref/ref.html +0 -19
  482. package/src/directive/ref/ref.js +0 -89
  483. package/src/directive/ref/ref.spec.js +0 -546
  484. package/src/directive/repeat/repeat.html +0 -19
  485. package/src/directive/repeat/repeat.js +0 -333
  486. package/src/directive/repeat/repeat.md +0 -330
  487. package/src/directive/repeat/repeat.spec.js +0 -1209
  488. package/src/directive/repeat/repeat.test.js +0 -12
  489. package/src/directive/script/script.html +0 -19
  490. package/src/directive/script/script.js +0 -17
  491. package/src/directive/script/script.md +0 -11
  492. package/src/directive/script/script.spec.js +0 -47
  493. package/src/directive/script/script.test.js +0 -12
  494. package/src/directive/select/select.html +0 -19
  495. package/src/directive/select/select.js +0 -594
  496. package/src/directive/select/select.md +0 -74
  497. package/src/directive/select/select.spec.js +0 -2566
  498. package/src/directive/select/select.test.js +0 -12
  499. package/src/directive/setter/setter.html +0 -19
  500. package/src/directive/setter/setter.js +0 -59
  501. package/src/directive/setter/setter.spec.js +0 -100
  502. package/src/directive/setter/setter.test.js +0 -12
  503. package/src/directive/show-hide/show-hide.html +0 -22
  504. package/src/directive/show-hide/show-hide.js +0 -65
  505. package/src/directive/show-hide/show-hide.md +0 -255
  506. package/src/directive/show-hide/show-hide.spec.js +0 -268
  507. package/src/directive/show-hide/show-hide.test.js +0 -12
  508. package/src/directive/style/style.html +0 -19
  509. package/src/directive/style/style.js +0 -27
  510. package/src/directive/style/style.md +0 -23
  511. package/src/directive/style/style.spec.js +0 -183
  512. package/src/directive/style/style.test.js +0 -12
  513. package/src/directive/switch/switch.html +0 -19
  514. package/src/directive/switch/switch.js +0 -133
  515. package/src/directive/switch/switch.md +0 -66
  516. package/src/directive/switch/switch.spec.js +0 -509
  517. package/src/directive/switch/switch.test.js +0 -12
  518. package/src/directive/transclude/transclude.js +0 -122
  519. package/src/directive/validators/validators.html +0 -22
  520. package/src/directive/validators/validators.js +0 -346
  521. package/src/directive/validators/validators.spec.js +0 -740
  522. package/src/directive/validators/validators.test.js +0 -12
  523. package/src/filters/filter.js +0 -213
  524. package/src/filters/filter.md +0 -69
  525. package/src/filters/filter.spec.js +0 -719
  526. package/src/filters/filters.html +0 -22
  527. package/src/filters/filters.js +0 -239
  528. package/src/filters/filters.spec.js +0 -36
  529. package/src/filters/filters.test.js +0 -12
  530. package/src/filters/json.md +0 -16
  531. package/src/filters/limit-to.js +0 -55
  532. package/src/filters/limit-to.md +0 -19
  533. package/src/filters/limit-to.spec.js +0 -252
  534. package/src/filters/order-by.js +0 -181
  535. package/src/filters/order-by.md +0 -83
  536. package/src/filters/order-by.spec.js +0 -883
  537. package/src/index.js +0 -6
  538. package/src/index.spec.js +0 -11
  539. package/src/injection-tokens.js +0 -78
  540. package/src/interface.ts +0 -421
  541. package/src/ng.js +0 -289
  542. package/src/ng.spec.js +0 -33
  543. package/src/router/common/trace.js +0 -240
  544. package/src/router/directives/component-example.html +0 -37
  545. package/src/router/directives/state-directives.html +0 -22
  546. package/src/router/directives/state-directives.js +0 -393
  547. package/src/router/directives/state-directives.md +0 -435
  548. package/src/router/directives/state-directives.spec.js +0 -1091
  549. package/src/router/directives/state-directives.test.js +0 -10
  550. package/src/router/directives/view-directive.js +0 -489
  551. package/src/router/directives/view-directive.spec.js +0 -1937
  552. package/src/router/directives/view-directive.test.js +0 -10
  553. package/src/router/directives/view-directives.html +0 -22
  554. package/src/router/glob/glob.html +0 -19
  555. package/src/router/glob/glob.js +0 -102
  556. package/src/router/glob/glob.spec.js +0 -108
  557. package/src/router/glob/glob.test.js +0 -12
  558. package/src/router/hooks/core-resolvables.js +0 -38
  559. package/src/router/hooks/ignored-transition.js +0 -25
  560. package/src/router/hooks/invalid-transition.js +0 -14
  561. package/src/router/hooks/lazy-load.js +0 -104
  562. package/src/router/hooks/on-enter-exit-retain.js +0 -55
  563. package/src/router/hooks/redirect-to.js +0 -38
  564. package/src/router/hooks/resolve.js +0 -57
  565. package/src/router/hooks/update-globals.js +0 -34
  566. package/src/router/hooks/url.js +0 -34
  567. package/src/router/hooks/views.js +0 -41
  568. package/src/router/params/interface.ts +0 -626
  569. package/src/router/params/param-factory.js +0 -23
  570. package/src/router/params/param-type.js +0 -133
  571. package/src/router/params/param-types.js +0 -153
  572. package/src/router/params/param.js +0 -243
  573. package/src/router/params/state-params.js +0 -36
  574. package/src/router/path/path-node.js +0 -78
  575. package/src/router/path/path-utils.js +0 -207
  576. package/src/router/resolve/interface.ts +0 -208
  577. package/src/router/resolve/resolvable.js +0 -123
  578. package/src/router/resolve/resolve-context.js +0 -190
  579. package/src/router/router-test-hashbang.html +0 -45
  580. package/src/router/router-test.html +0 -41
  581. package/src/router/router.html +0 -22
  582. package/src/router/router.js +0 -54
  583. package/src/router/router.test.js +0 -12
  584. package/src/router/services.spec.js +0 -52
  585. package/src/router/state/README.md +0 -21
  586. package/src/router/state/interface.ts +0 -1007
  587. package/src/router/state/state-builder.js +0 -376
  588. package/src/router/state/state-builder.spec.js +0 -86
  589. package/src/router/state/state-matcher.js +0 -64
  590. package/src/router/state/state-object.js +0 -118
  591. package/src/router/state/state-queue-manager.js +0 -95
  592. package/src/router/state/state-registry.js +0 -257
  593. package/src/router/state/state-service.js +0 -699
  594. package/src/router/state/state.html +0 -23
  595. package/src/router/state/state.spec.js +0 -1002
  596. package/src/router/state/state.test.js +0 -12
  597. package/src/router/state/target-state.js +0 -162
  598. package/src/router/state/views.js +0 -195
  599. package/src/router/state-filter.spec.js +0 -139
  600. package/src/router/state-filters.js +0 -46
  601. package/src/router/template-factory.html +0 -19
  602. package/src/router/template-factory.js +0 -249
  603. package/src/router/template-factory.spec.js +0 -155
  604. package/src/router/template-factory.test.js +0 -12
  605. package/src/router/transition/hook-builder.js +0 -133
  606. package/src/router/transition/hook-registry.js +0 -172
  607. package/src/router/transition/interface.js +0 -18
  608. package/src/router/transition/interface.ts +0 -922
  609. package/src/router/transition/reject-factory.js +0 -122
  610. package/src/router/transition/transition-event-type.js +0 -26
  611. package/src/router/transition/transition-hook.js +0 -199
  612. package/src/router/transition/transition-service.js +0 -302
  613. package/src/router/transition/transition.js +0 -652
  614. package/src/router/url/url-config.js +0 -155
  615. package/src/router/url/url-matcher.js +0 -532
  616. package/src/router/url/url-rule.js +0 -231
  617. package/src/router/url/url-rules.js +0 -350
  618. package/src/router/url/url-service.js +0 -446
  619. package/src/router/url/url-service.spec.js +0 -1288
  620. package/src/router/url/url.html +0 -19
  621. package/src/router/url/url.test.js +0 -12
  622. package/src/router/view/interface.ts +0 -51
  623. package/src/router/view/view.html +0 -19
  624. package/src/router/view/view.js +0 -274
  625. package/src/router/view/view.spec.js +0 -100
  626. package/src/router/view/view.test.js +0 -12
  627. package/src/router/view-hook.spec.js +0 -215
  628. package/src/router/view-scroll.js +0 -33
  629. package/src/router/view-scroll.spec.js +0 -72
  630. package/src/services/anchor-scroll.html +0 -76
  631. package/src/services/anchor-scroll.js +0 -147
  632. package/src/services/cookie-reader.js +0 -48
  633. package/src/services/exception/exception-handler.js +0 -75
  634. package/src/services/exception/interface.ts +0 -7
  635. package/src/services/http/http.html +0 -23
  636. package/src/services/http/http.js +0 -922
  637. package/src/services/http/http.md +0 -413
  638. package/src/services/http/http.spec.js +0 -3941
  639. package/src/services/http/http.test.js +0 -11
  640. package/src/services/http/interface.ts +0 -243
  641. package/src/services/http/template-request.spec.js +0 -220
  642. package/src/services/http-backend/http-backend.html +0 -22
  643. package/src/services/http-backend/http-backend.js +0 -158
  644. package/src/services/http-backend/http-backend.spec.js +0 -389
  645. package/src/services/http-backend/http-backend.test.js +0 -12
  646. package/src/services/location/interface.ts +0 -70
  647. package/src/services/location/location.html +0 -22
  648. package/src/services/location/location.js +0 -1006
  649. package/src/services/location/location.spec.js +0 -3792
  650. package/src/services/location/location.test.js +0 -12
  651. package/src/services/log/interface.ts +0 -39
  652. package/src/services/log/log.html +0 -19
  653. package/src/services/log/log.js +0 -74
  654. package/src/services/log/log.spec.js +0 -64
  655. package/src/services/log/log.test.js +0 -12
  656. package/src/services/pubsub/pubsub.html +0 -19
  657. package/src/services/pubsub/pubsub.js +0 -349
  658. package/src/services/pubsub/pubsub.spec.js +0 -400
  659. package/src/services/pubsub/pubsub.test.js +0 -12
  660. package/src/services/sce/sce.html +0 -19
  661. package/src/services/sce/sce.js +0 -847
  662. package/src/services/sce/sce.md +0 -300
  663. package/src/services/sce/sce.spec.js +0 -617
  664. package/src/services/sce/sce.test.js +0 -12
  665. package/src/services/template-cache/interface.ts +0 -10
  666. package/src/services/template-cache/template-cache.html +0 -22
  667. package/src/services/template-cache/template-cache.js +0 -15
  668. package/src/services/template-cache/template-cache.spec.js +0 -134
  669. package/src/services/template-cache/template-cache.test.js +0 -12
  670. package/src/services/template-request.js +0 -142
  671. package/src/shared/cache.js +0 -7
  672. package/src/shared/common.js +0 -438
  673. package/src/shared/common.spec.js +0 -294
  674. package/src/shared/constants.js +0 -21
  675. package/src/shared/dom.js +0 -716
  676. package/src/shared/hof.js +0 -151
  677. package/src/shared/hof.spec.js +0 -60
  678. package/src/shared/interface.ts +0 -21
  679. package/src/shared/min-err.spec.js +0 -178
  680. package/src/shared/noderef.js +0 -225
  681. package/src/shared/predicates.js +0 -34
  682. package/src/shared/queue.js +0 -105
  683. package/src/shared/queue.spec.js +0 -80
  684. package/src/shared/shared.html +0 -24
  685. package/src/shared/shared.test.js +0 -12
  686. package/src/shared/strings.js +0 -142
  687. package/src/shared/strings.spec.js +0 -40
  688. package/src/shared/test-utils.js +0 -47
  689. package/src/shared/url-utils/interface.ts +0 -54
  690. package/src/shared/url-utils/url-utils.html +0 -22
  691. package/src/shared/url-utils/url-utils.js +0 -122
  692. package/src/shared/url-utils/url-utils.spec.js +0 -148
  693. package/src/shared/url-utils/url-utils.test.js +0 -12
  694. package/src/shared/utils.js +0 -1255
  695. package/src/shared/utils.spec.js +0 -178
  696. package/src/src.html +0 -21
  697. package/src/src.test.js +0 -10
  698. package/tsconfig.json +0 -19
  699. package/tsconfig.types.json +0 -14
  700. package/typedoc.json +0 -8
  701. package/utils/express.js +0 -203
  702. package/utils/version.cjs +0 -23
  703. package/vite.config.js +0 -14
@@ -1,3792 +0,0 @@
1
- import {
2
- decodePath,
3
- encodePath,
4
- normalizePath,
5
- Location,
6
- LocationProvider,
7
- parseAppUrl,
8
- stripBaseUrl,
9
- stripHash,
10
- stripFile,
11
- serverBase,
12
- urlsEqual,
13
- } from "./location.js";
14
- import { Angular } from "../../angular.js";
15
- import { createInjector } from "../../core/di/injector.js";
16
-
17
- describe("$location", () => {
18
- let module;
19
- beforeEach(() => {
20
- window.angular = new Angular();
21
- module = window.angular.module("test1", ["ng"]);
22
- });
23
-
24
- // function initService(options) {
25
- // module.config(($provide, $locationProvider) => {
26
- // $locationProvider.setHtml5Mode(options.html5Mode);
27
- // $locationProvider.hashPrefix(options.hashPrefix);
28
- // $provide.value("$sniffer", { history: options.supportHistory });
29
- // });
30
- // }
31
-
32
- describe("defaults", () => {
33
- it('should have hashPrefix of "!"', () => {
34
- let provider = new LocationProvider();
35
- expect(provider.hashPrefixConf).toBe("!");
36
- });
37
-
38
- it("should default to html5 mode with no base and rewrite links", () => {
39
- let provider = new LocationProvider();
40
- expect(provider.html5ModeConf.enabled).toBeTrue();
41
- expect(provider.html5ModeConf.requireBase).toBeFalse();
42
- expect(provider.html5ModeConf.rewriteLinks).toBeTrue();
43
- });
44
- });
45
-
46
- describe("File Protocol", () => {
47
- let urlParsingNodePlaceholder;
48
- let urlParsingNode;
49
-
50
- beforeEach(() => {
51
- urlParsingNodePlaceholder = urlParsingNode;
52
-
53
- // temporarily overriding the DOM element
54
- // with output from IE, if not in IE
55
- urlParsingNode = {
56
- hash: "#/C:/",
57
- host: "",
58
- hostname: "",
59
- href: "file:///C:/base#!/C:/foo",
60
- pathname: "/C:/foo",
61
- port: "",
62
- protocol: "file:",
63
- search: "",
64
- setAttribute: () => {},
65
- };
66
- });
67
-
68
- afterEach(() => {
69
- urlParsingNode = urlParsingNodePlaceholder;
70
- });
71
-
72
- it("should not include the drive name in path() on WIN", () => {
73
- // See issue #4680 for details
74
- const locationUrl = new Location("file:///base", "file:///", false, "#!");
75
- locationUrl.parse("file:///base#!/foo?a=b&c#hash");
76
-
77
- expect(locationUrl.getPath()).toBe("/foo");
78
- });
79
-
80
- it("should include the drive name if it was provided in the input url", () => {
81
- const locationUrl = new Location("file:///base", "file:///", false, "#!");
82
- locationUrl.parse("file:///base#!/C:/foo?a=b&c#hash");
83
-
84
- expect(locationUrl.getPath()).toBe("/C:/foo");
85
- });
86
- });
87
-
88
- describe("NewUrl", () => {
89
- function createLocationHtml5Url() {
90
- const locationUrl = new Location(
91
- "http://www.domain.com:9877/",
92
- "http://www.domain.com:9877/",
93
- true,
94
- );
95
- locationUrl.parse(
96
- "http://www.domain.com:9877/path/b?search=a&b=c&d#hash",
97
- );
98
- return locationUrl;
99
- }
100
-
101
- it("should provide common getters", () => {
102
- const locationUrl = createLocationHtml5Url();
103
- expect(locationUrl.absUrl).toBe(
104
- "http://www.domain.com:9877/path/b?search=a&b=c&d#hash",
105
- );
106
- expect(locationUrl.getPath()).toBe("/path/b");
107
- expect(locationUrl.getSearch()).toEqual({ search: "a", b: "c", d: true });
108
- expect(locationUrl.getHash()).toBe("hash");
109
- expect(locationUrl.getUrl()).toBe("/path/b?search=a&b=c&d#hash");
110
- });
111
-
112
- it("path() should change path", () => {
113
- const locationUrl = createLocationHtml5Url();
114
- locationUrl.setPath("/new/path");
115
- expect(locationUrl.getPath()).toBe("/new/path");
116
- expect(locationUrl.absUrl).toBe(
117
- "http://www.domain.com:9877/new/path?search=a&b=c&d#hash",
118
- );
119
- });
120
-
121
- it("path() should not break on numeric values", () => {
122
- const locationUrl = createLocationHtml5Url();
123
- locationUrl.setPath(1);
124
- expect(locationUrl.getPath()).toBe("/1");
125
- expect(locationUrl.absUrl).toBe(
126
- "http://www.domain.com:9877/1?search=a&b=c&d#hash",
127
- );
128
- });
129
-
130
- it("path() should allow using 0 as path", () => {
131
- const locationUrl = createLocationHtml5Url();
132
- locationUrl.setPath(0);
133
- expect(locationUrl.getPath()).toBe("/0");
134
- expect(locationUrl.absUrl).toBe(
135
- "http://www.domain.com:9877/0?search=a&b=c&d#hash",
136
- );
137
- });
138
-
139
- it("path() should set to empty path on null value", () => {
140
- const locationUrl = createLocationHtml5Url();
141
- locationUrl.setPath("/foo");
142
- expect(locationUrl.getPath()).toBe("/foo");
143
- locationUrl.setPath(null);
144
- expect(locationUrl.getPath()).toBe("/");
145
- });
146
-
147
- it("search() should accept string", () => {
148
- const locationUrl = createLocationHtml5Url();
149
- locationUrl.setSearch("x=y&c");
150
- expect(locationUrl.getSearch()).toEqual({ x: "y", c: true });
151
- expect(locationUrl.absUrl).toBe(
152
- "http://www.domain.com:9877/path/b?x=y&c#hash",
153
- );
154
- });
155
-
156
- it("search() should accept object", () => {
157
- const locationUrl = createLocationHtml5Url();
158
- locationUrl.setSearch({ one: 1, two: true });
159
- expect(locationUrl.getSearch()).toEqual({ one: 1, two: true });
160
- expect(locationUrl.absUrl).toBe(
161
- "http://www.domain.com:9877/path/b?one=1&two#hash",
162
- );
163
- });
164
-
165
- it("search() should copy object", () => {
166
- const locationUrl = createLocationHtml5Url();
167
- const obj = { one: 1, two: true, three: null };
168
- locationUrl.setSearch(obj);
169
- expect(obj).toEqual({ one: 1, two: true, three: null });
170
- obj.one = "changed";
171
- expect(locationUrl.getSearch()).toEqual({ one: 1, two: true });
172
- expect(locationUrl.absUrl).toBe(
173
- "http://www.domain.com:9877/path/b?one=1&two#hash",
174
- );
175
- });
176
-
177
- it("search() should change single parameter", () => {
178
- const locationUrl = createLocationHtml5Url();
179
- locationUrl.setSearch({ id: "old", preserved: true });
180
- locationUrl.setSearch("id", "new");
181
-
182
- expect(locationUrl.getSearch()).toEqual({ id: "new", preserved: true });
183
- });
184
-
185
- it("search() should remove single parameter", () => {
186
- const locationUrl = createLocationHtml5Url();
187
- locationUrl.setSearch({ id: "old", preserved: true });
188
- locationUrl.setSearch("id", null);
189
-
190
- expect(locationUrl.getSearch()).toEqual({ preserved: true });
191
- });
192
-
193
- it("search() should remove multiple parameters", () => {
194
- const locationUrl = createLocationHtml5Url();
195
- locationUrl.setSearch({ one: 1, two: true });
196
- expect(locationUrl.getSearch()).toEqual({ one: 1, two: true });
197
- locationUrl.setSearch({ one: null, two: null });
198
- expect(locationUrl.getSearch()).toEqual({});
199
- expect(locationUrl.absUrl).toBe("http://www.domain.com:9877/path/b#hash");
200
- });
201
-
202
- it("search() should accept numeric keys", () => {
203
- const locationUrl = createLocationHtml5Url();
204
- locationUrl.setSearch({ 1: "one", 2: "two" });
205
- expect(locationUrl.getSearch()).toEqual({ 1: "one", 2: "two" });
206
- expect(locationUrl.absUrl).toBe(
207
- "http://www.domain.com:9877/path/b?1=one&2=two#hash",
208
- );
209
- });
210
-
211
- it("search() should handle multiple value", () => {
212
- const locationUrl = createLocationHtml5Url();
213
- locationUrl.setSearch("a&b");
214
- expect(locationUrl.getSearch()).toEqual({ a: true, b: true });
215
-
216
- locationUrl.setSearch("a", null);
217
-
218
- expect(locationUrl.getSearch()).toEqual({ b: true });
219
-
220
- locationUrl.setSearch("b", undefined);
221
- expect(locationUrl.getSearch()).toEqual({});
222
- });
223
-
224
- it("search() should handle single value", () => {
225
- const locationUrl = createLocationHtml5Url();
226
- locationUrl.setSearch("ignore");
227
- expect(locationUrl.getSearch()).toEqual({ ignore: true });
228
- locationUrl.setSearch(1);
229
- expect(locationUrl.getSearch()).toEqual({ 1: true });
230
- });
231
-
232
- it("search() should throw error an incorrect argument", () => {
233
- const locationUrl = createLocationHtml5Url();
234
- expect(() => {
235
- locationUrl.setSearch(null);
236
- }).toThrowError(/isrcharg/);
237
- expect(() => {
238
- locationUrl.setSearch(undefined);
239
- }).toThrowError(/isrcharg/);
240
- });
241
-
242
- it("hash() should change hash fragment", () => {
243
- const locationUrl = createLocationHtml5Url();
244
- locationUrl.setHash("new-hash");
245
- expect(locationUrl.getHash()).toBe("new-hash");
246
- expect(locationUrl.absUrl).toBe(
247
- "http://www.domain.com:9877/path/b?search=a&b=c&d#new-hash",
248
- );
249
- });
250
-
251
- it("hash() should accept numeric parameter", () => {
252
- const locationUrl = createLocationHtml5Url();
253
- locationUrl.setHash(5);
254
- expect(locationUrl.getHash()).toBe("5");
255
- expect(locationUrl.absUrl).toBe(
256
- "http://www.domain.com:9877/path/b?search=a&b=c&d#5",
257
- );
258
- });
259
-
260
- it("hash() should allow using 0", () => {
261
- const locationUrl = createLocationHtml5Url();
262
- locationUrl.setHash(0);
263
- expect(locationUrl.getHash()).toBe("0");
264
- expect(locationUrl.absUrl).toBe(
265
- "http://www.domain.com:9877/path/b?search=a&b=c&d#0",
266
- );
267
- });
268
-
269
- it("hash() should accept null parameter", () => {
270
- const locationUrl = createLocationHtml5Url();
271
- locationUrl.setHash(null);
272
- expect(locationUrl.getHash()).toBe("");
273
- expect(locationUrl.absUrl).toBe(
274
- "http://www.domain.com:9877/path/b?search=a&b=c&d",
275
- );
276
- });
277
-
278
- it("url getter/setter should change the path, search and hash", () => {
279
- const locationUrl = createLocationHtml5Url();
280
- locationUrl.setUrl("/some/path?a=b&c=d#hhh");
281
- expect(locationUrl.getUrl()).toBe("/some/path?a=b&c=d#hhh");
282
- expect(locationUrl.absUrl).toBe(
283
- "http://www.domain.com:9877/some/path?a=b&c=d#hhh",
284
- );
285
- expect(locationUrl.getPath()).toBe("/some/path");
286
- expect(locationUrl.getSearch()).toEqual({ a: "b", c: "d" });
287
- expect(locationUrl.getHash()).toBe("hhh");
288
- });
289
-
290
- it("url getter/setter should change only hash when no search and path specified", () => {
291
- const locationUrl = createLocationHtml5Url();
292
- locationUrl.setUrl("#some-hash");
293
-
294
- expect(locationUrl.getHash()).toBe("some-hash");
295
- expect(locationUrl.getUrl()).toBe("/path/b?search=a&b=c&d#some-hash");
296
- expect(locationUrl.absUrl).toBe(
297
- "http://www.domain.com:9877/path/b?search=a&b=c&d#some-hash",
298
- );
299
- });
300
-
301
- it("setUrl() should change only search and hash when no path specified", () => {
302
- const locationUrl = createLocationHtml5Url();
303
- locationUrl.setUrl("?a=b");
304
-
305
- expect(locationUrl.getSearch()).toEqual({ a: "b" });
306
- expect(locationUrl.getHash()).toBe("");
307
- expect(locationUrl.getPath()).toBe("/path/b");
308
- });
309
-
310
- it("setUrl() should reset search and hash when only path specified", () => {
311
- const locationUrl = createLocationHtml5Url();
312
- locationUrl.setUrl("/new/path");
313
-
314
- expect(locationUrl.getPath()).toBe("/new/path");
315
- expect(locationUrl.getSearch()).toEqual({});
316
- expect(locationUrl.getHash()).toBe("");
317
- });
318
-
319
- it("setUrl() should change path when empty string specified", () => {
320
- const locationUrl = createLocationHtml5Url();
321
- locationUrl.setUrl("");
322
-
323
- expect(locationUrl.getPath()).toBe("/");
324
- expect(locationUrl.getSearch()).toEqual({});
325
- expect(locationUrl.getHash()).toBe("");
326
- });
327
-
328
- it("should parse new url", () => {
329
- let locationUrl = new Location("http://host.com/", "http://host.com/");
330
- locationUrl.parse("http://host.com/base");
331
- expect(locationUrl.getPath()).toBe("/base");
332
-
333
- locationUrl = new Location("http://host.com/", "http://host.com/", true);
334
- locationUrl.parse("http://host.com/base#");
335
- expect(locationUrl.getPath()).toBe("/base");
336
- });
337
-
338
- it("should prefix path with forward-slash", () => {
339
- const locationUrl = new Location(
340
- "http://server/",
341
- "http://server/",
342
- true,
343
- );
344
- locationUrl.setPath("b");
345
-
346
- expect(locationUrl.getPath()).toBe("/b");
347
- expect(locationUrl.absUrl).toBe("http://server/b");
348
- });
349
-
350
- it("should set path to forward-slash when empty", () => {
351
- const locationUrl = new Location(
352
- "http://server/",
353
- "http://server/",
354
- true,
355
- );
356
- locationUrl.parse("http://server/");
357
- expect(locationUrl.getPath()).toBe("/");
358
- expect(locationUrl.absUrl).toBe("http://server/");
359
- });
360
-
361
- it("setters should return Url object to allow chaining", () => {
362
- const locationUrl = createLocationHtml5Url();
363
- expect(locationUrl.setPath("/any")).toBe(locationUrl);
364
- expect(locationUrl.setSearch("")).toBe(locationUrl);
365
- expect(locationUrl.setHash("aaa")).toBe(locationUrl);
366
- expect(locationUrl.setUrl("/some")).toBe(locationUrl);
367
- });
368
-
369
- it("should not preserve old properties when parsing new url", () => {
370
- const locationUrl = createLocationHtml5Url();
371
- locationUrl.parse("http://www.domain.com:9877/a");
372
-
373
- expect(locationUrl.getPath()).toBe("/a");
374
- expect(locationUrl.getSearch()).toEqual({});
375
- expect(locationUrl.getHash()).toBe("");
376
- expect(locationUrl.absUrl).toBe("http://www.domain.com:9877/a");
377
- });
378
-
379
- // it("should not rewrite when hashbang url is not given", () => {
380
- // initService({ html5Mode: true, hashPrefix: "!", supportHistory: true });
381
- // initBrowser({ url: "http://domain.com/base/a/b", basePath: "/base" });
382
- // expect($browser.getUrl()).toBe("http://domain.com/base/a/b");
383
- // });
384
-
385
- it("should prepend path with basePath", () => {
386
- const locationUrl = new Location(
387
- "http://server/base/",
388
- "http://server/base/",
389
- true,
390
- );
391
- locationUrl.parse("http://server/base/abc?a");
392
- expect(locationUrl.getPath()).toBe("/abc");
393
- expect(locationUrl.getSearch()).toEqual({ a: true });
394
-
395
- locationUrl.setPath("/new/path");
396
- expect(locationUrl.absUrl).toBe("http://server/base/new/path?a");
397
- });
398
-
399
- it("should throw error when invalid server url given", () => {
400
- const locationUrl = new Location(
401
- "http://server.org/base/abc",
402
- "http://server.org/base/",
403
- true,
404
- );
405
-
406
- expect(() => {
407
- locationUrl.parse("http://other.server.org/path#/path");
408
- }).toThrowError(/ipthprfx/);
409
- });
410
-
411
- it("should throw error when invalid base url given", () => {
412
- const locationUrl = new Location(
413
- "http://server.org/base/abc",
414
- "http://server.org/base/",
415
- true,
416
- );
417
-
418
- expect(() => {
419
- locationUrl.parse("http://server.org/path#/path");
420
- }).toThrowError(/ipthprfx/);
421
- });
422
-
423
- describe("state", () => {
424
- it("should set $$state and return itself", () => {
425
- const locationUrl = createLocationHtml5Url();
426
- expect(locationUrl.$$state).toEqual(undefined);
427
-
428
- const returned = locationUrl.setState({ a: 2 });
429
- expect(locationUrl.$$state).toEqual({ a: 2 });
430
- expect(returned).toBe(locationUrl);
431
- });
432
-
433
- it("should set state", () => {
434
- const locationUrl = createLocationHtml5Url();
435
- locationUrl.setState({ a: 2 });
436
- expect(locationUrl.getState()).toEqual({ a: 2 });
437
- });
438
-
439
- it("should allow to set both URL and state", () => {
440
- const locationUrl = createLocationHtml5Url();
441
- locationUrl.setUrl("/foo").setState({ a: 2 });
442
- expect(locationUrl.getUrl()).toEqual("/foo");
443
- expect(locationUrl.getState()).toEqual({ a: 2 });
444
- });
445
-
446
- it("should allow to mix state and various URL functions", () => {
447
- const locationUrl = createLocationHtml5Url();
448
- locationUrl
449
- .setPath("/foo")
450
- .setHash("abcd")
451
- .setState({ a: 2 })
452
- .setSearch("bar", "baz");
453
-
454
- expect(locationUrl.getPath()).toEqual("/foo");
455
- expect(locationUrl.getState()).toEqual({ a: 2 });
456
- expect(locationUrl.getSearch() && locationUrl.getSearch().bar).toBe(
457
- "baz",
458
- );
459
- expect(locationUrl.getHash()).toEqual("abcd");
460
- });
461
- });
462
-
463
- describe("encoding", () => {
464
- it("should encode special characters", () => {
465
- const locationUrl = createLocationHtml5Url();
466
- locationUrl.setPath("/a <>#");
467
- locationUrl.setSearch({ "i j": "<>#" });
468
- locationUrl.setHash("<>#");
469
-
470
- expect(locationUrl.getPath()).toBe("/a <>#");
471
- expect(locationUrl.getSearch()).toEqual({ "i j": "<>#" });
472
- expect(locationUrl.getHash()).toBe("<>#");
473
- expect(locationUrl.absUrl).toBe(
474
- "http://www.domain.com:9877/a%20%3C%3E%23?i%20j=%3C%3E%23#%3C%3E%23",
475
- );
476
- });
477
-
478
- it("should not encode !$:@", () => {
479
- const locationUrl = createLocationHtml5Url();
480
- locationUrl.setPath("/!$:@");
481
- locationUrl.setSearch("");
482
- locationUrl.setHash("!$:@");
483
-
484
- expect(locationUrl.absUrl).toBe("http://www.domain.com:9877/!$:@#!$:@");
485
- });
486
-
487
- it("should decode special characters", () => {
488
- const locationUrl = new Location(
489
- "http://host.com/",
490
- "http://host.com/",
491
- true,
492
- );
493
- locationUrl.parse(
494
- "http://host.com/a%20%3C%3E%23?i%20j=%3C%3E%23#x%20%3C%3E%23",
495
- );
496
- expect(locationUrl.getPath()).toBe("/a <>#");
497
- expect(locationUrl.getSearch()).toEqual({ "i j": "<>#" });
498
- expect(locationUrl.getHash()).toBe("x <>#");
499
- });
500
-
501
- it("should not decode encoded forward slashes in the path", () => {
502
- const locationUrl = new Location(
503
- "http://host.com/base/",
504
- "http://host.com/base/",
505
- true,
506
- );
507
- locationUrl.parse("http://host.com/base/a/ng2;path=%2Fsome%2Fpath");
508
- expect(locationUrl.getPath()).toBe("/a/ng2;path=%2Fsome%2Fpath");
509
- expect(locationUrl.getSearch()).toEqual({});
510
- expect(locationUrl.getHash()).toBe("");
511
- expect(locationUrl.getUrl()).toBe("/a/ng2;path=%2Fsome%2Fpath");
512
- expect(locationUrl.absUrl).toBe(
513
- "http://host.com/base/a/ng2;path=%2Fsome%2Fpath",
514
- );
515
- });
516
-
517
- it("should decode pluses as spaces in urls", () => {
518
- const locationUrl = new Location(
519
- "http://host.com/",
520
- "http://host.com/",
521
- true,
522
- );
523
- locationUrl.parse("http://host.com/?a+b=c+d");
524
- expect(locationUrl.getSearch()).toEqual({ "a b": "c d" });
525
- });
526
-
527
- it("should retain pluses when setting search queries", () => {
528
- const locationUrl = createLocationHtml5Url();
529
- locationUrl.setSearch({ "a+b": "c+d" });
530
- expect(locationUrl.getSearch()).toEqual({ "a+b": "c+d" });
531
- });
532
-
533
- fit("should not drop encodings on already enconded params", () => {
534
- const locationUrl = createLocationHtml5Url();
535
- locationUrl.setUrl("/path/foo%2Fbar/baz%2Fqux");
536
- expect(locationUrl.getPath()).toEqual("/path/foo%2Fbar/baz%2Fqux");
537
- });
538
- });
539
- });
540
-
541
- describe("HashbangUrl", () => {
542
- function createHashbangUrl() {
543
- const locationUrl = new Location(
544
- "http://www.server.org:1234/base",
545
- "http://www.server.org:1234/",
546
- false,
547
- "#!",
548
- );
549
- locationUrl.parse("http://www.server.org:1234/base#!/path?a=b&c#hash");
550
- return locationUrl;
551
- }
552
-
553
- it("should parse hashbang url into path and search", () => {
554
- const locationUrl = createHashbangUrl();
555
- expect(locationUrl.getPath()).toBe("/path");
556
- expect(locationUrl.getSearch()).toEqual({ a: "b", c: true });
557
- expect(locationUrl.getHash()).toBe("hash");
558
- });
559
-
560
- it("absUrl should return hashbang url", () => {
561
- const locationUrl = createHashbangUrl();
562
- expect(locationUrl.absUrl).toBe(
563
- "http://www.server.org:1234/base#!/path?a=b&c#hash",
564
- );
565
-
566
- locationUrl.setPath("/new/path");
567
- locationUrl.setSearch({ one: 1 });
568
- locationUrl.setHash("hhh");
569
- expect(locationUrl.absUrl).toBe(
570
- "http://www.server.org:1234/base#!/new/path?one=1#hhh",
571
- );
572
- });
573
-
574
- it("should preserve query params in base", () => {
575
- const locationUrl = new Location(
576
- "http://www.server.org:1234/base?base=param",
577
- "http://www.server.org:1234/",
578
- false,
579
- "#",
580
- );
581
- locationUrl.parse(
582
- "http://www.server.org:1234/base?base=param#/path?a=b&c#hash",
583
- );
584
- expect(locationUrl.absUrl).toBe(
585
- "http://www.server.org:1234/base?base=param#/path?a=b&c#hash",
586
- );
587
-
588
- locationUrl.setPath("/new/path");
589
- locationUrl.setSearch({ one: 1 });
590
- locationUrl.setHash("hhh");
591
- expect(locationUrl.absUrl).toBe(
592
- "http://www.server.org:1234/base?base=param#/new/path?one=1#hhh",
593
- );
594
- });
595
-
596
- it("should prefix path with forward-slash", () => {
597
- const locationUrl = new Location(
598
- "http://host.com/base",
599
- "http://host.com/",
600
- false,
601
- "#",
602
- );
603
- locationUrl.parse("http://host.com/base#path");
604
- expect(locationUrl.getPath()).toBe("/path");
605
- expect(locationUrl.absUrl).toBe("http://host.com/base#/path");
606
-
607
- locationUrl.setPath("wrong");
608
- expect(locationUrl.getPath()).toBe("/wrong");
609
- expect(locationUrl.absUrl).toBe("http://host.com/base#/wrong");
610
- });
611
-
612
- it("should set path to forward-slash when empty", () => {
613
- const locationUrl = new Location(
614
- "http://server/base",
615
- "http://server/",
616
- false,
617
- "#!",
618
- );
619
- locationUrl.parse("http://server/base");
620
- locationUrl.setPath("aaa");
621
-
622
- expect(locationUrl.getPath()).toBe("/aaa");
623
- expect(locationUrl.absUrl).toBe("http://server/base#!/aaa");
624
- });
625
-
626
- it("should not preserve old properties when parsing new url", () => {
627
- const locationUrl = createHashbangUrl();
628
- locationUrl.parse("http://www.server.org:1234/base#!/");
629
-
630
- expect(locationUrl.getPath()).toBe("/");
631
- expect(locationUrl.getSearch()).toEqual({});
632
- expect(locationUrl.getHash()).toBe("");
633
- expect(locationUrl.absUrl).toBe("http://www.server.org:1234/base#!/");
634
- });
635
-
636
- it("should insert default hashbang if a hash is given with no hashbang prefix", () => {
637
- const locationUrl = createHashbangUrl();
638
-
639
- locationUrl.parse("http://www.server.org:1234/base#/path");
640
- expect(locationUrl.absUrl).toBe(
641
- "http://www.server.org:1234/base#!#%2Fpath",
642
- );
643
- expect(locationUrl.getHash()).toBe("/path");
644
- expect(locationUrl.getPath()).toBe("");
645
-
646
- locationUrl.parse("http://www.server.org:1234/base#");
647
- expect(locationUrl.absUrl).toBe("http://www.server.org:1234/base");
648
- expect(locationUrl.getHash()).toBe("");
649
- expect(locationUrl.getPath()).toBe("");
650
- });
651
-
652
- it("should ignore extra path segments if no hashbang is given", () => {
653
- const locationUrl = createHashbangUrl();
654
- locationUrl.parse("http://www.server.org:1234/base/extra/path");
655
- expect(locationUrl.absUrl).toBe("http://www.server.org:1234/base");
656
- expect(locationUrl.getPath()).toBe("");
657
- expect(locationUrl.getHash()).toBe("");
658
- });
659
-
660
- describe("encoding", () => {
661
- it("should encode special characters", () => {
662
- const locationUrl = createHashbangUrl();
663
- locationUrl.setPath("/a <>#");
664
- locationUrl.setSearch({ "i j": "<>#" });
665
- locationUrl.setHash("<>#");
666
-
667
- expect(locationUrl.getPath()).toBe("/a <>#");
668
- expect(locationUrl.getSearch()).toEqual({ "i j": "<>#" });
669
- expect(locationUrl.getHash()).toBe("<>#");
670
- expect(locationUrl.absUrl).toBe(
671
- "http://www.server.org:1234/base#!/a%20%3C%3E%23?i%20j=%3C%3E%23#%3C%3E%23",
672
- );
673
- });
674
-
675
- it("should not encode !$:@", () => {
676
- const locationUrl = createHashbangUrl();
677
- locationUrl.setPath("/!$:@");
678
- locationUrl.setSearch("");
679
- locationUrl.setHash("!$:@");
680
-
681
- expect(locationUrl.absUrl).toBe(
682
- "http://www.server.org:1234/base#!/!$:@#!$:@",
683
- );
684
- });
685
-
686
- it("should decode special characters", () => {
687
- const locationUrl = new Location(
688
- "http://host.com/a",
689
- "http://host.com/",
690
- false,
691
- "#",
692
- );
693
- locationUrl.parse(
694
- "http://host.com/a#/%20%3C%3E%23?i%20j=%3C%3E%23#x%20%3C%3E%23",
695
- );
696
- expect(locationUrl.getPath()).toBe("/ <>#");
697
- expect(locationUrl.getSearch()).toEqual({ "i j": "<>#" });
698
- expect(locationUrl.getHash()).toBe("x <>#");
699
- });
700
-
701
- it("should return decoded characters for search specified in URL", () => {
702
- const locationUrl = new Location(
703
- "http://host.com/",
704
- "http://host.com/",
705
- true,
706
- );
707
- locationUrl.parse("http://host.com/?q=1%2F2%203");
708
- expect(locationUrl.getSearch()).toEqual({ q: "1/2 3" });
709
- });
710
-
711
- it("should return decoded characters for search specified with setter", () => {
712
- const locationUrl = new Location(
713
- "http://host.com/",
714
- "http://host.com/",
715
- true,
716
- );
717
- locationUrl.parse("http://host.com/");
718
- locationUrl.setSearch("q", "1/2 3");
719
- expect(locationUrl.getSearch()).toEqual({ q: "1/2 3" });
720
- });
721
-
722
- it("should return an array for duplicate params", () => {
723
- const locationUrl = new Location(
724
- "http://host.com",
725
- "http://host.com",
726
- true,
727
- );
728
- locationUrl.parse("http://host.com");
729
- locationUrl.setSearch("q", ["1/2 3", "4/5 6"]);
730
- expect(locationUrl.getSearch()).toEqual({ q: ["1/2 3", "4/5 6"] });
731
- });
732
-
733
- it("should encode an array correctly from search and add to url", () => {
734
- const locationUrl = new Location(
735
- "http://host.com",
736
- "http://host.com",
737
- true,
738
- );
739
- locationUrl.parse("http://host.com");
740
- locationUrl.setSearch({ q: ["1/2 3", "4/5 6"] });
741
- expect(locationUrl.absUrl).toEqual(
742
- "http://host.com?q=1%2F2%203&q=4%2F5%206",
743
- );
744
- });
745
-
746
- it("should rewrite params when specifying a single param in search", () => {
747
- const locationUrl = new Location(
748
- "http://host.com",
749
- "http://host.com",
750
- true,
751
- );
752
- locationUrl.parse("http://host.com");
753
- locationUrl.setSearch({ q: "1/2 3" });
754
- expect(locationUrl.absUrl).toEqual("http://host.com?q=1%2F2%203");
755
- locationUrl.setSearch({ q: "4/5 6" });
756
- expect(locationUrl.absUrl).toEqual("http://host.com?q=4%2F5%206");
757
- });
758
-
759
- it("url getter/setter should decode non-component special characters in hashbang mode", () => {
760
- const locationUrl = new Location(
761
- "http://host.com",
762
- "http://host.com",
763
- false,
764
- );
765
- locationUrl.parse("http://host.com");
766
- locationUrl.setUrl("/foo%3Abar");
767
- expect(locationUrl.getPath()).toEqual("/foo:bar");
768
- });
769
-
770
- it("url getter/setter should decode non-component special characters in html5 mode", () => {
771
- const locationUrl = new Location(
772
- "http://host.com",
773
- "http://host.com",
774
- true,
775
- );
776
- locationUrl.parse("http://host.com");
777
- locationUrl.setUrl("/foo%3Abar");
778
- expect(locationUrl.getPath()).toEqual("/foo:bar");
779
- });
780
- });
781
- });
782
-
783
- describe("encodePath", () => {
784
- it("should encode each segment but preserve slashes", () => {
785
- const input = "user profile/images/pic 1.jpg";
786
- const result = encodePath(input);
787
- expect(result).toBe("user%20profile/images/pic%201.jpg");
788
- });
789
-
790
- it("should re-encode previously encoded forward slashes as literal slashes", () => {
791
- const input = "folder1%2Fsub/folder2";
792
- const result = encodePath(input);
793
- expect(result).toBe("folder1%2Fsub/folder2");
794
- });
795
-
796
- it("should handle special characters properly", () => {
797
- const input = "a$bc/def@gh";
798
- const result = encodePath(input);
799
- expect(result).toBe("a$bc/def@gh");
800
- });
801
-
802
- it("should return empty string for empty path", () => {
803
- const input = "";
804
- const result = encodePath(input);
805
- expect(result).toBe("");
806
- });
807
-
808
- it("should handle single segment", () => {
809
- const input = "hello world";
810
- const result = encodePath(input);
811
- expect(result).toBe("hello%20world");
812
- });
813
-
814
- it("should not double encode already encoded segments except slashes", () => {
815
- const input = "one%20two/three%2Ffour";
816
- const result = encodePath(input);
817
- expect(result).toBe("one%20two/three%2Ffour");
818
- });
819
-
820
- it("should not double encode already encoded segments", () => {
821
- const input = "double%20encoded";
822
- const result = encodePath(input);
823
- expect(result).toBe("double%20encoded");
824
- });
825
-
826
- it("should preserve double encoded segments as-is (single decode only)", () => {
827
- const input = "double%2520encoded";
828
- const result = encodePath(input);
829
- expect(result).toBe("double%2520encoded"); // double % stays double encoded
830
- });
831
-
832
- it("should preserve leading and trailing slashes", () => {
833
- const input = "/a b/c d/";
834
- const result = encodePath(input);
835
- expect(result).toBe("/a%20b/c%20d/");
836
- });
837
-
838
- it("should preserve multiple consecutive slashes as empty segments", () => {
839
- const input = "foo//bar///baz";
840
- const result = encodePath(input);
841
- expect(result).toBe("foo//bar///baz");
842
- });
843
-
844
- it("should not encode RFC 3986 reserved characters in segments", () => {
845
- const input = "key=value/param+test";
846
- const result = encodePath(input);
847
- expect(result).toBe("key=value/param+test");
848
- });
849
-
850
- it("should encode unicode characters properly", () => {
851
- const input = "café/naïve";
852
- const result = encodePath(input);
853
- expect(result).toBe("caf%C3%A9/na%C3%AFve");
854
- });
855
-
856
- it("should handle input with only slashes", () => {
857
- const input = "///";
858
- const result = encodePath(input);
859
- expect(result).toBe("///");
860
- });
861
-
862
- it("should treat encoded slashes as literal and decoded slashes as separators", () => {
863
- const input = "part1%2Fsub/part2";
864
- const result = encodePath(input);
865
- expect(result).toBe("part1%2Fsub/part2");
866
- });
867
- });
868
-
869
- describe("decodePath", () => {
870
- it("should decode percent-encoded segments", () => {
871
- const input = "hello%20world/abc%40def";
872
- const result = decodePath(input, false);
873
- expect(result).toBe("hello world/abc@def");
874
- });
875
-
876
- it("should encode slashes as %2F in html5Mode", () => {
877
- const input = "section%2Fname/data";
878
- const result = decodePath(input, true);
879
- expect(result).toBe("section%2Fname/data");
880
- });
881
-
882
- it("should preserve decoded forward slashes in html5Mode", () => {
883
- const input = "foo/bar%2Fbaz/qux";
884
- const result = decodePath(input, true);
885
- // 'bar/baz' becomes 'bar%2Fbaz'
886
- expect(result).toBe("foo/bar%2Fbaz/qux");
887
- });
888
-
889
- it("should not change decoded slashes when html5Mode is false", () => {
890
- const input = "foo/bar%2Fbaz/qux";
891
- const result = decodePath(input, false);
892
- expect(result).toBe("foo/bar/baz/qux");
893
- });
894
-
895
- it("should handle empty segments correctly", () => {
896
- const input = "a//b";
897
- const result = decodePath(input, false);
898
- expect(result).toBe("a//b"); // empty segment remains
899
- });
900
-
901
- it("should decode already decoded values without errors", () => {
902
- const input = "simple/path";
903
- const result = decodePath(input, false);
904
- expect(result).toBe("simple/path");
905
- });
906
-
907
- it("should decode and re-encode all forward slashes in segments when html5Mode is true", () => {
908
- const input = "a%2Fb/c%2Fd";
909
- const result = decodePath(input, true);
910
- expect(result).toBe("a%2Fb/c%2Fd");
911
- });
912
-
913
- it("should return an empty string if given an empty string", () => {
914
- expect(decodePath("", false)).toBe("");
915
- expect(decodePath("", true)).toBe("");
916
- });
917
-
918
- it("should decode double-encoded segments only once", () => {
919
- const input = "double%2520encoded"; // '%2520' = '%20'
920
- const result = decodePath(input, false);
921
- expect(result).toBe("double%20encoded"); // Only decode once
922
- });
923
-
924
- it("should correctly decode reserved URI characters", () => {
925
- const input = "%3A%3B%26%3D";
926
- const result = decodePath(input, false);
927
- expect(result).toBe(":;&=");
928
- });
929
-
930
- it("should throw URIError for malformed percent encodings", () => {
931
- const input = "bad%encoding";
932
- expect(() => decodePath(input, false)).toThrowError(URIError);
933
- });
934
-
935
- it("should preserve leading and trailing empty segments", () => {
936
- const input = "/path/with/trailing/";
937
- const result = decodePath(input, false);
938
- expect(result).toBe("/path/with/trailing/");
939
- });
940
-
941
- it("should re-encode slashes inside segments when html5Mode is true", () => {
942
- const input = "path%2Fsegment/next";
943
- const result = decodePath(input, true);
944
- expect(result).toBe("path%2Fsegment/next");
945
- });
946
-
947
- it("should handle completely empty segments (multiple slashes)", () => {
948
- const input = "///";
949
- const result = decodePath(input, false);
950
- expect(result).toBe("///");
951
- });
952
- });
953
-
954
- describe("normalizePath", () => {
955
- it("should encode the path, append search and hash correctly", () => {
956
- const path = "folder name/file name";
957
- const search = { q: "test", page: "1" };
958
- const hash = "section 2";
959
-
960
- const result = normalizePath(path, search, hash);
961
- expect(result).toBe(
962
- "folder%20name/file%20name?q=test&page=1#section%202",
963
- );
964
- });
965
-
966
- it("should return path only if no search and no hash", () => {
967
- const path = "simple/path";
968
- const result = normalizePath(path, null, null);
969
- expect(result).toBe("simple/path");
970
- });
971
-
972
- it("should correctly encode search params from object", () => {
973
- const search = { a: "1", b: "2" };
974
- const result = normalizePath("path", search, null);
975
- expect(result).toBe("path?a=1&b=2");
976
- });
977
-
978
- it("should correctly encode array values in search", () => {
979
- const search = { a: ["1", "2"] };
980
- const result = normalizePath("path", search, null);
981
- // Expected: a=1&a=2 (both keys repeated)
982
- expect(result).toBe("path?a=1&a=2");
983
- });
984
-
985
- it("should handle boolean true values", () => {
986
- const search = { flag: true };
987
- const result = normalizePath("path", search, null);
988
- expect(result).toBe("path?flag");
989
- });
990
-
991
- it("should encode hash value properly", () => {
992
- const path = "path";
993
- const hash = "hello world";
994
- const result = normalizePath(path, null, hash);
995
- expect(result).toBe("path#hello%20world");
996
- });
997
-
998
- it("should not append ? if search is empty string or empty object", () => {
999
- expect(normalizePath("path", "", "hash")).toBe("path#hash");
1000
- expect(normalizePath("path", {}, "hash")).toBe("path#hash");
1001
- });
1002
-
1003
- it("should handle empty path gracefully", () => {
1004
- const result = normalizePath("", { a: "1" }, "h");
1005
- expect(result).toBe("?a=1#h");
1006
- });
1007
- });
1008
-
1009
- describe("parseAppUrl", () => {
1010
- let locationObj;
1011
-
1012
- beforeEach(() => {
1013
- locationObj = new Location(
1014
- "http://www.domain.com:9877/",
1015
- "http://www.domain.com:9877/",
1016
- );
1017
- });
1018
-
1019
- it("should throw error on url starting with // or \\\\", () => {
1020
- expect(() => parseAppUrl("//invalid/path", false)).toThrowError(
1021
- /Invalid url/,
1022
- );
1023
- expect(() => parseAppUrl("\\\\invalid\\path", false)).toThrowError(
1024
- /Invalid url/,
1025
- );
1026
- });
1027
-
1028
- it("should add leading slash if missing and parse url correctly", () => {
1029
- parseAppUrl("some/path?foo=bar#hashValue", false);
1030
- expect(locationObj.getPath()).toBe("/some/path");
1031
- expect(locationObj.getSearch()).toEqual(
1032
- jasmine.objectContaining({ foo: "bar" }),
1033
- );
1034
- expect(locationObj.getHash()).toBe("hashValue");
1035
- });
1036
-
1037
- it("should keep leading slash if present", () => {
1038
- parseAppUrl("/already/slashed?x=1#abc", locationObj, false);
1039
- expect(locationObj.getPath()).toBe("/already/slashed");
1040
- expect(locationObj.getSearch()).toEqual(
1041
- jasmine.objectContaining({ x: "1" }),
1042
- );
1043
- expect(locationObj.getHash()).toBe("abc");
1044
- });
1045
-
1046
- it("should remove leading slash from path if prefixed and path starts with slash", () => {
1047
- parseAppUrl("foo/bar", locationObj, false);
1048
- expect(locationObj.getPath().charAt(0)).toBe("/");
1049
- expect(locationObj.getPath()).toBe("/foo/bar");
1050
- });
1051
-
1052
- it("should set empty $$search when no query params", () => {
1053
- parseAppUrl("/pathOnly", locationObj, false);
1054
- expect(locationObj.getSearch()).toEqual({});
1055
- });
1056
-
1057
- it("should decode hash correctly", () => {
1058
- parseAppUrl("/path#%23encoded", locationObj, false);
1059
- expect(locationObj.getHash()).toBe("#encoded");
1060
- });
1061
- });
1062
-
1063
- describe("stripBaseUrl", () => {
1064
- it("should return substring after base if url starts with base", () => {
1065
- expect(stripBaseUrl("/base", "/base/some/path")).toBe("/some/path");
1066
- expect(
1067
- stripBaseUrl("http://example.com", "http://example.com/page"),
1068
- ).toBe("/page");
1069
- expect(stripBaseUrl("", "/anything")).toBe("/anything"); // empty base returns full url
1070
- });
1071
-
1072
- it("should return empty string if url equals base", () => {
1073
- expect(stripBaseUrl("/base", "/base")).toBe("");
1074
- });
1075
-
1076
- it("should return undefined if url does not start with base", () => {
1077
- expect(stripBaseUrl("/base", "/notbase/something")).toBeUndefined();
1078
- expect(
1079
- stripBaseUrl("http://example.com", "https://example.com/page"),
1080
- ).toBeUndefined();
1081
- });
1082
-
1083
- it("should handle base being longer than url", () => {
1084
- expect(stripBaseUrl("/longer/base", "/short")).toBeUndefined();
1085
- });
1086
-
1087
- it("should be case sensitive", () => {
1088
- expect(stripBaseUrl("/Base", "/base/something")).toBeUndefined();
1089
- });
1090
- });
1091
-
1092
- describe("stripHash", () => {
1093
- it("should return the same URL if there is no hash", () => {
1094
- expect(stripHash("http://example.com/path")).toBe(
1095
- "http://example.com/path",
1096
- );
1097
- expect(stripHash("/some/path")).toBe("/some/path");
1098
- });
1099
-
1100
- it("should remove the hash and everything after it", () => {
1101
- expect(stripHash("http://example.com/path#section1")).toBe(
1102
- "http://example.com/path",
1103
- );
1104
- expect(stripHash("/path/to/resource#hashvalue")).toBe(
1105
- "/path/to/resource",
1106
- );
1107
- });
1108
-
1109
- it("should remove hash even if it is at the very end", () => {
1110
- expect(stripHash("http://example.com/#")).toBe("http://example.com/");
1111
- });
1112
-
1113
- it("should handle empty string input", () => {
1114
- expect(stripHash("")).toBe("");
1115
- });
1116
-
1117
- it("should handle hash only string", () => {
1118
- expect(stripHash("#hashonly")).toBe("");
1119
- });
1120
- });
1121
-
1122
- describe("stripFile", () => {
1123
- it("removes filename from URL without hash", () => {
1124
- const input = "https://example.com/path/to/file.js";
1125
- const expected = "https://example.com/path/to/";
1126
- expect(stripFile(input)).toBe(expected);
1127
- });
1128
-
1129
- it("removes filename and hash from URL", () => {
1130
- const input = "https://example.com/path/to/file.js#section";
1131
- const expected = "https://example.com/path/to/";
1132
- expect(stripFile(input)).toBe(expected);
1133
- });
1134
-
1135
- it("handles root URL with file", () => {
1136
- const input = "https://example.com/file.js";
1137
- const expected = "https://example.com/";
1138
- expect(stripFile(input)).toBe(expected);
1139
- });
1140
-
1141
- it("handles URL with no file", () => {
1142
- const input = "https://example.com/path/to/";
1143
- const expected = "https://example.com/path/to/";
1144
- expect(stripFile(input)).toBe(expected);
1145
- });
1146
-
1147
- it("handles relative URL with file and hash", () => {
1148
- const input = "docs/static/app.js#v1";
1149
- const expected = "docs/static/";
1150
- expect(stripFile(input)).toBe(expected);
1151
- });
1152
- });
1153
-
1154
- describe("serverBase", () => {
1155
- it("returns server base for https URL without port", () => {
1156
- const input = "https://example.com/path/to/resource";
1157
- const expected = "https://example.com";
1158
- expect(serverBase(input)).toBe(expected);
1159
- });
1160
-
1161
- it("returns server base for http URL with port", () => {
1162
- const input = "http://localhost:8080/api/data";
1163
- const expected = "http://localhost:8080";
1164
- expect(serverBase(input)).toBe(expected);
1165
- });
1166
-
1167
- it("returns server base for URL with subdomain", () => {
1168
- const input = "https://api.example.com/v1/query";
1169
- const expected = "https://api.example.com";
1170
- expect(serverBase(input)).toBe(expected);
1171
- });
1172
-
1173
- it("returns full URL if no path is present", () => {
1174
- const input = "https://example.com";
1175
- const expected = "https://example.com";
1176
- expect(serverBase(input)).toBe(expected);
1177
- });
1178
-
1179
- it("handles trailing slash after host", () => {
1180
- const input = "https://example.com/";
1181
- const expected = "https://example.com";
1182
- expect(serverBase(input)).toBe(expected);
1183
- });
1184
- });
1185
-
1186
- describe("urlsEqual", () => {
1187
- it("matches same URL", () => {
1188
- expect(
1189
- urlsEqual("http://example.com/foo", "http://example.com/foo"),
1190
- ).toBe(true);
1191
- });
1192
-
1193
- it("ignores trailing slash", () => {
1194
- expect(
1195
- urlsEqual("http://example.com/foo/", "http://example.com/foo"),
1196
- ).toBe(true);
1197
- });
1198
-
1199
- it("ignores encoded spaces", () => {
1200
- expect(
1201
- urlsEqual("http://example.com/foo%20bar", "http://example.com/foo bar"),
1202
- ).toBe(true);
1203
- });
1204
-
1205
- it("ignores empty hash", () => {
1206
- expect(
1207
- urlsEqual("http://example.com/foo#", "http://example.com/foo"),
1208
- ).toBe(true);
1209
- });
1210
-
1211
- it("resolves relative to base href", () => {
1212
- const base = document.createElement("base");
1213
- base.href = "http://localhost/";
1214
- document.head.appendChild(base);
1215
-
1216
- expect(urlsEqual("/bar", "http://localhost/bar")).toBe(true);
1217
-
1218
- document.head.removeChild(base); // cleanup
1219
- });
1220
-
1221
- it("returns false for different paths", () => {
1222
- expect(
1223
- urlsEqual("http://example.com/foo", "http://example.com/bar"),
1224
- ).toBe(false);
1225
- });
1226
- });
1227
-
1228
- // describe("location watch", () => {
1229
- // it("should not update browser if only the empty hash fragment is cleared", () => {
1230
- // initService({ supportHistory: true });
1231
- // mockUpBrowser({ initialUrl: "http://new.com/a/b#", baseHref: "/base/" });
1232
- // inject(($browser, $rootScope) => {
1233
- // $browser.url("http://new.com/a/b");
1234
- // const $browserUrl = spyOnlyCallsWithArgs(
1235
- // $browser,
1236
- // "url",
1237
- // ).and.callThrough();
1238
- // $rootScope.$digest();
1239
- // expect($browserUrl).not.toHaveBeenCalled();
1240
- // });
1241
- // });
1242
-
1243
- // it("should not replace browser url if only the empty hash fragment is cleared", () => {
1244
- // initService({ html5Mode: true, supportHistory: true });
1245
- // mockUpBrowser({ initialUrl: "http://new.com/#", baseHref: "/" });
1246
- // inject(($browser, $location, $window) => {
1247
- // expect($browser.url()).toBe("http://new.com/");
1248
- // expect($location.absUrl).toBe("http://new.com/");
1249
- // expect($window.location.href).toBe("http://new.com/#");
1250
- // });
1251
- // });
1252
-
1253
- // it("should not get caught in infinite digest when replacing path in locationChangeSuccess handler", () => {
1254
- // initService({ html5Mode: true, supportHistory: false });
1255
- // mockUpBrowser({
1256
- // initialUrl: "http://server/base/home",
1257
- // baseHref: "/base/",
1258
- // });
1259
- // inject(($browser, $location, $rootScope, $window) => {
1260
- // let handlerCalled = false;
1261
- // $rootScope.$on("$locationChangeSuccess", () => {
1262
- // handlerCalled = true;
1263
- // if ($location.getPath() !== "/") {
1264
- // $location.setPath("/").replace();
1265
- // }
1266
- // });
1267
- // expect($browser.url()).toEqual("http://server/base/#!/home");
1268
- // $rootScope.$digest();
1269
- // expect(handlerCalled).toEqual(true);
1270
- // expect($browser.url()).toEqual("http://server/base/#!/");
1271
- // });
1272
- // });
1273
-
1274
- // it("should not infinitely digest when using a semicolon in initial path", () => {
1275
- // initService({ html5Mode: true, supportHistory: true });
1276
- // mockUpBrowser({
1277
- // initialUrl: "http://localhost:9876/;jsessionid=foo",
1278
- // baseHref: "/",
1279
- // });
1280
- // inject(($location, $browser, $rootScope) => {
1281
- // expect(() => {
1282
- // $rootScope.$digest();
1283
- // }).not.toThrow();
1284
- // });
1285
- // });
1286
-
1287
- // // https://github.com/angular/angular.js/issues/16592
1288
- // it("should not infinitely digest when initial params contain a quote", () => {
1289
- // initService({ html5Mode: true, supportHistory: true });
1290
- // mockUpBrowser({
1291
- // initialUrl: "http://localhost:9876/?q='",
1292
- // baseHref: "/",
1293
- // });
1294
- // inject(($location, $browser, $rootScope) => {
1295
- // expect(() => {
1296
- // $rootScope.$digest();
1297
- // }).not.toThrow();
1298
- // });
1299
- // });
1300
-
1301
- // // https://github.com/angular/angular.js/issues/16592
1302
- // it("should not infinitely digest when initial params contain an escaped quote", () => {
1303
- // initService({ html5Mode: true, supportHistory: true });
1304
- // mockUpBrowser({
1305
- // initialUrl: "http://localhost:9876/?q=%27",
1306
- // baseHref: "/",
1307
- // });
1308
- // inject(($location, $browser, $rootScope) => {
1309
- // expect(() => {
1310
- // $rootScope.$digest();
1311
- // }).not.toThrow();
1312
- // });
1313
- // });
1314
-
1315
- // // https://github.com/angular/angular.js/issues/16592
1316
- // it("should not infinitely digest when updating params containing a quote (via $browser.url)", () => {
1317
- // initService({ html5Mode: true, supportHistory: true });
1318
- // mockUpBrowser({ initialUrl: "http://localhost:9876/", baseHref: "/" });
1319
- // inject(($location, $browser, $rootScope) => {
1320
- // $rootScope.$digest();
1321
- // $browser.url("http://localhost:9876/?q='");
1322
- // expect(() => {
1323
- // $rootScope.$digest();
1324
- // }).not.toThrow();
1325
- // });
1326
- // });
1327
-
1328
- // // https://github.com/angular/angular.js/issues/16592
1329
- // it("should not infinitely digest when updating params containing a quote (via window.location + popstate)", () => {
1330
- // initService({ html5Mode: true, supportHistory: true });
1331
- // mockUpBrowser({ initialUrl: "http://localhost:9876/", baseHref: "/" });
1332
- // inject(($window, $location, $browser, $rootScope) => {
1333
- // $rootScope.$digest();
1334
- // $window.location.href = "http://localhost:9876/?q='";
1335
- // expect(() => {
1336
- // ($window).triggerHandler("popstate");
1337
- // }).not.toThrow();
1338
- // });
1339
- // });
1340
-
1341
- // describe("when changing the browser URL/history directly during a `$digest`", () => {
1342
- // beforeEach(() => {
1343
- // initService({ supportHistory: true });
1344
- // mockUpBrowser({ initialUrl: "http://foo.bar/", baseHref: "/" });
1345
- // });
1346
-
1347
- // it("should correctly update `$location` from history and not digest infinitely", inject((
1348
- // $browser,
1349
- // $location,
1350
- // $rootScope,
1351
- // $window,
1352
- // ) => {
1353
- // $location.setUrl("baz");
1354
- // $rootScope.$digest();
1355
-
1356
- // const originalUrl = $window.location.href;
1357
-
1358
- // $rootScope.$apply(() => {
1359
- // $rootScope.$evalAsync(() => {
1360
- // $window.history.pushState({}, null, `${originalUrl}/qux`);
1361
- // });
1362
- // });
1363
-
1364
- // expect($browser.url()).toBe("http://foo.bar/#!/baz/qux");
1365
- // expect($location.absUrl).toBe("http://foo.bar/#!/baz/qux");
1366
-
1367
- // $rootScope.$apply(() => {
1368
- // $rootScope.$evalAsync(() => {
1369
- // $window.history.replaceState({}, null, `${originalUrl}/quux`);
1370
- // });
1371
- // });
1372
-
1373
- // expect($browser.url()).toBe("http://foo.bar/#!/baz/quux");
1374
- // expect($location.absUrl).toBe("http://foo.bar/#!/baz/quux");
1375
- // }));
1376
-
1377
- // it("should correctly update `$location` from URL and not digest infinitely", inject((
1378
- // $browser,
1379
- // $location,
1380
- // $rootScope,
1381
- // $window,
1382
- // ) => {
1383
- // $location.setUrl("baz");
1384
- // $rootScope.$digest();
1385
-
1386
- // $rootScope.$apply(() => {
1387
- // $rootScope.$evalAsync(() => {
1388
- // $window.location.href += "/qux";
1389
- // });
1390
- // });
1391
-
1392
- // ($window).triggerHandler("hashchange");
1393
-
1394
- // expect($browser.url()).toBe("http://foo.bar/#!/baz/qux");
1395
- // expect($location.absUrl).toBe("http://foo.bar/#!/baz/qux");
1396
- // }));
1397
- // });
1398
-
1399
- // function updatePathOnLocationChangeSuccessTo(newPath, newParams) {
1400
- // inject(($rootScope, $location) => {
1401
- // $rootScope.$on("$locationChangeSuccess", (event, newUrl, oldUrl) => {
1402
- // $location.setPath(newPath);
1403
- // if (newParams) {
1404
- // $location.setSearch(newParams);
1405
- // }
1406
- // });
1407
- // });
1408
- // }
1409
-
1410
- // describe("location watch for hashbang browsers", () => {
1411
- // it("should not infinite $digest when going to base URL without trailing slash when $locationChangeSuccess watcher changes path to /Home", () => {
1412
- // initService({ html5Mode: true, supportHistory: false });
1413
- // mockUpBrowser({ initialUrl: "http://server/app/", baseHref: "/app/" });
1414
- // inject(($rootScope, $location, $browser) => {
1415
- // const $browserUrl = spyOnlyCallsWithArgs(
1416
- // $browser,
1417
- // "url",
1418
- // ).and.callThrough();
1419
-
1420
- // updatePathOnLocationChangeSuccessTo("/Home");
1421
-
1422
- // $rootScope.$digest();
1423
-
1424
- // expect($browser.url()).toEqual("http://server/app/#!/Home");
1425
- // expect($location.getPath()).toEqual("/Home");
1426
- // expect($browserUrl).toHaveBeenCalledTimes(1);
1427
- // });
1428
- // });
1429
-
1430
- // it("should not infinite $digest when going to base URL without trailing slash when $locationChangeSuccess watcher changes path to /", () => {
1431
- // initService({ html5Mode: true, supportHistory: false });
1432
- // mockUpBrowser({
1433
- // initialUrl: "http://server/app/Home",
1434
- // baseHref: "/app/",
1435
- // });
1436
- // inject(($rootScope, $location, $browser, $window) => {
1437
- // const $browserUrl = spyOnlyCallsWithArgs(
1438
- // $browser,
1439
- // "url",
1440
- // ).and.callThrough();
1441
-
1442
- // updatePathOnLocationChangeSuccessTo("/");
1443
-
1444
- // $rootScope.$digest();
1445
-
1446
- // expect($browser.url()).toEqual("http://server/app/#!/");
1447
- // expect($location.getPath()).toEqual("/");
1448
- // expect($browserUrl).toHaveBeenCalledTimes(1);
1449
- // expect($browserUrl.calls.argsFor(0)).toEqual([
1450
- // "http://server/app/#!/",
1451
- // false,
1452
- // null,
1453
- // ]);
1454
- // });
1455
- // });
1456
-
1457
- // it("should not infinite $digest when going to base URL with trailing slash when $locationChangeSuccess watcher changes path to /Home", () => {
1458
- // initService({ html5Mode: true, supportHistory: false });
1459
- // mockUpBrowser({ initialUrl: "http://server/app/", baseHref: "/app/" });
1460
- // inject(($rootScope, $location, $browser) => {
1461
- // const $browserUrl = spyOnlyCallsWithArgs(
1462
- // $browser,
1463
- // "url",
1464
- // ).and.callThrough();
1465
-
1466
- // updatePathOnLocationChangeSuccessTo("/Home");
1467
- // $rootScope.$digest();
1468
-
1469
- // expect($browser.url()).toEqual("http://server/app/#!/Home");
1470
- // expect($location.getPath()).toEqual("/Home");
1471
- // expect($browserUrl).toHaveBeenCalledTimes(1);
1472
- // expect($browserUrl.calls.argsFor(0)).toEqual([
1473
- // "http://server/app/#!/Home",
1474
- // false,
1475
- // null,
1476
- // ]);
1477
- // });
1478
- // });
1479
-
1480
- // it("should not infinite $digest when going to base URL with trailing slash when $locationChangeSuccess watcher changes path to /", () => {
1481
- // initService({ html5Mode: true, supportHistory: false });
1482
- // mockUpBrowser({ initialUrl: "http://server/app/", baseHref: "/app/" });
1483
- // inject(($rootScope, $location, $browser) => {
1484
- // const $browserUrl = spyOnlyCallsWithArgs(
1485
- // $browser,
1486
- // "url",
1487
- // ).and.callThrough();
1488
-
1489
- // updatePathOnLocationChangeSuccessTo("/");
1490
- // $rootScope.$digest();
1491
-
1492
- // expect($browser.url()).toEqual("http://server/app/#!/");
1493
- // expect($location.getPath()).toEqual("/");
1494
- // expect($browserUrl).toHaveBeenCalledTimes(1);
1495
- // });
1496
- // });
1497
- // });
1498
-
1499
- // describe("location watch for HTML5 browsers", () => {
1500
- // it("should not infinite $digest when going to base URL without trailing slash when $locationChangeSuccess watcher changes path to /Home", () => {
1501
- // initService({ html5Mode: true, supportHistory: true });
1502
- // mockUpBrowser({ initialUrl: "http://server/app/", baseHref: "/app/" });
1503
- // inject(($rootScope, $injector, $browser) => {
1504
- // const $browserUrl = spyOnlyCallsWithArgs(
1505
- // $browser,
1506
- // "url",
1507
- // ).and.callThrough();
1508
-
1509
- // const $location = $injector.get("$location");
1510
- // updatePathOnLocationChangeSuccessTo("/Home");
1511
-
1512
- // $rootScope.$digest();
1513
-
1514
- // expect($browser.url()).toEqual("http://server/app/Home");
1515
- // expect($location.getPath()).toEqual("/Home");
1516
- // expect($browserUrl).toHaveBeenCalledTimes(1);
1517
- // });
1518
- // });
1519
-
1520
- // it("should not infinite $digest when going to base URL without trailing slash when $locationChangeSuccess watcher changes path to /", () => {
1521
- // initService({ html5Mode: true, supportHistory: true });
1522
- // mockUpBrowser({ initialUrl: "http://server/app/", baseHref: "/app/" });
1523
- // inject(($rootScope, $injector, $browser) => {
1524
- // const $browserUrl = spyOnlyCallsWithArgs(
1525
- // $browser,
1526
- // "url",
1527
- // ).and.callThrough();
1528
-
1529
- // const $location = $injector.get("$location");
1530
- // updatePathOnLocationChangeSuccessTo("/");
1531
-
1532
- // $rootScope.$digest();
1533
-
1534
- // expect($browser.url()).toEqual("http://server/app/");
1535
- // expect($location.getPath()).toEqual("/");
1536
- // expect($browserUrl).not.toHaveBeenCalled();
1537
- // });
1538
- // });
1539
-
1540
- // it("should not infinite $digest when going to base URL with trailing slash when $locationChangeSuccess watcher changes path to /Home", () => {
1541
- // initService({ html5Mode: true, supportHistory: true });
1542
- // mockUpBrowser({ initialUrl: "http://server/app/", baseHref: "/app/" });
1543
- // inject(($rootScope, $injector, $browser) => {
1544
- // const $browserUrl = spyOnlyCallsWithArgs(
1545
- // $browser,
1546
- // "url",
1547
- // ).and.callThrough();
1548
-
1549
- // const $location = $injector.get("$location");
1550
- // updatePathOnLocationChangeSuccessTo("/Home");
1551
-
1552
- // $rootScope.$digest();
1553
-
1554
- // expect($browser.url()).toEqual("http://server/app/Home");
1555
- // expect($location.getPath()).toEqual("/Home");
1556
- // expect($browserUrl).toHaveBeenCalledTimes(1);
1557
- // });
1558
- // });
1559
-
1560
- // it("should not infinite $digest when going to base URL with trailing slash when $locationChangeSuccess watcher changes path to /", () => {
1561
- // initService({ html5Mode: true, supportHistory: true });
1562
- // mockUpBrowser({ initialUrl: "http://server/app/", baseHref: "/app/" });
1563
- // inject(($rootScope, $injector, $browser) => {
1564
- // const $browserUrl = spyOnlyCallsWithArgs(
1565
- // $browser,
1566
- // "url",
1567
- // ).and.callThrough();
1568
-
1569
- // const $location = $injector.get("$location");
1570
- // updatePathOnLocationChangeSuccessTo("/");
1571
-
1572
- // $rootScope.$digest();
1573
-
1574
- // expect($browser.url()).toEqual("http://server/app/");
1575
- // expect($location.getPath()).toEqual("/");
1576
- // expect($browserUrl).not.toHaveBeenCalled();
1577
- // });
1578
- // });
1579
-
1580
- // // https://github.com/angular/angular.js/issues/16592
1581
- // it("should not infinite $digest when going to base URL with trailing slash when $locationChangeSuccess watcher changes query params to contain quote", () => {
1582
- // initService({ html5Mode: true, supportHistory: true });
1583
- // mockUpBrowser({ initialUrl: "http://server/app/", baseHref: "/app/" });
1584
- // inject(($rootScope, $injector, $browser) => {
1585
- // const $browserUrl = spyOnlyCallsWithArgs(
1586
- // $browser,
1587
- // "url",
1588
- // ).and.callThrough();
1589
-
1590
- // const $location = $injector.get("$location");
1591
- // updatePathOnLocationChangeSuccessTo("/", { q: "'" });
1592
-
1593
- // $rootScope.$digest();
1594
-
1595
- // expect($location.getPath()).toEqual("/");
1596
- // expect($location.getSearch()).toEqual({ q: "'" });
1597
- // expect($browserUrl).toHaveBeenCalledTimes(1);
1598
- // });
1599
- // });
1600
- // });
1601
- // });
1602
-
1603
- // describe("wiring", () => {
1604
- // it("should update $location when browser url changes", () => {
1605
- // initService({ html5Mode: false, hashPrefix: "!", supportHistory: true });
1606
- // mockUpBrowser({ initialUrl: "http://new.com/a/b#!", baseHref: "/a/b" });
1607
- // inject(($window, $browser, $location, $rootScope) => {
1608
- // spyOn($location, "parse").and.callThrough();
1609
- // $window.location.href = "http://new.com/a/b#!/aaa";
1610
- // $browser.$$checkUrlChange();
1611
- // expect($location.absUrl).toBe("http://new.com/a/b#!/aaa");
1612
- // expect($location.getPath()).toBe("/aaa");
1613
- // expect($location.parse).toHaveBeenCalled();
1614
- // });
1615
- // });
1616
-
1617
- // // location.href = '...' fires hashchange event synchronously, so it might happen inside $apply
1618
- // it("should not $apply when browser url changed inside $apply", () => {
1619
- // initService({ html5Mode: false, hashPrefix: "!", supportHistory: true });
1620
- // mockUpBrowser({ initialUrl: "http://new.com/a/b#!", baseHref: "/a/b" });
1621
- // inject(($rootScope, $browser, $location, $window) => {
1622
- // const OLD_URL = $browser.url();
1623
- // const NEW_URL = "http://new.com/a/b#!/new";
1624
-
1625
- // $rootScope.$apply(() => {
1626
- // $window.location.href = NEW_URL;
1627
- // $browser.$$checkUrlChange(); // simulate firing event from browser
1628
- // expect($location.absUrl).toBe(OLD_URL); // should be async
1629
- // });
1630
-
1631
- // expect($location.absUrl).toBe(NEW_URL);
1632
- // });
1633
- // });
1634
-
1635
- // // location.href = '...' fires hashchange event synchronously, so it might happen inside $digest
1636
- // it("should not $apply when browser url changed inside $digest", () => {
1637
- // initService({ html5Mode: false, hashPrefix: "!", supportHistory: true });
1638
- // mockUpBrowser({ initialUrl: "http://new.com/a/b#!", baseHref: "/a/b" });
1639
- // inject(($rootScope, $browser, $location, $window) => {
1640
- // const OLD_URL = $browser.url();
1641
- // const NEW_URL = "http://new.com/a/b#!/new";
1642
- // let notRunYet = true;
1643
-
1644
- // $rootScope.$watch(() => {
1645
- // if (notRunYet) {
1646
- // notRunYet = false;
1647
- // $window.location.href = NEW_URL;
1648
- // $browser.$$checkUrlChange(); // simulate firing event from browser
1649
- // expect($location.absUrl).toBe(OLD_URL); // should be async
1650
- // }
1651
- // });
1652
-
1653
- // $rootScope.$digest();
1654
- // expect($location.absUrl).toBe(NEW_URL);
1655
- // });
1656
- // });
1657
-
1658
- // it("should update browser when $location changes", () => {
1659
- // initService({ html5Mode: false, hashPrefix: "!", supportHistory: true });
1660
- // mockUpBrowser({ initialUrl: "http://new.com/a/b#!", baseHref: "/a/b" });
1661
- // inject(($rootScope, $browser, $location) => {
1662
- // const $browserUrl = spyOnlyCallsWithArgs(
1663
- // $browser,
1664
- // "url",
1665
- // ).and.callThrough();
1666
- // $location.setPath("/new/path");
1667
- // expect($browserUrl).not.toHaveBeenCalled();
1668
- // $rootScope.$apply();
1669
-
1670
- // expect($browserUrl).toHaveBeenCalled();
1671
- // expect($browser.url()).toBe("http://new.com/a/b#!/new/path");
1672
- // });
1673
- // });
1674
-
1675
- // it("should update browser only once per $apply cycle", () => {
1676
- // initService({ html5Mode: false, hashPrefix: "!", supportHistory: true });
1677
- // mockUpBrowser({ initialUrl: "http://new.com/a/b#!", baseHref: "/a/b" });
1678
- // inject(($rootScope, $browser, $location) => {
1679
- // const $browserUrl = spyOnlyCallsWithArgs(
1680
- // $browser,
1681
- // "url",
1682
- // ).and.callThrough();
1683
- // $location.setPath("/new/path");
1684
-
1685
- // $rootScope.$watch(() => {
1686
- // $location.setSearch("a=b");
1687
- // });
1688
-
1689
- // $rootScope.$apply();
1690
- // expect($browserUrl).toHaveBeenCalled();
1691
- // expect($browser.url()).toBe("http://new.com/a/b#!/new/path?a=b");
1692
- // });
1693
- // });
1694
-
1695
- // it("should replace browser url when url was replaced at least once", () => {
1696
- // initService({ html5Mode: false, hashPrefix: "!", supportHistory: true });
1697
- // mockUpBrowser({ initialUrl: "http://new.com/a/b#!", baseHref: "/a/b" });
1698
- // inject(($rootScope, $browser, $location) => {
1699
- // const $browserUrl = spyOnlyCallsWithArgs(
1700
- // $browser,
1701
- // "url",
1702
- // ).and.callThrough();
1703
- // $location.setPath("/n/url").replace();
1704
- // $rootScope.$apply();
1705
-
1706
- // expect($browserUrl).toHaveBeenCalled();
1707
- // expect($browserUrl.calls.mostRecent().args).toEqual([
1708
- // "http://new.com/a/b#!/n/url",
1709
- // true,
1710
- // null,
1711
- // ]);
1712
- // expect($location.$$replace).toBe(false);
1713
- // });
1714
- // });
1715
-
1716
- // it("should always reset replace flag after running watch", () => {
1717
- // initService({ html5Mode: false, hashPrefix: "!", supportHistory: true });
1718
- // mockUpBrowser({ initialUrl: "http://new.com/a/b#!", baseHref: "/a/b" });
1719
- // inject(($rootScope, $browser, $location) => {
1720
- // // init watches
1721
- // $location.setUrl("/initUrl");
1722
- // $rootScope.$apply();
1723
-
1724
- // // changes url but resets it before digest
1725
- // $location.setUrl("/newUrl").replace().url("/initUrl");
1726
- // $rootScope.$apply();
1727
- // expect($location.$$replace).toBe(false);
1728
-
1729
- // // set the url to the old value
1730
- // $location.setUrl("/newUrl").replace();
1731
- // $rootScope.$apply();
1732
- // expect($location.$$replace).toBe(false);
1733
-
1734
- // // doesn't even change url only calls replace()
1735
- // $location.replace();
1736
- // $rootScope.$apply();
1737
- // expect($location.$$replace).toBe(false);
1738
- // });
1739
- // });
1740
-
1741
- // it("should update the browser if changed from within a watcher", () => {
1742
- // initService({ html5Mode: false, hashPrefix: "!", supportHistory: true });
1743
- // mockUpBrowser({ initialUrl: "http://new.com/a/b#!", baseHref: "/a/b" });
1744
- // inject(($rootScope, $browser, $location) => {
1745
- // $rootScope.$watch(
1746
- // () => true,
1747
- // () => {
1748
- // $location.setPath("/changed");
1749
- // },
1750
- // );
1751
-
1752
- // $rootScope.$digest();
1753
- // expect($browser.url()).toBe("http://new.com/a/b#!/changed");
1754
- // });
1755
- // });
1756
-
1757
- // it("should not infinitely digest if hash is set when there is no hashPrefix", () => {
1758
- // initService({ html5Mode: false, hashPrefix: "", supportHistory: true });
1759
- // mockUpBrowser({ initialUrl: "http://new.com/a/b", baseHref: "/a/b" });
1760
- // inject(($rootScope, $browser, $location) => {
1761
- // $location.setHash("test");
1762
-
1763
- // $rootScope.$digest();
1764
- // expect($browser.url()).toBe("http://new.com/a/b##test");
1765
- // });
1766
- // });
1767
- // });
1768
-
1769
- // describe("wiring in html5 mode", () => {
1770
- // it("should initialize state to initial state from the browser", () => {
1771
- // initService({ html5Mode: true, supportHistory: true });
1772
- // mockUpBrowser({
1773
- // initialUrl: "http://new.com/a/b/",
1774
- // baseHref: "/a/b/",
1775
- // state: { a: 2 },
1776
- // });
1777
- // inject(($location) => {
1778
- // expect($location.getState()).toEqual({ a: 2 });
1779
- // });
1780
- // });
1781
-
1782
- // it("should update $location when browser state changes", () => {
1783
- // initService({ html5Mode: true, supportHistory: true });
1784
- // mockUpBrowser({ initialUrl: "http://new.com/a/b/", baseHref: "/a/b/" });
1785
- // inject(($location, $rootScope, $window) => {
1786
- // $window.history.pushState({ b: 3 });
1787
- // $rootScope.$digest();
1788
-
1789
- // expect($location.getState()).toEqual({ b: 3 });
1790
-
1791
- // $window.history.pushState(
1792
- // { b: 4 },
1793
- // null,
1794
- // `${$window.location.href}c?d=e#f`,
1795
- // );
1796
- // $rootScope.$digest();
1797
-
1798
- // expect($location.getPath()).toBe("/c");
1799
- // expect($location.getSearch()).toEqual({ d: "e" });
1800
- // expect($location.getHash()).toBe("f");
1801
- // expect($location.getState()).toEqual({ b: 4 });
1802
- // });
1803
- // });
1804
-
1805
- // // https://github.com/angular/angular.js/issues/16592
1806
- // it("should not infinite $digest on pushState() with quote in param", () => {
1807
- // initService({ html5Mode: true, supportHistory: true });
1808
- // mockUpBrowser({ initialUrl: "http://server/app/", baseHref: "/app/" });
1809
- // inject(($rootScope, $injector, $window) => {
1810
- // const $location = $injector.get("$location");
1811
- // $rootScope.$digest(); // allow $location initialization to finish
1812
-
1813
- // $window.history.pushState({}, null, "http://server/app/Home?q='");
1814
- // $rootScope.$digest();
1815
-
1816
- // expect($location.absUrl).toEqual("http://server/app/Home?q='");
1817
- // expect($location.getPath()).toEqual("/Home");
1818
- // expect($location.getSearch()).toEqual({ q: "'" });
1819
- // });
1820
- // });
1821
-
1822
- // // https://github.com/angular/angular.js/issues/16592
1823
- // it("should not infinite $digest on popstate event with quote in param", () => {
1824
- // initService({ html5Mode: true, supportHistory: true });
1825
- // mockUpBrowser({ initialUrl: "http://server/app/", baseHref: "/app/" });
1826
- // inject(($rootScope, $injector, $window) => {
1827
- // const $location = $injector.get("$location");
1828
- // $rootScope.$digest(); // allow $location initialization to finish
1829
-
1830
- // $window.location.href = "http://server/app/Home?q='";
1831
- // ($window).triggerHandler("popstate");
1832
-
1833
- // expect($location.absUrl).toEqual("http://server/app/Home?q='");
1834
- // expect($location.getPath()).toEqual("/Home");
1835
- // expect($location.getSearch()).toEqual({ q: "'" });
1836
- // });
1837
- // });
1838
-
1839
- // it("should replace browser url & state when replace() was called at least once", () => {
1840
- // initService({ html5Mode: true, supportHistory: true });
1841
- // mockUpBrowser({ initialUrl: "http://new.com/a/b/", baseHref: "/a/b/" });
1842
- // inject(($rootScope, $location, $browser) => {
1843
- // const $browserUrl = spyOnlyCallsWithArgs(
1844
- // $browser,
1845
- // "url",
1846
- // ).and.callThrough();
1847
- // $location.setPath("/n/url").state({ a: 2 }).replace();
1848
- // $rootScope.$apply();
1849
-
1850
- // expect($browserUrl).toHaveBeenCalled();
1851
- // expect($browserUrl.calls.mostRecent().args).toEqual([
1852
- // "http://new.com/a/b/n/url",
1853
- // true,
1854
- // { a: 2 },
1855
- // ]);
1856
- // expect($location.$$replace).toBe(false);
1857
- // expect($location.$$state).toEqual({ a: 2 });
1858
- // });
1859
- // });
1860
-
1861
- // it("should use only the most recent url & state definition", () => {
1862
- // initService({ html5Mode: true, supportHistory: true });
1863
- // mockUpBrowser({ initialUrl: "http://new.com/a/b/", baseHref: "/a/b/" });
1864
-
1865
- // inject(($rootScope, $location, $browser) => {
1866
- // const $browserUrl = spyOnlyCallsWithArgs(
1867
- // $browser,
1868
- // "url",
1869
- // ).and.callThrough();
1870
- // $location
1871
- // .setPath("/n/url")
1872
- // .state({ a: 2 })
1873
- // .replace()
1874
- // .state({ b: 3 })
1875
- // .setPath("/o/url");
1876
- // $rootScope.$apply();
1877
-
1878
- // expect($browserUrl).toHaveBeenCalled();
1879
- // expect($browserUrl.calls.mostRecent().args).toEqual([
1880
- // "http://new.com/a/b/o/url",
1881
- // true,
1882
- // { b: 3 },
1883
- // ]);
1884
- // expect($location.$$replace).toBe(false);
1885
- // expect($location.$$state).toEqual({ b: 3 });
1886
- // });
1887
- // });
1888
-
1889
- // it("should allow to set state without touching the URL", () => {
1890
- // initService({ html5Mode: true, supportHistory: true });
1891
- // mockUpBrowser({ initialUrl: "http://new.com/a/b/", baseHref: "/a/b/" });
1892
-
1893
- // inject(($rootScope, $location, $browser) => {
1894
- // const $browserUrl = spyOnlyCallsWithArgs(
1895
- // $browser,
1896
- // "url",
1897
- // ).and.callThrough();
1898
- // $location.setState({ a: 2 }).replace().state({ b: 3 });
1899
- // $rootScope.$apply();
1900
-
1901
- // expect($browserUrl).toHaveBeenCalled();
1902
- // expect($browserUrl.calls.mostRecent().args).toEqual([
1903
- // "http://new.com/a/b/",
1904
- // true,
1905
- // { b: 3 },
1906
- // ]);
1907
- // expect($location.$$replace).toBe(false);
1908
- // expect($location.$$state).toEqual({ b: 3 });
1909
- // });
1910
- // });
1911
-
1912
- // it("should always reset replace flag after running watch", () => {
1913
- // initService({ html5Mode: true, supportHistory: true });
1914
- // mockUpBrowser({ initialUrl: "http://new.com/a/b/", baseHref: "/a/b/" });
1915
-
1916
- // inject(($rootScope, $location) => {
1917
- // // init watches
1918
- // $location.setUrl("/initUrl").state({ a: 2 });
1919
- // $rootScope.$apply();
1920
-
1921
- // // changes url & state but resets them before digest
1922
- // $location
1923
- // .url("/newUrl")
1924
- // .state({ a: 2 })
1925
- // .replace()
1926
- // .state({ b: 3 })
1927
- // .url("/initUrl");
1928
- // $rootScope.$apply();
1929
- // expect($location.$$replace).toBe(false);
1930
-
1931
- // // set the url to the old value
1932
- // $location.setUrl("/newUrl").state({ a: 2 }).replace();
1933
- // $rootScope.$apply();
1934
- // expect($location.$$replace).toBe(false);
1935
-
1936
- // // doesn't even change url only calls replace()
1937
- // $location.replace();
1938
- // $rootScope.$apply();
1939
- // expect($location.$$replace).toBe(false);
1940
- // });
1941
- // });
1942
-
1943
- // it("should allow to modify state only before digest", () => {
1944
- // initService({ html5Mode: true, supportHistory: true });
1945
- // mockUpBrowser({ initialUrl: "http://new.com/a/b/", baseHref: "/a/b/" });
1946
-
1947
- // inject(($rootScope, $location, $browser) => {
1948
- // const o = { a: 2 };
1949
- // $location.setState(o);
1950
- // o.a = 3;
1951
- // $rootScope.$apply();
1952
- // expect($browser.state()).toEqual({ a: 3 });
1953
-
1954
- // o.a = 4;
1955
- // $rootScope.$apply();
1956
- // expect($browser.state()).toEqual({ a: 3 });
1957
- // });
1958
- // });
1959
-
1960
- // it("should make $location.getState() referencially identical with $browser.state() after digest", () => {
1961
- // initService({ html5Mode: true, supportHistory: true });
1962
- // mockUpBrowser({ initialUrl: "http://new.com/a/b/", baseHref: "/a/b/" });
1963
-
1964
- // inject(($rootScope, $location, $browser) => {
1965
- // $location.setState({ a: 2 });
1966
- // $rootScope.$apply();
1967
- // expect($location.getState()).toBe($browser.state());
1968
- // });
1969
- // });
1970
-
1971
- // it("should allow to query the state after digest", () => {
1972
- // initService({ html5Mode: true, supportHistory: true });
1973
- // mockUpBrowser({ initialUrl: "http://new.com/a/b/", baseHref: "/a/b/" });
1974
-
1975
- // inject(($rootScope, $location) => {
1976
- // $location.setUrl("/foo").state({ a: 2 });
1977
- // $rootScope.$apply();
1978
- // expect($location.getState()).toEqual({ a: 2 });
1979
- // });
1980
- // });
1981
-
1982
- // it("should reset the state on .url() after digest", () => {
1983
- // initService({ html5Mode: true, supportHistory: true });
1984
- // mockUpBrowser({ initialUrl: "http://new.com/a/b/", baseHref: "/a/b/" });
1985
-
1986
- // inject(($rootScope, $location, $browser) => {
1987
- // $location.setUrl("/foo").state({ a: 2 });
1988
- // $rootScope.$apply();
1989
-
1990
- // const $browserUrl = spyOnlyCallsWithArgs(
1991
- // $browser,
1992
- // "url",
1993
- // ).and.callThrough();
1994
- // $location.setUrl("/bar");
1995
- // $rootScope.$apply();
1996
-
1997
- // expect($browserUrl).toHaveBeenCalled();
1998
- // expect($browserUrl.calls.mostRecent().args).toEqual([
1999
- // "http://new.com/a/b/bar",
2000
- // false,
2001
- // null,
2002
- // ]);
2003
- // });
2004
- // });
2005
-
2006
- // it("should force a page reload if navigating outside of the application base href", () => {
2007
- // initService({ html5Mode: true, supportHistory: true });
2008
- // mockUpBrowser({ initialUrl: "http://new.com/a/b/", baseHref: "/a/b/" });
2009
-
2010
- // inject(($window, $browser, $location) => {
2011
- // $window.location.href = "http://new.com/a/outside.html";
2012
- // spyOn($window.location, "$$setHref");
2013
- // expect($window.location.$$setHref).not.toHaveBeenCalled();
2014
- // $browser.$$checkUrlChange();
2015
- // expect($window.location.$$setHref).toHaveBeenCalledWith(
2016
- // "http://new.com/a/outside.html",
2017
- // );
2018
- // });
2019
- // });
2020
- // });
2021
-
2022
- // TODO MOVE TO PLAYWRIGHT
2023
- // html5 history is disabled
2024
- // describe("disabled history", () => {
2025
- // it("should use hashbang url with hash prefix", () => {
2026
- // initService({ html5Mode: false, hashPrefix: "!" });
2027
- // mockUpBrowser({
2028
- // initialUrl: "http://domain.com/base/index.html#!/a/b",
2029
- // baseHref: "/base/index.html",
2030
- // });
2031
- // inject(($rootScope, $location, $browser) => {
2032
- // expect($browser.url()).toBe("http://domain.com/base/index.html#!/a/b");
2033
- // $location.setPath("/new");
2034
- // $location.setSearch({ a: true });
2035
- // $rootScope.$apply();
2036
- // expect($browser.url()).toBe(
2037
- // "http://domain.com/base/index.html#!/new?a",
2038
- // );
2039
- // });
2040
- // });
2041
-
2042
- // it("should use hashbang url without hash prefix", () => {
2043
- // initService({ html5Mode: false, hashPrefix: "" });
2044
- // mockUpBrowser({
2045
- // initialUrl: "http://domain.com/base/index.html#/a/b",
2046
- // baseHref: "/base/index.html",
2047
- // });
2048
- // inject(($rootScope, $location, $browser) => {
2049
- // expect($browser.url()).toBe("http://domain.com/base/index.html#/a/b");
2050
- // $location.setPath("/new");
2051
- // $location.setSearch({ a: true });
2052
- // $rootScope.$apply();
2053
- // expect($browser.url()).toBe("http://domain.com/base/index.html#/new?a");
2054
- // });
2055
- // });
2056
- // });
2057
-
2058
- // TODO MOVE TO PLAYWRIGHT
2059
- // html5 history enabled, but not supported by browser
2060
- // describe("history on old browser", () => {
2061
- // it("should use hashbang url with hash prefix", () => {
2062
- // initService({ html5Mode: true, hashPrefix: "!!", supportHistory: false });
2063
- // inject(
2064
- // initBrowser({
2065
- // url: "http://domain.com/base/index.html#!!/a/b",
2066
- // basePath: "/base/index.html",
2067
- // }),
2068
- // ($rootScope, $location, $browser) => {
2069
- // expect($browser.url()).toBe(
2070
- // "http://domain.com/base/index.html#!!/a/b",
2071
- // );
2072
- // $location.setPath("/new");
2073
- // $location.setSearch({ a: true });
2074
- // $rootScope.$apply();
2075
- // expect($browser.url()).toBe(
2076
- // "http://domain.com/base/index.html#!!/new?a",
2077
- // );
2078
- // },
2079
- // );
2080
- // });
2081
-
2082
- // it("should redirect to hashbang url when new url given", () => {
2083
- // initService({ html5Mode: true, hashPrefix: "!" });
2084
- // inject(
2085
- // initBrowser({
2086
- // url: "http://domain.com/base/new-path/index.html",
2087
- // basePath: "/base/index.html",
2088
- // }),
2089
- // ($browser, $location) => {
2090
- // expect($browser.url()).toBe(
2091
- // "http://domain.com/base/index.html#!/new-path/index.html",
2092
- // );
2093
- // },
2094
- // );
2095
- // });
2096
-
2097
- // it("should correctly convert html5 url with path matching basepath to hashbang url", () => {
2098
- // initService({ html5Mode: true, hashPrefix: "!", supportHistory: false });
2099
- // inject(
2100
- // initBrowser({
2101
- // url: "http://domain.com/base/index.html",
2102
- // basePath: "/base/index.html",
2103
- // }),
2104
- // ($browser, $location) => {
2105
- // expect($browser.url()).toBe(
2106
- // "http://domain.com/base/index.html#!/index.html",
2107
- // );
2108
- // },
2109
- // );
2110
- // });
2111
- // });
2112
-
2113
- // TODO MOVE TO PLAYWRIGHT
2114
- // html5 history enabled and supported by browser
2115
- // describe("history on new browser", () => {
2116
- // it("should use new url", () => {
2117
- // initService({ html5Mode: true, hashPrefix: "", supportHistory: true });
2118
- // mockUpBrowser({
2119
- // initialUrl: "http://domain.com/base/old/index.html#a",
2120
- // baseHref: "/base/index.html",
2121
- // });
2122
- // inject(($rootScope, $location, $browser) => {
2123
- // expect($browser.url()).toBe("http://domain.com/base/old/index.html#a");
2124
- // $location.setPath("/new");
2125
- // $location.setSearch({ a: true });
2126
- // $rootScope.$apply();
2127
- // expect($browser.url()).toBe("http://domain.com/base/new?a#a");
2128
- // });
2129
- // });
2130
-
2131
- // it("should rewrite when hashbang url given", () => {
2132
- // initService({ html5Mode: true, hashPrefix: "!", supportHistory: true });
2133
- // mockUpBrowser({
2134
- // initialUrl: "http://domain.com/base/index.html#!/a/b",
2135
- // baseHref: "/base/index.html",
2136
- // });
2137
- // inject(($rootScope, $location, $browser) => {
2138
- // expect($browser.url()).toBe("http://domain.com/base/a/b");
2139
- // $location.setPath("/new");
2140
- // $location.setHash("abc");
2141
- // $rootScope.$apply();
2142
- // expect($browser.url()).toBe("http://domain.com/base/new#abc");
2143
- // expect($location.getPath()).toBe("/new");
2144
- // });
2145
- // });
2146
-
2147
- // it("should rewrite when hashbang url given (without hash prefix)", () => {
2148
- // initService({ html5Mode: true, hashPrefix: "", supportHistory: true });
2149
- // mockUpBrowser({
2150
- // initialUrl: "http://domain.com/base/index.html#/a/b",
2151
- // baseHref: "/base/index.html",
2152
- // });
2153
- // inject(($rootScope, $location, $browser) => {
2154
- // expect($browser.url()).toBe("http://domain.com/base/a/b");
2155
- // expect($location.getPath()).toBe("/a/b");
2156
- // });
2157
- // });
2158
- // });
2159
-
2160
- // describe("PATH_MATCH", () => {
2161
- // it("should parse just path", () => {
2162
- // const match = PATH_MATCH.exec("/path");
2163
- // expect(match[1]).toBe("/path");
2164
- // });
2165
-
2166
- // it("should parse path with search", () => {
2167
- // const match = PATH_MATCH.exec("/ppp/a?a=b&c");
2168
- // expect(match[1]).toBe("/ppp/a");
2169
- // expect(match[3]).toBe("a=b&c");
2170
- // });
2171
-
2172
- // it("should parse path with hash", () => {
2173
- // const match = PATH_MATCH.exec("/ppp/a#abc?");
2174
- // expect(match[1]).toBe("/ppp/a");
2175
- // expect(match[5]).toBe("abc?");
2176
- // });
2177
-
2178
- // it("should parse path with both search and hash", () => {
2179
- // const match = PATH_MATCH.exec("/ppp/a?a=b&c#abc/d?");
2180
- // expect(match[3]).toBe("a=b&c");
2181
- // });
2182
- // });
2183
-
2184
- // TODO MOVE TO PLAYWRIGHT
2185
- // describe("link rewriting", () => {
2186
- // let root;
2187
- // let link;
2188
- // let originalBrowser;
2189
- // let lastEventPreventDefault;
2190
-
2191
- // function configureTestLink(options) {
2192
- // let { linkHref } = options;
2193
- // const { relLink } = options;
2194
- // let { attrs } = options;
2195
- // const { content } = options;
2196
-
2197
- // attrs = attrs ? ` ${attrs} ` : "";
2198
-
2199
- // if (typeof linkHref === "string" && !relLink) {
2200
- // if (linkHref[0] === "/") {
2201
- // linkHref = `http://host.com${linkHref}`;
2202
- // } else if (!linkHref.match(/:\/\//)) {
2203
- // // fake the behavior of <base> tag
2204
- // linkHref = `http://host.com/base/${linkHref}`;
2205
- // }
2206
- // }
2207
-
2208
- // if (linkHref) {
2209
- // link = (`<a href="${linkHref}"${attrs}>${content}</a>`)[0];
2210
- // } else {
2211
- // link = (`<a ${attrs}>${content}</a>`)[0];
2212
- // }
2213
-
2214
- // module(
2215
- // ($provide) =>
2216
- // function ($rootElement, $document) {
2217
- // $rootElement.append(link);
2218
- // root = $rootElement;
2219
- // // we need to do this otherwise we can't simulate events
2220
- // $document.querySelector("body").append($rootElement);
2221
- // },
2222
- // );
2223
- // }
2224
-
2225
- // function setupRewriteChecks() {
2226
- // return function ($browser, $location, $rootElement) {
2227
- // originalBrowser = $browser.url();
2228
- // // we have to prevent the default operation, as we need to test absolute links (http://...)
2229
- // // and navigating to these links would kill jstd
2230
- // $rootElement.on("click", (e) => {
2231
- // lastEventPreventDefault = e.isDefaultPrevented();
2232
- // e.preventDefault();
2233
- // });
2234
- // };
2235
- // }
2236
-
2237
- // function expectRewriteTo($browser, url) {
2238
- // expect(lastEventPreventDefault).toBe(true);
2239
- // expect($browser.url()).toBe(url);
2240
- // }
2241
-
2242
- // function expectNoRewrite($browser) {
2243
- // expect(lastEventPreventDefault).toBe(false);
2244
- // expect($browser.url()).toBe(originalBrowser);
2245
- // }
2246
-
2247
- // afterEach(() => {
2248
- // dealoc(root);
2249
- // dealoc(document.body);
2250
- // });
2251
-
2252
- // it("should rewrite rel link to new url when history enabled on new browser", () => {
2253
- // configureTestLink({ linkHref: "link?a#b" });
2254
- // initService({ html5Mode: true, supportHistory: true });
2255
- // inject(
2256
- // initBrowser({
2257
- // url: "http://host.com/base/index.html",
2258
- // basePath: "/base/index.html",
2259
- // }),
2260
- // setupRewriteChecks(),
2261
- // ($browser) => {
2262
- // browserTrigger(link, "click");
2263
- // expectRewriteTo($browser, "http://host.com/base/link?a#b");
2264
- // },
2265
- // );
2266
- // });
2267
-
2268
- // it("should do nothing if already on the same URL", () => {
2269
- // configureTestLink({ linkHref: "/base/" });
2270
- // initService({ html5Mode: true, supportHistory: true });
2271
- // inject(
2272
- // initBrowser({
2273
- // url: "http://host.com/base/index.html",
2274
- // basePath: "/base/index.html",
2275
- // }),
2276
- // setupRewriteChecks(),
2277
- // ($browser) => {
2278
- // browserTrigger(link, "click");
2279
- // expectRewriteTo($browser, "http://host.com/base/");
2280
-
2281
- // (link).getAttribute("href", "http://host.com/base/foo");
2282
- // browserTrigger(link, "click");
2283
- // expectRewriteTo($browser, "http://host.com/base/foo");
2284
-
2285
- // (link).getAttribute("href", "http://host.com/base/");
2286
- // browserTrigger(link, "click");
2287
- // expectRewriteTo($browser, "http://host.com/base/");
2288
-
2289
- // (link)
2290
- // .getAttribute("href", "http://host.com/base/foo")
2291
- // .on("click", (e) => {
2292
- // e.preventDefault();
2293
- // });
2294
- // browserTrigger(link, "click");
2295
- // expect($browser.url()).toBe("http://host.com/base/");
2296
- // },
2297
- // );
2298
- // });
2299
-
2300
- // it("should rewrite abs link to new url when history enabled on new browser", () => {
2301
- // configureTestLink({ linkHref: "/base/link?a#b" });
2302
- // initService({ html5Mode: true, supportHistory: true });
2303
- // inject(
2304
- // initBrowser({
2305
- // url: "http://host.com/base/index.html",
2306
- // basePath: "/base/index.html",
2307
- // }),
2308
- // setupRewriteChecks(),
2309
- // ($browser) => {
2310
- // browserTrigger(link, "click");
2311
- // expectRewriteTo($browser, "http://host.com/base/link?a#b");
2312
- // },
2313
- // );
2314
- // });
2315
-
2316
- // it("should rewrite rel link to hashbang url when history enabled on old browser", () => {
2317
- // configureTestLink({ linkHref: "link?a#b" });
2318
- // initService({ html5Mode: true, supportHistory: false, hashPrefix: "!" });
2319
- // inject(
2320
- // initBrowser({
2321
- // url: "http://host.com/base/index.html",
2322
- // basePath: "/base/index.html",
2323
- // }),
2324
- // setupRewriteChecks(),
2325
- // ($browser) => {
2326
- // browserTrigger(link, "click");
2327
- // expectRewriteTo(
2328
- // $browser,
2329
- // "http://host.com/base/index.html#!/link?a#b",
2330
- // );
2331
- // },
2332
- // );
2333
- // });
2334
-
2335
- // // Regression (gh-7721)
2336
- // it("should not throw when clicking anchor with no href attribute when history enabled on old browser", () => {
2337
- // configureTestLink({ linkHref: null });
2338
- // initService({ html5Mode: true, supportHistory: false });
2339
- // inject(
2340
- // initBrowser({
2341
- // url: "http://host.com/base/index.html",
2342
- // basePath: "/base/index.html",
2343
- // }),
2344
- // setupRewriteChecks(),
2345
- // ($browser) => {
2346
- // browserTrigger(link, "click");
2347
- // expectNoRewrite($browser);
2348
- // },
2349
- // );
2350
- // });
2351
-
2352
- // it('should produce relative paths correctly when $location.getPath() is "/" when history enabled on old browser', () => {
2353
- // configureTestLink({ linkHref: "partial1" });
2354
- // initService({ html5Mode: true, supportHistory: false, hashPrefix: "!" });
2355
- // inject(
2356
- // initBrowser({
2357
- // url: "http://host.com/base/index.html",
2358
- // basePath: "/base/index.html",
2359
- // }),
2360
- // setupRewriteChecks(),
2361
- // ($browser, $location, $rootScope) => {
2362
- // $rootScope.$apply(() => {
2363
- // $location.setPath("/");
2364
- // });
2365
- // browserTrigger(link, "click");
2366
- // expectRewriteTo(
2367
- // $browser,
2368
- // "http://host.com/base/index.html#!/partial1",
2369
- // );
2370
- // },
2371
- // );
2372
- // });
2373
-
2374
- // it("should rewrite abs link to hashbang url when history enabled on old browser", () => {
2375
- // configureTestLink({ linkHref: "/base/link?a#b" });
2376
- // initService({ html5Mode: true, supportHistory: false, hashPrefix: "!" });
2377
- // inject(
2378
- // initBrowser({
2379
- // url: "http://host.com/base/index.html",
2380
- // basePath: "/base/index.html",
2381
- // }),
2382
- // setupRewriteChecks(),
2383
- // ($browser) => {
2384
- // browserTrigger(link, "click");
2385
- // expectRewriteTo(
2386
- // $browser,
2387
- // "http://host.com/base/index.html#!/link?a#b",
2388
- // );
2389
- // },
2390
- // );
2391
- // });
2392
-
2393
- // it("should not rewrite full url links to different domain", () => {
2394
- // configureTestLink({ linkHref: "http://www.dot.abc/a?b=c" });
2395
- // initService({ html5Mode: true });
2396
- // inject(
2397
- // initBrowser({
2398
- // url: "http://host.com/base/index.html",
2399
- // basePath: "/base/index.html",
2400
- // }),
2401
- // setupRewriteChecks(),
2402
- // ($browser) => {
2403
- // browserTrigger(link, "click");
2404
- // expectNoRewrite($browser);
2405
- // },
2406
- // );
2407
- // });
2408
-
2409
- // it('should not rewrite links with target="_blank"', () => {
2410
- // configureTestLink({ linkHref: "base/a?b=c", attrs: 'target="_blank"' });
2411
- // initService({ html5Mode: true, supportHistory: true });
2412
- // inject(
2413
- // initBrowser({
2414
- // url: "http://host.com/base/index.html",
2415
- // basePath: "/base/index.html",
2416
- // }),
2417
- // setupRewriteChecks(),
2418
- // ($browser) => {
2419
- // browserTrigger(link, "click");
2420
- // expectNoRewrite($browser);
2421
- // },
2422
- // );
2423
- // });
2424
-
2425
- // it("should not rewrite links with target specified", () => {
2426
- // configureTestLink({
2427
- // linkHref: "base/a?b=c",
2428
- // attrs: 'target="some-frame"',
2429
- // });
2430
- // initService({ html5Mode: true, supportHistory: true });
2431
- // inject(
2432
- // initBrowser({
2433
- // url: "http://host.com/base/index.html",
2434
- // basePath: "/base/index.html",
2435
- // }),
2436
- // setupRewriteChecks(),
2437
- // ($browser) => {
2438
- // browserTrigger(link, "click");
2439
- // expectNoRewrite($browser);
2440
- // },
2441
- // );
2442
- // });
2443
-
2444
- // it("should not rewrite links with `javascript:` URI", () => {
2445
- // configureTestLink({
2446
- // linkHref: ' jAvAsCrIpT:throw new Error("Boom!")',
2447
- // relLink: true,
2448
- // });
2449
- // initService({ html5Mode: true, supportHistory: true });
2450
- // inject(
2451
- // initBrowser({
2452
- // url: "http://host.com/base/index.html",
2453
- // basePath: "/base/index.html",
2454
- // }),
2455
- // setupRewriteChecks(),
2456
- // ($browser) => {
2457
- // browserTrigger(link, "click");
2458
- // expectNoRewrite($browser);
2459
- // },
2460
- // );
2461
- // });
2462
-
2463
- // it("should not rewrite links with `mailto:` URI", () => {
2464
- // configureTestLink({ linkHref: " mAiLtO:foo@bar.com", relLink: true });
2465
- // initService({ html5Mode: true, supportHistory: true });
2466
- // inject(
2467
- // initBrowser({
2468
- // url: "http://host.com/base/index.html",
2469
- // basePath: "/base/index.html",
2470
- // }),
2471
- // setupRewriteChecks(),
2472
- // ($browser) => {
2473
- // browserTrigger(link, "click");
2474
- // expectNoRewrite($browser);
2475
- // },
2476
- // );
2477
- // });
2478
-
2479
- // it("should not rewrite links when rewriting links is disabled", () => {
2480
- // configureTestLink({ linkHref: "link?a#b" });
2481
- // initService({
2482
- // html5Mode: { enabled: true, rewriteLinks: false },
2483
- // supportHistory: true,
2484
- // });
2485
- // inject(
2486
- // initBrowser({
2487
- // url: "http://host.com/base/index.html",
2488
- // basePath: "/base/index.html",
2489
- // }),
2490
- // setupRewriteChecks(),
2491
- // ($browser) => {
2492
- // browserTrigger(link, "click");
2493
- // expectNoRewrite($browser);
2494
- // },
2495
- // );
2496
- // });
2497
-
2498
- // it("should rewrite links when the specified rewriteLinks attr is present", () => {
2499
- // configureTestLink({ linkHref: "link?a#b", attrs: "do-rewrite" });
2500
- // initService({
2501
- // html5Mode: { enabled: true, rewriteLinks: "do-rewrite" },
2502
- // supportHistory: true,
2503
- // });
2504
- // inject(
2505
- // initBrowser({
2506
- // url: "http://host.com/base/index.html",
2507
- // basePath: "/base/index.html",
2508
- // }),
2509
- // setupRewriteChecks(),
2510
- // ($browser) => {
2511
- // browserTrigger(link, "click");
2512
- // expectRewriteTo($browser, "http://host.com/base/link?a#b");
2513
- // },
2514
- // );
2515
- // });
2516
-
2517
- // it("should not rewrite links when the specified rewriteLinks attr is not present", () => {
2518
- // configureTestLink({ linkHref: "link?a#b" });
2519
- // initService({
2520
- // html5Mode: { enabled: true, rewriteLinks: "do-rewrite" },
2521
- // supportHistory: true,
2522
- // });
2523
- // inject(
2524
- // initBrowser({
2525
- // url: "http://host.com/base/index.html",
2526
- // basePath: "/base/index.html",
2527
- // }),
2528
- // setupRewriteChecks(),
2529
- // ($browser) => {
2530
- // browserTrigger(link, "click");
2531
- // expectNoRewrite($browser);
2532
- // },
2533
- // );
2534
- // });
2535
-
2536
- // it("should rewrite full url links to same domain and base path", () => {
2537
- // configureTestLink({ linkHref: "http://host.com/base/new" });
2538
- // initService({ html5Mode: true, supportHistory: false, hashPrefix: "!" });
2539
- // inject(
2540
- // initBrowser({
2541
- // url: "http://host.com/base/index.html",
2542
- // basePath: "/base/index.html",
2543
- // }),
2544
- // setupRewriteChecks(),
2545
- // ($browser) => {
2546
- // browserTrigger(link, "click");
2547
- // expectRewriteTo($browser, "http://host.com/base/index.html#!/new");
2548
- // },
2549
- // );
2550
- // });
2551
-
2552
- // it("should rewrite when clicked span inside link", () => {
2553
- // configureTestLink({
2554
- // linkHref: "some/link",
2555
- // attrs: "",
2556
- // content: "<span>link</span>",
2557
- // });
2558
- // initService({ html5Mode: true, supportHistory: true });
2559
- // inject(
2560
- // initBrowser({
2561
- // url: "http://host.com/base/index.html",
2562
- // basePath: "/base/index.html",
2563
- // }),
2564
- // setupRewriteChecks(),
2565
- // ($browser) => {
2566
- // const span = (link).querySelector("span");
2567
-
2568
- // browserTrigger(span, "click");
2569
- // expectRewriteTo($browser, "http://host.com/base/some/link");
2570
- // },
2571
- // );
2572
- // });
2573
-
2574
- // it("should not rewrite when link to different base path when history enabled on new browser", () => {
2575
- // configureTestLink({ linkHref: "/other_base/link" });
2576
- // initService({ html5Mode: true, supportHistory: true });
2577
- // inject(
2578
- // initBrowser({
2579
- // url: "http://host.com/base/index.html",
2580
- // basePath: "/base/index.html",
2581
- // }),
2582
- // setupRewriteChecks(),
2583
- // ($browser) => {
2584
- // browserTrigger(link, "click");
2585
- // expectNoRewrite($browser);
2586
- // },
2587
- // );
2588
- // });
2589
-
2590
- // it("should not rewrite when link to different base path when history enabled on old browser", () => {
2591
- // configureTestLink({ linkHref: "/other_base/link" });
2592
- // initService({ html5Mode: true, supportHistory: true });
2593
- // inject(
2594
- // initBrowser({
2595
- // url: "http://host.com/base/index.html",
2596
- // basePath: "/base/index.html",
2597
- // }),
2598
- // setupRewriteChecks(),
2599
- // ($browser) => {
2600
- // browserTrigger(link, "click");
2601
- // expectNoRewrite($browser);
2602
- // },
2603
- // );
2604
- // });
2605
-
2606
- // it("should not rewrite when link to different base path when history disabled", () => {
2607
- // configureTestLink({ linkHref: "/other_base/link" });
2608
- // initService({ html5Mode: false });
2609
- // inject(
2610
- // initBrowser({
2611
- // url: "http://host.com/base/index.html",
2612
- // basePath: "/base/index.html",
2613
- // }),
2614
- // setupRewriteChecks(),
2615
- // ($browser) => {
2616
- // browserTrigger(link, "click");
2617
- // expectNoRewrite($browser);
2618
- // },
2619
- // );
2620
- // });
2621
-
2622
- // it("should not rewrite when full link to different base path when history enabled on new browser", () => {
2623
- // configureTestLink({ linkHref: "http://host.com/other_base/link" });
2624
- // initService({ html5Mode: true, supportHistory: true });
2625
- // inject(
2626
- // initBrowser({
2627
- // url: "http://host.com/base/index.html",
2628
- // basePath: "/base/index.html",
2629
- // }),
2630
- // setupRewriteChecks(),
2631
- // ($browser) => {
2632
- // browserTrigger(link, "click");
2633
- // expectNoRewrite($browser);
2634
- // },
2635
- // );
2636
- // });
2637
-
2638
- // it("should not rewrite when full link to different base path when history enabled on old browser", () => {
2639
- // configureTestLink({ linkHref: "http://host.com/other_base/link" });
2640
- // inject(
2641
- // initBrowser({
2642
- // url: "http://host.com/base/index.html",
2643
- // basePath: "/base/index.html",
2644
- // }),
2645
- // setupRewriteChecks(),
2646
- // ($browser) => {
2647
- // browserTrigger(link, "click");
2648
- // expectNoRewrite($browser);
2649
- // },
2650
- // );
2651
- // });
2652
-
2653
- // it("should not rewrite when full link to different base path when history disabled", () => {
2654
- // configureTestLink({ linkHref: "http://host.com/other_base/link" });
2655
- // initService({ html5Mode: false });
2656
- // inject(
2657
- // initBrowser({
2658
- // url: "http://host.com/base/index.html",
2659
- // basePath: "/base/index.html",
2660
- // }),
2661
- // setupRewriteChecks(),
2662
- // ($browser) => {
2663
- // browserTrigger(link, "click");
2664
- // expectNoRewrite($browser);
2665
- // },
2666
- // );
2667
- // });
2668
-
2669
- // it('should replace current hash fragment when link begins with "#" history disabled', () => {
2670
- // configureTestLink({ linkHref: "#link", relLink: true });
2671
- // initService({ html5Mode: true, supportHistory: false, hashPrefix: "!" });
2672
- // inject(
2673
- // initBrowser({
2674
- // url: "http://host.com/base/index.html",
2675
- // basePath: "/base/index.html",
2676
- // }),
2677
- // setupRewriteChecks(),
2678
- // ($browser, $location, $rootScope) => {
2679
- // $rootScope.$apply(() => {
2680
- // $location.setPath("/some");
2681
- // $location.setHash("foo");
2682
- // });
2683
- // browserTrigger(link, "click");
2684
- // expect($location.getHash()).toBe("link");
2685
- // expectRewriteTo(
2686
- // $browser,
2687
- // "http://host.com/base/index.html#!/some#link",
2688
- // );
2689
- // },
2690
- // );
2691
- // });
2692
-
2693
- // it('should replace current hash fragment when link begins with "#" history enabled', () => {
2694
- // configureTestLink({ linkHref: "#link", relLink: true });
2695
- // initService({ html5Mode: true, supportHistory: true });
2696
- // inject(
2697
- // initBrowser({
2698
- // url: "http://host.com/base/index.html",
2699
- // basePath: "/base/index.html",
2700
- // }),
2701
- // setupRewriteChecks(),
2702
- // ($browser, $location, $rootScope) => {
2703
- // $rootScope.$apply(() => {
2704
- // $location.setPath("/some");
2705
- // $location.setHash("foo");
2706
- // });
2707
- // browserTrigger(link, "click");
2708
- // expect($location.getHash()).toBe("link");
2709
- // expectRewriteTo($browser, "http://host.com/base/some#link");
2710
- // },
2711
- // );
2712
- // });
2713
-
2714
- // it("should not rewrite when clicked with ctrl pressed", () => {
2715
- // configureTestLink({ linkHref: "base/a?b=c" });
2716
- // initService({ html5Mode: true, supportHistory: true });
2717
- // inject(
2718
- // initBrowser({
2719
- // url: "http://host.com/base/index.html",
2720
- // basePath: "/base/index.html",
2721
- // }),
2722
- // setupRewriteChecks(),
2723
- // ($browser) => {
2724
- // browserTrigger(link, "click", { keys: ["ctrl"] });
2725
- // expectNoRewrite($browser);
2726
- // },
2727
- // );
2728
- // });
2729
-
2730
- // it("should not rewrite when clicked with meta pressed", () => {
2731
- // configureTestLink({ linkHref: "base/a?b=c" });
2732
- // initService({ html5Mode: true, supportHistory: true });
2733
- // inject(
2734
- // initBrowser({
2735
- // url: "http://host.com/base/index.html",
2736
- // basePath: "/base/index.html",
2737
- // }),
2738
- // setupRewriteChecks(),
2739
- // ($browser) => {
2740
- // browserTrigger(link, "click", { keys: ["meta"] });
2741
- // expectNoRewrite($browser);
2742
- // },
2743
- // );
2744
- // });
2745
-
2746
- // it("should not rewrite when right click pressed", () => {
2747
- // configureTestLink({ linkHref: "base/a?b=c" });
2748
- // initService({ html5Mode: true, supportHistory: true });
2749
- // inject(
2750
- // initBrowser({
2751
- // url: "http://host.com/base/index.html",
2752
- // basePath: "/base/index.html",
2753
- // }),
2754
- // setupRewriteChecks(),
2755
- // ($browser) => {
2756
- // const rightClick = document.createEvent("MouseEvents");
2757
- // rightClick.initMouseEvent(
2758
- // "click",
2759
- // true,
2760
- // true,
2761
- // window,
2762
- // 1,
2763
- // 10,
2764
- // 10,
2765
- // 10,
2766
- // 10,
2767
- // false,
2768
- // false,
2769
- // false,
2770
- // false,
2771
- // 2,
2772
- // null,
2773
- // );
2774
-
2775
- // link.dispatchEvent(rightClick);
2776
- // expectNoRewrite($browser);
2777
- // },
2778
- // );
2779
- // });
2780
-
2781
- // it("should not rewrite when clicked with shift pressed", () => {
2782
- // configureTestLink({ linkHref: "base/a?b=c" });
2783
- // initService({ html5Mode: true, supportHistory: true });
2784
- // inject(
2785
- // initBrowser({
2786
- // url: "http://host.com/base/index.html",
2787
- // basePath: "/base/index.html",
2788
- // }),
2789
- // setupRewriteChecks(),
2790
- // ($browser) => {
2791
- // browserTrigger(link, "click", { keys: ["shift"] });
2792
- // expectNoRewrite($browser);
2793
- // },
2794
- // );
2795
- // });
2796
-
2797
- // it("should not mess up hash urls when clicking on links in hashbang mode", () => {
2798
- // let base;
2799
- // module(
2800
- // () =>
2801
- // function ($browser) {
2802
- // window.location.hash = "someHash";
2803
- // base = window.location.href;
2804
- // $browser.url(base);
2805
- // base = base.split("#")[0];
2806
- // },
2807
- // );
2808
- // inject(
2809
- // (
2810
- // $rootScope,
2811
- // $compile,
2812
- // $browser,
2813
- // $rootElement,
2814
- //
2815
- // $location,
2816
- // ) => {
2817
- // // we need to do this otherwise we can't simulate events
2818
- // $document.querySelector("body").append($rootElement);
2819
-
2820
- // const element = $compile(
2821
- // '<a href="#!/view1">v1</a><a href="#!/view2">v2</a>',
2822
- // )($rootScope);
2823
- // $rootElement.append(element);
2824
- // const av1 = $rootElement.querySelector("a")[0];
2825
- // const av2 = $rootElement.querySelector("a")[1];
2826
-
2827
- // browserTrigger(av1, "click");
2828
- // expect($browser.url()).toEqual(`${base}#!/view1`);
2829
-
2830
- // browserTrigger(av2, "click");
2831
- // expect($browser.url()).toEqual(`${base}#!/view2`);
2832
-
2833
- // $rootElement.remove();
2834
- // },
2835
- // );
2836
- // });
2837
-
2838
- // it("should not mess up hash urls when clicking on links in hashbang mode with a prefix", () => {
2839
- // let base;
2840
- // module(
2841
- // ($locationProvider) =>
2842
- // function ($browser) {
2843
- // window.location.hash = "!!someHash";
2844
- // $browser.url((base = window.location.href));
2845
- // base = base.split("#")[0];
2846
- // $locationProvider.hashPrefix("!!");
2847
- // },
2848
- // );
2849
- // inject(
2850
- // (
2851
- // $rootScope,
2852
- // $compile,
2853
- // $browser,
2854
- // $rootElement,
2855
- //
2856
- // $location,
2857
- // ) => {
2858
- // // we need to do this otherwise we can't simulate events
2859
- // $document.querySelector("body").append($rootElement);
2860
-
2861
- // const element = $compile(
2862
- // '<a href="#!!/view1">v1</a><a href="#!!/view2">v2</a>',
2863
- // )($rootScope);
2864
- // $rootElement.append(element);
2865
- // const av1 = $rootElement.querySelector("a")[0];
2866
- // const av2 = $rootElement.querySelector("a")[1];
2867
-
2868
- // browserTrigger(av1, "click");
2869
- // expect($browser.url()).toEqual(`${base}#!!/view1`);
2870
-
2871
- // browserTrigger(av2, "click");
2872
- // expect($browser.url()).toEqual(`${base}#!!/view2`);
2873
- // },
2874
- // );
2875
- // });
2876
-
2877
- // it("should not intercept clicks outside the current hash prefix", () => {
2878
- // let base;
2879
- // let clickHandler;
2880
- // module(($provide) => {
2881
- // $provide.value("$rootElement", {
2882
- // on(event, handler) {
2883
- // expect(event).toEqual("click");
2884
- // clickHandler = handler;
2885
- // },
2886
- // off: () => {},
2887
- // });
2888
- // return function ($browser) {
2889
- // $browser.url((base = "http://server/"));
2890
- // };
2891
- // });
2892
- // inject(($location) => {
2893
- // // make IE happy
2894
- // (document.body).html(
2895
- // '<a href="http://server/test.html">link</a>',
2896
- // );
2897
-
2898
- // const event = {
2899
- // target: (document.body).querySelector("a")[0],
2900
- // preventDefault: jasmine.createSpy("preventDefault"),
2901
- // isDefaultPrevented: jasmine.createSpy().and.returnValue(false),
2902
- // };
2903
-
2904
- // clickHandler(event);
2905
- // expect(event.preventDefault).not.toHaveBeenCalled();
2906
- // });
2907
- // });
2908
-
2909
- // it("should not intercept hash link clicks outside the app base url space", () => {
2910
- // let base;
2911
- // let clickHandler;
2912
- // module(($provide) => {
2913
- // $provide.value("$rootElement", {
2914
- // on(event, handler) {
2915
- // expect(event).toEqual("click");
2916
- // clickHandler = handler;
2917
- // },
2918
- // off: () => {},
2919
- // });
2920
- // return function ($browser) {
2921
- // $browser.url((base = "http://server/"));
2922
- // };
2923
- // });
2924
- // inject(
2925
- // (
2926
- // $rootScope,
2927
- // $compile,
2928
- // $browser,
2929
- // $rootElement,
2930
- //
2931
- // $location,
2932
- // ) => {
2933
- // // make IE happy
2934
- // (document.body).html(
2935
- // '<a href="http://server/index.html#test">link</a>',
2936
- // );
2937
-
2938
- // const event = {
2939
- // target: (document.body).querySelector("a")[0],
2940
- // preventDefault: jasmine.createSpy("preventDefault"),
2941
- // isDefaultPrevented: jasmine.createSpy().and.returnValue(false),
2942
- // };
2943
-
2944
- // clickHandler(event);
2945
- // expect(event.preventDefault).not.toHaveBeenCalled();
2946
- // },
2947
- // );
2948
- // });
2949
-
2950
- // // regression https://github.com/angular/angular.js/issues/1058
2951
- // it("should not throw if element was removed", inject((
2952
- //
2953
- // $rootElement,
2954
- // $location,
2955
- // ) => {
2956
- // // we need to do this otherwise we can't simulate events
2957
- // $document.querySelector("body").append($rootElement);
2958
-
2959
- // $rootElement.html("<button></button>");
2960
- // const button = $rootElement.querySelector("button");
2961
-
2962
- // button.on("click", () => {
2963
- // button.remove();
2964
- // });
2965
- // browserTrigger(button, "click");
2966
- // }));
2967
-
2968
- // it("should not throw when clicking an SVGAElement link", () => {
2969
- // let base;
2970
- // module(
2971
- // ($locationProvider) =>
2972
- // function ($browser) {
2973
- // window.location.hash = "!someHash";
2974
- // $browser.url((base = window.location.href));
2975
- // base = base.split("#")[0];
2976
- // $locationProvider.hashPrefix("!");
2977
- // },
2978
- // );
2979
- // inject(
2980
- // (
2981
- // $rootScope,
2982
- // $compile,
2983
- // $browser,
2984
- // $rootElement,
2985
- //
2986
- // $location,
2987
- // ) => {
2988
- // // we need to do this otherwise we can't simulate events
2989
- // $document.querySelector("body").append($rootElement);
2990
- // const template =
2991
- // '<svg><g><a xlink:href="#!/view1"><circle r="50"></circle></a></g></svg>';
2992
- // const element = $compile(template)($rootScope);
2993
-
2994
- // $rootElement.append(element);
2995
- // const av1 = $rootElement.querySelector("a")[0];
2996
- // expect(() => {
2997
- // browserTrigger(av1, "click");
2998
- // }).not.toThrow();
2999
- // },
3000
- // );
3001
- // });
3002
- // });
3003
-
3004
- // describe("location cancellation", () => {
3005
- // it("should fire $before/afterLocationChange event", inject((
3006
- // $location,
3007
- // $browser,
3008
- // $rootScope,
3009
- // $log,
3010
- // ) => {
3011
- // expect($browser.url()).toEqual("http://server/");
3012
-
3013
- // $rootScope.$on("$locationChangeStart", (event, newUrl, oldUrl) => {
3014
- // $log.info("before", newUrl, oldUrl, $browser.url());
3015
- // });
3016
- // $rootScope.$on("$locationChangeSuccess", (event, newUrl, oldUrl) => {
3017
- // $log.info("after", newUrl, oldUrl, $browser.url());
3018
- // });
3019
-
3020
- // expect($location.getUrl()).toEqual("");
3021
- // $location.setUrl("/somePath");
3022
- // expect($location.getUrl()).toEqual("/somePath");
3023
- // expect($browser.url()).toEqual("http://server/");
3024
- // expect($log.info.logs).toEqual([]);
3025
-
3026
- // $rootScope.$apply();
3027
-
3028
- // expect($log.info.logs.shift()).toEqual([
3029
- // "before",
3030
- // "http://server/#!/somePath",
3031
- // "http://server/",
3032
- // "http://server/",
3033
- // ]);
3034
- // expect($log.info.logs.shift()).toEqual([
3035
- // "after",
3036
- // "http://server/#!/somePath",
3037
- // "http://server/",
3038
- // "http://server/#!/somePath",
3039
- // ]);
3040
- // expect($location.getUrl()).toEqual("/somePath");
3041
- // expect($browser.url()).toEqual("http://server/#!/somePath");
3042
- // }));
3043
-
3044
- // it("should allow $locationChangeStart event cancellation", inject((
3045
- // $location,
3046
- // $browser,
3047
- // $rootScope,
3048
- // $log,
3049
- // ) => {
3050
- // expect($browser.url()).toEqual("http://server/");
3051
- // expect($location.getUrl()).toEqual("");
3052
-
3053
- // $rootScope.$on("$locationChangeStart", (event, newUrl, oldUrl) => {
3054
- // $log.info("before", newUrl, oldUrl, $browser.url());
3055
- // event.preventDefault();
3056
- // });
3057
- // $rootScope.$on("$locationChangeSuccess", (event, newUrl, oldUrl) => {
3058
- // throw new Error("location should have been canceled");
3059
- // });
3060
-
3061
- // expect($location.getUrl()).toEqual("");
3062
- // $location.setUrl("/somePath");
3063
- // expect($location.getUrl()).toEqual("/somePath");
3064
- // expect($browser.url()).toEqual("http://server/");
3065
- // expect($log.info.logs).toEqual([]);
3066
-
3067
- // $rootScope.$apply();
3068
-
3069
- // expect($log.info.logs.shift()).toEqual([
3070
- // "before",
3071
- // "http://server/#!/somePath",
3072
- // "http://server/",
3073
- // "http://server/",
3074
- // ]);
3075
- // expect($log.info.logs[1]).toBeUndefined();
3076
- // expect($location.getUrl()).toEqual("");
3077
- // expect($browser.url()).toEqual("http://server/");
3078
- // }));
3079
-
3080
- // it("should allow redirect during $locationChangeStart", inject((
3081
- // $location,
3082
- // $browser,
3083
- // $rootScope,
3084
- // $log,
3085
- // ) => {
3086
- // $rootScope.$on("$locationChangeStart", (event, newUrl, oldUrl) => {
3087
- // $log.info("before", newUrl, oldUrl, $browser.url());
3088
- // if (newUrl === "http://server/#!/somePath") {
3089
- // $location.setUrl("/redirectPath");
3090
- // }
3091
- // });
3092
- // $rootScope.$on("$locationChangeSuccess", (event, newUrl, oldUrl) => {
3093
- // $log.info("after", newUrl, oldUrl, $browser.url());
3094
- // });
3095
-
3096
- // $location.setUrl("/somePath");
3097
- // $rootScope.$apply();
3098
-
3099
- // expect($log.info.logs.shift()).toEqual([
3100
- // "before",
3101
- // "http://server/#!/somePath",
3102
- // "http://server/",
3103
- // "http://server/",
3104
- // ]);
3105
- // expect($log.info.logs.shift()).toEqual([
3106
- // "before",
3107
- // "http://server/#!/redirectPath",
3108
- // "http://server/",
3109
- // "http://server/",
3110
- // ]);
3111
- // expect($log.info.logs.shift()).toEqual([
3112
- // "after",
3113
- // "http://server/#!/redirectPath",
3114
- // "http://server/",
3115
- // "http://server/#!/redirectPath",
3116
- // ]);
3117
-
3118
- // expect($location.getUrl()).toEqual("/redirectPath");
3119
- // expect($browser.url()).toEqual("http://server/#!/redirectPath");
3120
- // }));
3121
-
3122
- // it("should allow redirect during $locationChangeStart even if default prevented", inject((
3123
- // $location,
3124
- // $browser,
3125
- // $rootScope,
3126
- // $log,
3127
- // ) => {
3128
- // $rootScope.$on("$locationChangeStart", (event, newUrl, oldUrl) => {
3129
- // $log.info("before", newUrl, oldUrl, $browser.url());
3130
- // if (newUrl === "http://server/#!/somePath") {
3131
- // event.preventDefault();
3132
- // $location.setUrl("/redirectPath");
3133
- // }
3134
- // });
3135
- // $rootScope.$on("$locationChangeSuccess", (event, newUrl, oldUrl) => {
3136
- // $log.info("after", newUrl, oldUrl, $browser.url());
3137
- // });
3138
-
3139
- // $location.setUrl("/somePath");
3140
- // $rootScope.$apply();
3141
-
3142
- // expect($log.info.logs.shift()).toEqual([
3143
- // "before",
3144
- // "http://server/#!/somePath",
3145
- // "http://server/",
3146
- // "http://server/",
3147
- // ]);
3148
- // expect($log.info.logs.shift()).toEqual([
3149
- // "before",
3150
- // "http://server/#!/redirectPath",
3151
- // "http://server/",
3152
- // "http://server/",
3153
- // ]);
3154
- // expect($log.info.logs.shift()).toEqual([
3155
- // "after",
3156
- // "http://server/#!/redirectPath",
3157
- // "http://server/",
3158
- // "http://server/#!/redirectPath",
3159
- // ]);
3160
-
3161
- // expect($location.getUrl()).toEqual("/redirectPath");
3162
- // expect($browser.url()).toEqual("http://server/#!/redirectPath");
3163
- // }));
3164
-
3165
- // it("should allow multiple redirect during $locationChangeStart", inject((
3166
- // $location,
3167
- // $browser,
3168
- // $rootScope,
3169
- // $log,
3170
- // ) => {
3171
- // $rootScope.$on("$locationChangeStart", (event, newUrl, oldUrl) => {
3172
- // $log.info("before", newUrl, oldUrl, $browser.url());
3173
- // if (newUrl === "http://server/#!/somePath") {
3174
- // $location.setUrl("/redirectPath");
3175
- // } else if (newUrl === "http://server/#!/redirectPath") {
3176
- // $location.setUrl("/redirectPath2");
3177
- // }
3178
- // });
3179
- // $rootScope.$on("$locationChangeSuccess", (event, newUrl, oldUrl) => {
3180
- // $log.info("after", newUrl, oldUrl, $browser.url());
3181
- // });
3182
-
3183
- // $location.setUrl("/somePath");
3184
- // $rootScope.$apply();
3185
-
3186
- // expect($log.info.logs.shift()).toEqual([
3187
- // "before",
3188
- // "http://server/#!/somePath",
3189
- // "http://server/",
3190
- // "http://server/",
3191
- // ]);
3192
- // expect($log.info.logs.shift()).toEqual([
3193
- // "before",
3194
- // "http://server/#!/redirectPath",
3195
- // "http://server/",
3196
- // "http://server/",
3197
- // ]);
3198
- // expect($log.info.logs.shift()).toEqual([
3199
- // "before",
3200
- // "http://server/#!/redirectPath2",
3201
- // "http://server/",
3202
- // "http://server/",
3203
- // ]);
3204
- // expect($log.info.logs.shift()).toEqual([
3205
- // "after",
3206
- // "http://server/#!/redirectPath2",
3207
- // "http://server/",
3208
- // "http://server/#!/redirectPath2",
3209
- // ]);
3210
-
3211
- // expect($location.getUrl()).toEqual("/redirectPath2");
3212
- // expect($browser.url()).toEqual("http://server/#!/redirectPath2");
3213
- // }));
3214
-
3215
- // it("should fire $locationChangeSuccess event when change from browser location bar", inject((
3216
- // $log,
3217
- // $location,
3218
- // $browser,
3219
- // $rootScope,
3220
- // ) => {
3221
- // $rootScope.$apply(); // clear initial $locationChangeStart
3222
-
3223
- // expect($browser.url()).toEqual("http://server/");
3224
- // expect($location.getUrl()).toEqual("");
3225
-
3226
- // $rootScope.$on("$locationChangeStart", (event, newUrl, oldUrl) => {
3227
- // $log.info("start", newUrl, oldUrl);
3228
- // });
3229
- // $rootScope.$on("$locationChangeSuccess", (event, newUrl, oldUrl) => {
3230
- // $log.info("after", newUrl, oldUrl);
3231
- // });
3232
-
3233
- // $browser.url("http://server/#!/somePath");
3234
- // $browser.poll();
3235
-
3236
- // expect($log.info.logs.shift()).toEqual([
3237
- // "start",
3238
- // "http://server/#!/somePath",
3239
- // "http://server/",
3240
- // ]);
3241
- // expect($log.info.logs.shift()).toEqual([
3242
- // "after",
3243
- // "http://server/#!/somePath",
3244
- // "http://server/",
3245
- // ]);
3246
- // }));
3247
-
3248
- // it("should fire $locationChangeSuccess when browser location changes to URL which ends with #", inject((
3249
- // $location,
3250
- // $browser,
3251
- // $rootScope,
3252
- // $log,
3253
- // ) => {
3254
- // $location.setUrl("/somepath");
3255
- // $rootScope.$apply();
3256
-
3257
- // expect($browser.url()).toEqual("http://server/#!/somepath");
3258
- // expect($location.getUrl()).toEqual("/somepath");
3259
-
3260
- // $rootScope.$on("$locationChangeStart", (event, newUrl, oldUrl) => {
3261
- // $log.info("start", newUrl, oldUrl);
3262
- // });
3263
- // $rootScope.$on("$locationChangeSuccess", (event, newUrl, oldUrl) => {
3264
- // $log.info("after", newUrl, oldUrl);
3265
- // });
3266
-
3267
- // $browser.url("http://server/#");
3268
- // $browser.poll();
3269
-
3270
- // expect($log.info.logs.shift()).toEqual([
3271
- // "start",
3272
- // "http://server/",
3273
- // "http://server/#!/somepath",
3274
- // ]);
3275
- // expect($log.info.logs.shift()).toEqual([
3276
- // "after",
3277
- // "http://server/",
3278
- // "http://server/#!/somepath",
3279
- // ]);
3280
- // }));
3281
-
3282
- // it("should allow redirect during browser url change", inject((
3283
- // $location,
3284
- // $browser,
3285
- // $rootScope,
3286
- // $log,
3287
- // ) => {
3288
- // $rootScope.$on("$locationChangeStart", (event, newUrl, oldUrl) => {
3289
- // $log.info("before", newUrl, oldUrl, $browser.url());
3290
- // if (newUrl === "http://server/#!/somePath") {
3291
- // $location.setUrl("/redirectPath");
3292
- // }
3293
- // });
3294
- // $rootScope.$on("$locationChangeSuccess", (event, newUrl, oldUrl) => {
3295
- // $log.info("after", newUrl, oldUrl, $browser.url());
3296
- // });
3297
-
3298
- // $browser.url("http://server/#!/somePath");
3299
- // $browser.poll();
3300
-
3301
- // expect($log.info.logs.shift()).toEqual([
3302
- // "before",
3303
- // "http://server/#!/somePath",
3304
- // "http://server/",
3305
- // "http://server/#!/somePath",
3306
- // ]);
3307
- // expect($log.info.logs.shift()).toEqual([
3308
- // "before",
3309
- // "http://server/#!/redirectPath",
3310
- // "http://server/#!/somePath",
3311
- // "http://server/#!/somePath",
3312
- // ]);
3313
- // expect($log.info.logs.shift()).toEqual([
3314
- // "after",
3315
- // "http://server/#!/redirectPath",
3316
- // "http://server/#!/somePath",
3317
- // "http://server/#!/redirectPath",
3318
- // ]);
3319
-
3320
- // expect($location.getUrl()).toEqual("/redirectPath");
3321
- // expect($browser.url()).toEqual("http://server/#!/redirectPath");
3322
- // }));
3323
-
3324
- // it("should allow redirect during browser url change even if default prevented", inject((
3325
- // $location,
3326
- // $browser,
3327
- // $rootScope,
3328
- // $log,
3329
- // ) => {
3330
- // $rootScope.$on("$locationChangeStart", (event, newUrl, oldUrl) => {
3331
- // $log.info("before", newUrl, oldUrl, $browser.url());
3332
- // if (newUrl === "http://server/#!/somePath") {
3333
- // event.preventDefault();
3334
- // $location.setUrl("/redirectPath");
3335
- // }
3336
- // });
3337
- // $rootScope.$on("$locationChangeSuccess", (event, newUrl, oldUrl) => {
3338
- // $log.info("after", newUrl, oldUrl, $browser.url());
3339
- // });
3340
-
3341
- // $browser.url("http://server/#!/somePath");
3342
- // $browser.poll();
3343
-
3344
- // expect($log.info.logs.shift()).toEqual([
3345
- // "before",
3346
- // "http://server/#!/somePath",
3347
- // "http://server/",
3348
- // "http://server/#!/somePath",
3349
- // ]);
3350
- // expect($log.info.logs.shift()).toEqual([
3351
- // "before",
3352
- // "http://server/#!/redirectPath",
3353
- // "http://server/#!/somePath",
3354
- // "http://server/#!/somePath",
3355
- // ]);
3356
- // expect($log.info.logs.shift()).toEqual([
3357
- // "after",
3358
- // "http://server/#!/redirectPath",
3359
- // "http://server/#!/somePath",
3360
- // "http://server/#!/redirectPath",
3361
- // ]);
3362
-
3363
- // expect($location.getUrl()).toEqual("/redirectPath");
3364
- // expect($browser.url()).toEqual("http://server/#!/redirectPath");
3365
- // }));
3366
-
3367
- // it("should listen on click events on href and prevent browser default in hashbang mode", () => {
3368
- // module(
3369
- // () =>
3370
- // function ($rootElement, $compile, $rootScope) {
3371
- // $rootElement.html('<a href="http://server/#!/somePath">link</a>');
3372
- // $compile($rootElement)($rootScope);
3373
- // (document.body).append($rootElement);
3374
- // },
3375
- // );
3376
-
3377
- // inject(($location, $rootScope, $browser, $rootElement) => {
3378
- // let log = "";
3379
- // const link = $rootElement.find("a");
3380
-
3381
- // $rootScope.$on("$locationChangeStart", (event) => {
3382
- // event.preventDefault();
3383
- // log += "$locationChangeStart";
3384
- // });
3385
- // $rootScope.$on("$locationChangeSuccess", () => {
3386
- // throw new Error("after cancellation in hashbang mode");
3387
- // });
3388
-
3389
- // browserTrigger(link, "click");
3390
-
3391
- // expect(log).toEqual("$locationChangeStart");
3392
- // expect($browser.url()).toEqual("http://server/");
3393
-
3394
- // dealoc($rootElement);
3395
- // });
3396
- // });
3397
-
3398
- // it("should listen on click events on href and prevent browser default in html5 mode", () => {
3399
- // module(($locationProvider, $provide) => {
3400
- // $locationProvider.setHtml5Mode(true);
3401
- // return function ($rootElement, $compile, $rootScope) {
3402
- // $rootElement.html('<a href="http://server/somePath">link</a>');
3403
- // $compile($rootElement)($rootScope);
3404
- // (document.body).append($rootElement);
3405
- // };
3406
- // });
3407
-
3408
- // inject(($location, $rootScope, $browser, $rootElement) => {
3409
- // let log = "";
3410
- // const link = $rootElement.querySelector("a");
3411
- // const browserUrlBefore = $browser.url();
3412
-
3413
- // $rootScope.$on("$locationChangeStart", (event) => {
3414
- // event.preventDefault();
3415
- // log += "$locationChangeStart";
3416
- // });
3417
- // $rootScope.$on("$locationChangeSuccess", () => {
3418
- // throw new Error("after cancellation in html5 mode");
3419
- // });
3420
-
3421
- // browserTrigger(link, "click");
3422
-
3423
- // expect(log).toEqual("$locationChangeStart");
3424
- // expect($browser.url()).toBe(browserUrlBefore);
3425
-
3426
- // dealoc($rootElement);
3427
- // });
3428
- // });
3429
-
3430
- // it("should always return the new url value via path() when $locationChangeStart event occurs regardless of cause", inject((
3431
- // $location,
3432
- // $rootScope,
3433
- // $browser,
3434
- // log,
3435
- // ) => {
3436
- // const base = $browser.url();
3437
-
3438
- // $rootScope.$on("$locationChangeStart", () => {
3439
- // log($location.getPath());
3440
- // });
3441
-
3442
- // // change through $location service
3443
- // $rootScope.$apply(() => {
3444
- // $location.setPath("/myNewPath");
3445
- // });
3446
-
3447
- // // reset location
3448
- // $rootScope.$apply(() => {
3449
- // $location.setPath("");
3450
- // });
3451
-
3452
- // // change through $browser
3453
- // $browser.url(`${base}#!/myNewPath`);
3454
- // $browser.poll();
3455
-
3456
- // expect(log).toEqual(["/myNewPath", "/", "/myNewPath"]);
3457
- // }));
3458
- // });
3459
-
3460
- describe("$locationProvider", () => {
3461
- describe("html5ModeConf", () => {
3462
- it("should have default values", () => {
3463
- module.config(($locationProvider) => {
3464
- expect($locationProvider.html5ModeConf).toEqual({
3465
- enabled: true,
3466
- requireBase: false,
3467
- rewriteLinks: true,
3468
- });
3469
- });
3470
- createInjector(["test1"]);
3471
- });
3472
- });
3473
- });
3474
-
3475
- describe("Location with html5 url", () => {
3476
- let locationUrl;
3477
- let locationUmlautUrl;
3478
- let locationIndexUrl;
3479
-
3480
- beforeEach(() => {
3481
- locationUrl = new Location("http://server/pre/", "http://server/pre/");
3482
- locationUmlautUrl = new Location(
3483
- "http://särver/pre/",
3484
- "http://särver/pre/",
3485
- );
3486
- locationIndexUrl = new Location(
3487
- "http://server/pre/index.html",
3488
- "http://server/pre/",
3489
- );
3490
- });
3491
-
3492
- it("should rewrite URL", () => {
3493
- expect(parseLinkAndReturn(locationUrl, "http://other")).toEqual(
3494
- undefined,
3495
- );
3496
- expect(parseLinkAndReturn(locationUrl, "http://server/pre")).toEqual(
3497
- "http://server/pre/",
3498
- );
3499
- expect(parseLinkAndReturn(locationUrl, "http://server/pre/")).toEqual(
3500
- "http://server/pre/",
3501
- );
3502
- expect(
3503
- parseLinkAndReturn(locationUrl, "http://server/pre/otherPath"),
3504
- ).toEqual("http://server/pre/otherPath");
3505
- // Note: relies on the previous state!
3506
- expect(
3507
- parseLinkAndReturn(locationUrl, "someIgnoredAbsoluteHref", "#test"),
3508
- ).toEqual("http://server/pre/otherPath#test");
3509
-
3510
- expect(parseLinkAndReturn(locationUmlautUrl, "http://other")).toEqual(
3511
- undefined,
3512
- );
3513
- expect(
3514
- parseLinkAndReturn(locationUmlautUrl, "http://särver/pre"),
3515
- ).toEqual("http://särver/pre/");
3516
- expect(
3517
- parseLinkAndReturn(locationUmlautUrl, "http://särver/pre/"),
3518
- ).toEqual("http://särver/pre/");
3519
- expect(
3520
- parseLinkAndReturn(locationUmlautUrl, "http://särver/pre/otherPath"),
3521
- ).toEqual("http://särver/pre/otherPath");
3522
- // Note: relies on the previous state!
3523
- expect(
3524
- parseLinkAndReturn(
3525
- locationUmlautUrl,
3526
- "someIgnoredAbsoluteHref",
3527
- "#test",
3528
- ),
3529
- ).toEqual("http://särver/pre/otherPath#test");
3530
-
3531
- expect(parseLinkAndReturn(locationIndexUrl, "http://server/pre")).toEqual(
3532
- "http://server/pre/",
3533
- );
3534
- expect(
3535
- parseLinkAndReturn(locationIndexUrl, "http://server/pre/"),
3536
- ).toEqual("http://server/pre/");
3537
- expect(
3538
- parseLinkAndReturn(locationIndexUrl, "http://server/pre/otherPath"),
3539
- ).toEqual("http://server/pre/otherPath");
3540
- // Note: relies on the previous state!
3541
- expect(
3542
- parseLinkAndReturn(locationUrl, "someIgnoredAbsoluteHref", "#test"),
3543
- ).toEqual("http://server/pre/otherPath#test");
3544
- });
3545
-
3546
- it("should complain if the path starts with double slashes", () => {
3547
- expect(() => {
3548
- parseLinkAndReturn(locationUrl, "http://server/pre///other/path");
3549
- }).toThrowError(/badpath/);
3550
-
3551
- expect(() => {
3552
- parseLinkAndReturn(locationUrl, "http://server/pre/\\\\other/path");
3553
- }).toThrowError(/badpath/);
3554
-
3555
- expect(() => {
3556
- parseLinkAndReturn(locationUrl, "http://server/pre//\\//other/path");
3557
- }).toThrowError(/badpath/);
3558
- });
3559
-
3560
- // it("should complain if no base tag present", () => {
3561
- // let module = window.angular.module("test1", ["ng"]);
3562
- // module.config((_$locationProvider_) => {
3563
- // $locationProvider.setHtml5Mode(true);
3564
- // });
3565
-
3566
- // createInjector(["test1"]).invoke(($browser, $injector) => {
3567
- // $browser.$$baseHref = undefined;
3568
- // expect(() => {
3569
- // $injector.get("$location");
3570
- // }).toThrowError(/nobase/);
3571
- // });
3572
- // });
3573
-
3574
- // it("should not complain if baseOptOut set to true in html5Mode", () => {
3575
- // module.config(($locationProvider) => {
3576
- // $locationProvider.setHtml5Mode({
3577
- // enabled: true,
3578
- // requireBase: false,
3579
- // });
3580
- // });
3581
-
3582
- // inject(($browser, $injector) => {
3583
- // $browser.$$baseHref = undefined;
3584
- // expect(() => {
3585
- // $injector.get("$location");
3586
- // }).not.toThrow(
3587
- // "$location",
3588
- // "nobase",
3589
- // "$location in HTML5 mode requires a <base> tag to be present!",
3590
- // );
3591
- // });
3592
- // });
3593
-
3594
- it("should support state", () => {
3595
- expect(locationUrl.setState({ a: 2 }).getState()).toEqual({ a: 2 });
3596
- });
3597
- });
3598
-
3599
- describe("Location with hashbang url", () => {
3600
- let locationUrl;
3601
-
3602
- it("should rewrite URL", () => {
3603
- locationUrl = new Location(
3604
- "http://server/pre/",
3605
- "http://server/pre/",
3606
- false,
3607
- "#",
3608
- );
3609
-
3610
- expect(parseLinkAndReturn(locationUrl, "http://other")).toEqual(
3611
- undefined,
3612
- );
3613
- expect(parseLinkAndReturn(locationUrl, "http://server/pre/")).toEqual(
3614
- "http://server/pre/",
3615
- );
3616
- expect(
3617
- parseLinkAndReturn(locationUrl, "http://server/pre/#otherPath"),
3618
- ).toEqual("http://server/pre/#/otherPath");
3619
-
3620
- expect(parseLinkAndReturn(locationUrl, "javascript:void(0)")).toEqual(
3621
- undefined,
3622
- );
3623
- });
3624
-
3625
- it("should not set hash if one was not originally specified", () => {
3626
- locationUrl = new Location(
3627
- "http://server/pre/index.html",
3628
- "http://server/pre/",
3629
- false,
3630
- "#",
3631
- );
3632
-
3633
- locationUrl.parse("http://server/pre/index.html");
3634
- expect(locationUrl.getUrl()).toBe("");
3635
- expect(locationUrl.absUrl).toBe("http://server/pre/index.html");
3636
- });
3637
-
3638
- it("should parse hash if one was specified", () => {
3639
- locationUrl = new Location(
3640
- "http://server/pre/index.html",
3641
- "http://server/pre/",
3642
- false,
3643
- "#",
3644
- );
3645
-
3646
- locationUrl.parse("http://server/pre/index.html#/foo/bar");
3647
- expect(locationUrl.getUrl()).toBe("/foo/bar");
3648
- expect(locationUrl.absUrl).toBe("http://server/pre/index.html#/foo/bar");
3649
- });
3650
-
3651
- it("should prefix hash url with / if one was originally missing", () => {
3652
- locationUrl = new Location(
3653
- "http://server/pre/index.html",
3654
- "http://server/pre/",
3655
- false,
3656
- "#",
3657
- );
3658
-
3659
- locationUrl.parse("http://server/pre/index.html#not-starting-with-slash");
3660
- expect(locationUrl.getUrl()).toBe("/not-starting-with-slash");
3661
- expect(locationUrl.absUrl).toBe(
3662
- "http://server/pre/index.html#/not-starting-with-slash",
3663
- );
3664
- });
3665
-
3666
- it("should not strip stuff from path just because it looks like Windows drive when it's not", () => {
3667
- locationUrl = new Location(
3668
- "http://server/pre/index.html",
3669
- "http://server/pre/",
3670
- false,
3671
- "#",
3672
- );
3673
-
3674
- locationUrl.parse(
3675
- "http://server/pre/index.html#http%3A%2F%2Fexample.com%2F",
3676
- );
3677
- expect(locationUrl.getUrl()).toBe("/http://example.com/");
3678
- expect(locationUrl.absUrl).toBe(
3679
- "http://server/pre/index.html#/http://example.com/",
3680
- );
3681
- });
3682
-
3683
- it("should allow navigating outside the original base URL", () => {
3684
- locationUrl = new Location(
3685
- "http://server/pre/index.html",
3686
- "http://server/pre/",
3687
- false,
3688
- "#",
3689
- );
3690
-
3691
- locationUrl.parse("http://server/next/index.html");
3692
- expect(locationUrl.getUrl()).toBe("");
3693
- expect(locationUrl.absUrl).toBe("http://server/next/index.html");
3694
- });
3695
- });
3696
-
3697
- // function mockUpBrowser(options) {
3698
- // module(($windowProvider, $browserProvider) => {
3699
- // let browser;
3700
- // const parser = document.createElement("a");
3701
- // parser.href = options.initialUrl;
3702
-
3703
- // $windowProvider.$get = () => {
3704
- // const win = {};
3705
- // angular.extend(win, window);
3706
- // // Ensure `window` is a reference to the mock global object, so that
3707
- // // JQLite does the right thing.
3708
- // win.window = win;
3709
- // win.history = {
3710
- // state: options.state || null,
3711
- // replaceState(state, title, url) {
3712
- // win.history.state = copy(state);
3713
- // if (url) win.location.href = url;
3714
- // },
3715
- // pushState(state, title, url) {
3716
- // win.history.state = copy(state);
3717
- // if (url) win.location.href = url;
3718
- // },
3719
- // };
3720
- // win.addEventListener = () => {};
3721
- // win.removeEventListener = () => {};
3722
- // win.location = {
3723
- // get href() {
3724
- // return this.$$getHref();
3725
- // },
3726
- // $$getHref() {
3727
- // return parser.href;
3728
- // },
3729
- // set href(val) {
3730
- // this.$$setHref(val);
3731
- // },
3732
- // $$setHref(val) {
3733
- // parser.href = val;
3734
- // },
3735
- // get hash() {
3736
- // return parser.hash;
3737
- // },
3738
- // // The parser correctly strips on a single preceding hash character if necessary
3739
- // // before joining the fragment onto the href by a new hash character
3740
- // // See hash setter spec: https://url.spec.whatwg.org/#urlutils-and-urlutilsreadonly-members
3741
- // set hash(val) {
3742
- // parser.hash = val;
3743
- // },
3744
-
3745
- // replace(val) {
3746
- // win.location.href = val;
3747
- // },
3748
- // };
3749
- // return win;
3750
- // };
3751
- // $browserProvider.$get = function (
3752
- //
3753
- // $window,
3754
- // $log,
3755
- // $sniffer,
3756
- // $$taskTrackerFactory,
3757
- // ) {
3758
- // browser = new Browser(
3759
- // $window,
3760
- //
3761
- // $log,
3762
- // $sniffer,
3763
- // $$taskTrackerFactory,
3764
- // );
3765
- // browser.baseHref = () => {
3766
- // return options.baseHref;
3767
- // };
3768
- // return browser;
3769
- // };
3770
- // });
3771
- // }
3772
-
3773
- function initBrowser(options) {
3774
- return function ($browser) {
3775
- $browser.url(options.url);
3776
- $browser.$$baseHref = options.basePath;
3777
- };
3778
- }
3779
-
3780
- function expectThrowOnStateChange(location) {
3781
- expect(() => {
3782
- location.state({ a: 2 });
3783
- }).toThrowError(/nostate/);
3784
- }
3785
-
3786
- function parseLinkAndReturn(location, url, relHref) {
3787
- if (location.parseLinkUrl(url, relHref)) {
3788
- return location.absUrl;
3789
- }
3790
- return undefined;
3791
- }
3792
- });