one 1.1.473 → 1.1.475

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 (245) hide show
  1. package/dist/cjs/Root.cjs +5 -1
  2. package/dist/cjs/Root.js +2 -2
  3. package/dist/cjs/Root.js.map +1 -1
  4. package/dist/cjs/Root.native.js +5 -2
  5. package/dist/cjs/Root.native.js.map +2 -2
  6. package/dist/cjs/createApp.cjs +2 -0
  7. package/dist/cjs/createApp.js +16 -2
  8. package/dist/cjs/createApp.js.map +1 -1
  9. package/dist/cjs/createApp.native.js +1 -0
  10. package/dist/cjs/createApp.native.js.map +2 -2
  11. package/dist/cjs/fork/__tests__/getPathFromState.test.cjs +1440 -0
  12. package/dist/cjs/fork/__tests__/getPathFromState.test.js +1559 -0
  13. package/dist/cjs/fork/__tests__/getPathFromState.test.js.map +6 -0
  14. package/dist/cjs/fork/__tests__/getPathFromState.test.native.js +1726 -0
  15. package/dist/cjs/fork/__tests__/getPathFromState.test.native.js.map +6 -0
  16. package/dist/cjs/fork/__tests__/getStateFromPath.test.cjs +2565 -0
  17. package/dist/cjs/fork/__tests__/getStateFromPath.test.js +2702 -0
  18. package/dist/cjs/fork/__tests__/getStateFromPath.test.js.map +6 -0
  19. package/dist/cjs/fork/__tests__/getStateFromPath.test.native.js +2861 -0
  20. package/dist/cjs/fork/__tests__/getStateFromPath.test.native.js.map +6 -0
  21. package/dist/cjs/fork/getPathFromState.cjs +2 -1
  22. package/dist/cjs/fork/getPathFromState.js +1 -1
  23. package/dist/cjs/fork/getPathFromState.js.map +1 -1
  24. package/dist/cjs/fork/getPathFromState.native.js +10 -5
  25. package/dist/cjs/fork/getPathFromState.native.js.map +1 -1
  26. package/dist/cjs/fork/getPathFromState.test.cjs +113 -0
  27. package/dist/cjs/fork/getPathFromState.test.js +122 -0
  28. package/dist/cjs/fork/getPathFromState.test.js.map +6 -0
  29. package/dist/cjs/fork/getPathFromState.test.native.js +135 -0
  30. package/dist/cjs/fork/getPathFromState.test.native.js.map +6 -0
  31. package/dist/cjs/fork/getStateFromPath.test.cjs +229 -0
  32. package/dist/cjs/fork/getStateFromPath.test.js +290 -0
  33. package/dist/cjs/fork/getStateFromPath.test.js.map +6 -0
  34. package/dist/cjs/fork/getStateFromPath.test.native.js +374 -0
  35. package/dist/cjs/fork/getStateFromPath.test.native.js.map +6 -0
  36. package/dist/cjs/render.cjs +1 -1
  37. package/dist/cjs/render.js +1 -1
  38. package/dist/cjs/render.js.map +1 -1
  39. package/dist/cjs/router/FlagsContext.cjs +27 -0
  40. package/dist/cjs/router/FlagsContext.js +22 -0
  41. package/dist/cjs/router/FlagsContext.js.map +6 -0
  42. package/dist/cjs/router/FlagsContext.native.js +26 -0
  43. package/dist/cjs/router/FlagsContext.native.js.map +6 -0
  44. package/dist/cjs/router/getRoutes.cjs +11 -1
  45. package/dist/cjs/router/getRoutes.js +11 -1
  46. package/dist/cjs/router/getRoutes.js.map +1 -1
  47. package/dist/cjs/router/getRoutes.native.js +11 -1
  48. package/dist/cjs/router/getRoutes.native.js.map +2 -2
  49. package/dist/cjs/router/matchers.test.cjs +38 -0
  50. package/dist/cjs/router/matchers.test.js +42 -0
  51. package/dist/cjs/router/matchers.test.js.map +6 -0
  52. package/dist/cjs/router/matchers.test.native.js +39 -0
  53. package/dist/cjs/router/matchers.test.native.js.map +6 -0
  54. package/dist/cjs/router/router.cjs +3 -35
  55. package/dist/cjs/router/router.js +2 -26
  56. package/dist/cjs/router/router.js.map +1 -1
  57. package/dist/cjs/router/router.native.js +2 -33
  58. package/dist/cjs/router/router.native.js.map +2 -2
  59. package/dist/cjs/router/utils/getNavigateAction.cjs +61 -0
  60. package/dist/cjs/router/utils/getNavigateAction.js +46 -0
  61. package/dist/cjs/router/utils/getNavigateAction.js.map +6 -0
  62. package/dist/cjs/router/utils/getNavigateAction.native.js +58 -0
  63. package/dist/cjs/router/utils/getNavigateAction.native.js.map +6 -0
  64. package/dist/cjs/router/utils/getNavigateAction.test.cjs +259 -0
  65. package/dist/cjs/router/utils/getNavigateAction.test.js +295 -0
  66. package/dist/cjs/router/utils/getNavigateAction.test.js.map +6 -0
  67. package/dist/cjs/router/utils/getNavigateAction.test.native.js +330 -0
  68. package/dist/cjs/router/utils/getNavigateAction.test.native.js.map +6 -0
  69. package/dist/cjs/testing-utils.cjs +63 -0
  70. package/dist/cjs/testing-utils.js +55 -0
  71. package/dist/cjs/testing-utils.js.map +6 -0
  72. package/dist/cjs/testing-utils.native.js +79 -0
  73. package/dist/cjs/testing-utils.native.js.map +6 -0
  74. package/dist/cjs/views/Navigator.cjs +8 -1
  75. package/dist/cjs/views/Navigator.js +25 -11
  76. package/dist/cjs/views/Navigator.js.map +1 -1
  77. package/dist/cjs/views/Navigator.native.js +7 -4
  78. package/dist/cjs/views/Navigator.native.js.map +2 -2
  79. package/dist/cjs/vite/one.cjs +6 -1
  80. package/dist/cjs/vite/one.js +6 -1
  81. package/dist/cjs/vite/one.js.map +1 -1
  82. package/dist/cjs/vite/one.native.js +7 -2
  83. package/dist/cjs/vite/one.native.js.map +2 -2
  84. package/dist/cjs/vite/plugins/virtualEntryPlugin.cjs +2 -0
  85. package/dist/cjs/vite/plugins/virtualEntryPlugin.js +2 -0
  86. package/dist/cjs/vite/plugins/virtualEntryPlugin.js.map +1 -1
  87. package/dist/cjs/vite/plugins/virtualEntryPlugin.native.js +2 -0
  88. package/dist/cjs/vite/plugins/virtualEntryPlugin.native.js.map +2 -2
  89. package/dist/esm/Root.js +2 -1
  90. package/dist/esm/Root.js.map +1 -1
  91. package/dist/esm/Root.mjs +5 -1
  92. package/dist/esm/Root.mjs.map +1 -1
  93. package/dist/esm/Root.native.js +5 -1
  94. package/dist/esm/Root.native.js.map +1 -1
  95. package/dist/esm/createApp.js +16 -2
  96. package/dist/esm/createApp.js.map +1 -1
  97. package/dist/esm/createApp.mjs +2 -0
  98. package/dist/esm/createApp.mjs.map +1 -1
  99. package/dist/esm/createApp.native.js +1 -0
  100. package/dist/esm/createApp.native.js.map +1 -1
  101. package/dist/esm/fork/__tests__/getPathFromState.test.js +1561 -0
  102. package/dist/esm/fork/__tests__/getPathFromState.test.js.map +6 -0
  103. package/dist/esm/fork/__tests__/getPathFromState.test.mjs +1441 -0
  104. package/dist/esm/fork/__tests__/getPathFromState.test.mjs.map +1 -0
  105. package/dist/esm/fork/__tests__/getPathFromState.test.native.js +1580 -0
  106. package/dist/esm/fork/__tests__/getPathFromState.test.native.js.map +1 -0
  107. package/dist/esm/fork/__tests__/getStateFromPath.test.js +2706 -0
  108. package/dist/esm/fork/__tests__/getStateFromPath.test.js.map +6 -0
  109. package/dist/esm/fork/__tests__/getStateFromPath.test.mjs +2566 -0
  110. package/dist/esm/fork/__tests__/getStateFromPath.test.mjs.map +1 -0
  111. package/dist/esm/fork/__tests__/getStateFromPath.test.native.js +2636 -0
  112. package/dist/esm/fork/__tests__/getStateFromPath.test.native.js.map +1 -0
  113. package/dist/esm/fork/getPathFromState.js +1 -1
  114. package/dist/esm/fork/getPathFromState.js.map +1 -1
  115. package/dist/esm/fork/getPathFromState.mjs +2 -1
  116. package/dist/esm/fork/getPathFromState.mjs.map +1 -1
  117. package/dist/esm/fork/getPathFromState.native.js +9 -5
  118. package/dist/esm/fork/getPathFromState.native.js.map +1 -1
  119. package/dist/esm/fork/getPathFromState.test.js +123 -0
  120. package/dist/esm/fork/getPathFromState.test.js.map +6 -0
  121. package/dist/esm/fork/getPathFromState.test.mjs +114 -0
  122. package/dist/esm/fork/getPathFromState.test.mjs.map +1 -0
  123. package/dist/esm/fork/getPathFromState.test.native.js +122 -0
  124. package/dist/esm/fork/getPathFromState.test.native.js.map +1 -0
  125. package/dist/esm/fork/getStateFromPath.test.js +294 -0
  126. package/dist/esm/fork/getStateFromPath.test.js.map +6 -0
  127. package/dist/esm/fork/getStateFromPath.test.mjs +230 -0
  128. package/dist/esm/fork/getStateFromPath.test.mjs.map +1 -0
  129. package/dist/esm/fork/getStateFromPath.test.native.js +233 -0
  130. package/dist/esm/fork/getStateFromPath.test.native.js.map +1 -0
  131. package/dist/esm/render.js +1 -1
  132. package/dist/esm/render.js.map +1 -1
  133. package/dist/esm/render.mjs +1 -1
  134. package/dist/esm/render.mjs.map +1 -1
  135. package/dist/esm/router/FlagsContext.js +6 -0
  136. package/dist/esm/router/FlagsContext.js.map +6 -0
  137. package/dist/esm/router/FlagsContext.mjs +4 -0
  138. package/dist/esm/router/FlagsContext.mjs.map +1 -0
  139. package/dist/esm/router/FlagsContext.native.js +4 -0
  140. package/dist/esm/router/FlagsContext.native.js.map +1 -0
  141. package/dist/esm/router/getRoutes.js +11 -1
  142. package/dist/esm/router/getRoutes.js.map +1 -1
  143. package/dist/esm/router/getRoutes.mjs +11 -1
  144. package/dist/esm/router/getRoutes.mjs.map +1 -1
  145. package/dist/esm/router/getRoutes.native.js +11 -1
  146. package/dist/esm/router/getRoutes.native.js.map +1 -1
  147. package/dist/esm/router/matchers.test.js +50 -0
  148. package/dist/esm/router/matchers.test.js.map +6 -0
  149. package/dist/esm/router/matchers.test.mjs +39 -0
  150. package/dist/esm/router/matchers.test.mjs.map +1 -0
  151. package/dist/esm/router/matchers.test.native.js +39 -0
  152. package/dist/esm/router/matchers.test.native.js.map +1 -0
  153. package/dist/esm/router/router.js +1 -26
  154. package/dist/esm/router/router.js.map +1 -1
  155. package/dist/esm/router/router.mjs +1 -33
  156. package/dist/esm/router/router.mjs.map +1 -1
  157. package/dist/esm/router/router.native.js +1 -37
  158. package/dist/esm/router/router.native.js.map +1 -1
  159. package/dist/esm/router/utils/getNavigateAction.js +32 -0
  160. package/dist/esm/router/utils/getNavigateAction.js.map +6 -0
  161. package/dist/esm/router/utils/getNavigateAction.mjs +38 -0
  162. package/dist/esm/router/utils/getNavigateAction.mjs.map +1 -0
  163. package/dist/esm/router/utils/getNavigateAction.native.js +42 -0
  164. package/dist/esm/router/utils/getNavigateAction.native.js.map +1 -0
  165. package/dist/esm/router/utils/getNavigateAction.test.js +296 -0
  166. package/dist/esm/router/utils/getNavigateAction.test.js.map +6 -0
  167. package/dist/esm/router/utils/getNavigateAction.test.mjs +260 -0
  168. package/dist/esm/router/utils/getNavigateAction.test.mjs.map +1 -0
  169. package/dist/esm/router/utils/getNavigateAction.test.native.js +273 -0
  170. package/dist/esm/router/utils/getNavigateAction.test.native.js.map +1 -0
  171. package/dist/esm/testing-utils.js +33 -0
  172. package/dist/esm/testing-utils.js.map +6 -0
  173. package/dist/esm/testing-utils.mjs +27 -0
  174. package/dist/esm/testing-utils.mjs.map +1 -0
  175. package/dist/esm/testing-utils.native.js +38 -0
  176. package/dist/esm/testing-utils.native.js.map +1 -0
  177. package/dist/esm/views/Navigator.js +29 -11
  178. package/dist/esm/views/Navigator.js.map +1 -1
  179. package/dist/esm/views/Navigator.mjs +8 -1
  180. package/dist/esm/views/Navigator.mjs.map +1 -1
  181. package/dist/esm/views/Navigator.native.js +8 -2
  182. package/dist/esm/views/Navigator.native.js.map +1 -1
  183. package/dist/esm/vite/one.js +6 -1
  184. package/dist/esm/vite/one.js.map +1 -1
  185. package/dist/esm/vite/one.mjs +6 -1
  186. package/dist/esm/vite/one.mjs.map +1 -1
  187. package/dist/esm/vite/one.native.js +9 -2
  188. package/dist/esm/vite/one.native.js.map +1 -1
  189. package/dist/esm/vite/plugins/virtualEntryPlugin.js +2 -0
  190. package/dist/esm/vite/plugins/virtualEntryPlugin.js.map +1 -1
  191. package/dist/esm/vite/plugins/virtualEntryPlugin.mjs +2 -0
  192. package/dist/esm/vite/plugins/virtualEntryPlugin.mjs.map +1 -1
  193. package/dist/esm/vite/plugins/virtualEntryPlugin.native.js +2 -0
  194. package/dist/esm/vite/plugins/virtualEntryPlugin.native.js.map +1 -1
  195. package/package.json +13 -10
  196. package/src/Root.tsx +12 -2
  197. package/src/createApp.native.tsx +8 -2
  198. package/src/createApp.tsx +18 -3
  199. package/src/fork/__tests__/README.md +8 -0
  200. package/src/fork/__tests__/getPathFromState.test.tsx +1809 -0
  201. package/src/fork/__tests__/getStateFromPath.test.tsx +3188 -0
  202. package/src/fork/getPathFromState.test.ts +146 -0
  203. package/src/fork/getPathFromState.ts +1 -1
  204. package/src/fork/getStateFromPath.test.ts +345 -0
  205. package/src/render.tsx +3 -3
  206. package/src/router/FlagsContext.ts +4 -0
  207. package/src/router/getRoutes.ts +14 -2
  208. package/src/router/matchers.test.ts +120 -0
  209. package/src/router/router.ts +1 -113
  210. package/src/router/utils/getNavigateAction.test.ts +334 -0
  211. package/src/router/utils/getNavigateAction.ts +120 -0
  212. package/src/testing-utils.ts +56 -0
  213. package/src/views/Navigator.tsx +34 -10
  214. package/src/vite/one.ts +5 -0
  215. package/src/vite/plugins/virtualEntryPlugin.ts +4 -1
  216. package/src/vite/types.ts +18 -0
  217. package/types/Root.d.ts +1 -0
  218. package/types/Root.d.ts.map +1 -1
  219. package/types/createApp.d.ts +2 -0
  220. package/types/createApp.d.ts.map +1 -1
  221. package/types/createApp.native.d.ts +2 -0
  222. package/types/createApp.native.d.ts.map +1 -1
  223. package/types/fork/getPathFromState.test.d.ts +2 -0
  224. package/types/fork/getPathFromState.test.d.ts.map +1 -0
  225. package/types/fork/getStateFromPath.test.d.ts +2 -0
  226. package/types/fork/getStateFromPath.test.d.ts.map +1 -0
  227. package/types/router/FlagsContext.d.ts +3 -0
  228. package/types/router/FlagsContext.d.ts.map +1 -0
  229. package/types/router/getRoutes.d.ts.map +1 -1
  230. package/types/router/matchers.test.d.ts +2 -0
  231. package/types/router/matchers.test.d.ts.map +1 -0
  232. package/types/router/router.d.ts.map +1 -1
  233. package/types/router/utils/getNavigateAction.d.ts +17 -0
  234. package/types/router/utils/getNavigateAction.d.ts.map +1 -0
  235. package/types/router/utils/getNavigateAction.test.d.ts +2 -0
  236. package/types/router/utils/getNavigateAction.test.d.ts.map +1 -0
  237. package/types/testing-utils.d.ts +26 -0
  238. package/types/testing-utils.d.ts.map +1 -0
  239. package/types/views/Navigator.d.ts +1 -1
  240. package/types/views/Navigator.d.ts.map +1 -1
  241. package/types/vite/one.d.ts.map +1 -1
  242. package/types/vite/plugins/virtualEntryPlugin.d.ts +2 -0
  243. package/types/vite/plugins/virtualEntryPlugin.d.ts.map +1 -1
  244. package/types/vite/types.d.ts +16 -0
  245. package/types/vite/types.d.ts.map +1 -1
@@ -0,0 +1,2861 @@
1
+ "use strict";
2
+ var import_vitest = require("vitest"), import_immer = require("immer"), import_findFocusedRoute = require("../findFocusedRoute"), import_getPathFromState = require("../getPathFromState"), import_getStateFromPath = require("../getStateFromPath"), changePath = function(state, path) {
3
+ return (0, import_immer.produce)(state, function(draftState) {
4
+ var route = (0, import_findFocusedRoute.findFocusedRoute)(draftState);
5
+ route.path = path;
6
+ });
7
+ };
8
+ (0, import_vitest.test)("returns undefined for invalid path", function() {
9
+ (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)("//")).toBeUndefined();
10
+ });
11
+ import_vitest.test.skip("converts path string to initial state", function() {
12
+ var path = "foo/bar/baz%20qux?author=jane%20%26%20co&valid=true", state = {
13
+ routes: [
14
+ {
15
+ name: "foo",
16
+ state: {
17
+ routes: [
18
+ {
19
+ name: "bar",
20
+ state: {
21
+ routes: [
22
+ {
23
+ name: "baz qux",
24
+ params: {
25
+ author: "jane & co",
26
+ valid: "true"
27
+ },
28
+ path
29
+ }
30
+ ]
31
+ }
32
+ }
33
+ ]
34
+ }
35
+ }
36
+ ]
37
+ };
38
+ (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)(path)).toEqual(state), (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)((0, import_getPathFromState.getPathFromState)(state))).toEqual(changePath(state, "/foo/bar/baz%20qux?author=jane%20%26%20co&valid=true"));
39
+ });
40
+ import_vitest.test.skip("decodes encoded params in path", function() {
41
+ var path = "/foo/bar/bar_%23_foo", config = {
42
+ screens: {
43
+ Foo: {
44
+ path: "foo",
45
+ screens: {
46
+ Bar: {
47
+ path: "/bar/:id"
48
+ }
49
+ }
50
+ }
51
+ }
52
+ }, state = {
53
+ routes: [
54
+ {
55
+ name: "Foo",
56
+ state: {
57
+ routes: [
58
+ {
59
+ name: "Bar",
60
+ params: {
61
+ id: "bar_#_foo"
62
+ },
63
+ path
64
+ }
65
+ ]
66
+ }
67
+ }
68
+ ]
69
+ };
70
+ (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)(path, config)).toEqual(state), (0, import_vitest.expect)((0, import_getPathFromState.getPathFromState)((0, import_getStateFromPath.getStateFromPath)(path, config), config)).toEqual(path);
71
+ });
72
+ import_vitest.test.skip("decodes encoded params in path that have encoded /", function() {
73
+ var path = "/foo/bar/bar_%2F_foo", config = {
74
+ screens: {
75
+ Foo: {
76
+ path: "foo",
77
+ screens: {
78
+ Bar: {
79
+ path: "/bar/:id"
80
+ }
81
+ }
82
+ }
83
+ }
84
+ }, state = {
85
+ routes: [
86
+ {
87
+ name: "Foo",
88
+ state: {
89
+ routes: [
90
+ {
91
+ name: "Bar",
92
+ params: {
93
+ id: "bar_/_foo"
94
+ },
95
+ path
96
+ }
97
+ ]
98
+ }
99
+ }
100
+ ]
101
+ };
102
+ (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)(path, config)).toEqual(state), (0, import_vitest.expect)((0, import_getPathFromState.getPathFromState)((0, import_getStateFromPath.getStateFromPath)(path, config), config)).toEqual(path);
103
+ });
104
+ import_vitest.test.skip("converts path string to initial state with config", function() {
105
+ var path = "/foo/bar/sweet/apple/baz/jane?count=10&answer=42&valid=true", config = {
106
+ screens: {
107
+ Foo: {
108
+ path: "foo",
109
+ screens: {
110
+ Bar: {
111
+ path: "bar/:type/:fruit",
112
+ screens: {
113
+ Baz: {
114
+ path: "baz/:author",
115
+ parse: {
116
+ author: function(author) {
117
+ return author.replace(/^\w/, function(c) {
118
+ return c.toUpperCase();
119
+ });
120
+ },
121
+ count: Number,
122
+ valid: Boolean
123
+ },
124
+ stringify: {
125
+ author: function(author) {
126
+ return author.toLowerCase();
127
+ }
128
+ }
129
+ }
130
+ }
131
+ }
132
+ }
133
+ }
134
+ }
135
+ }, state = {
136
+ routes: [
137
+ {
138
+ name: "Foo",
139
+ state: {
140
+ routes: [
141
+ {
142
+ name: "Bar",
143
+ params: {
144
+ fruit: "apple",
145
+ type: "sweet"
146
+ },
147
+ state: {
148
+ routes: [
149
+ {
150
+ name: "Baz",
151
+ params: {
152
+ author: "Jane",
153
+ count: 10,
154
+ answer: "42",
155
+ valid: !0
156
+ },
157
+ path
158
+ }
159
+ ]
160
+ }
161
+ }
162
+ ]
163
+ }
164
+ }
165
+ ]
166
+ };
167
+ (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)(path, config)).toEqual(state), (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)((0, import_getPathFromState.getPathFromState)(state, config), config)).toEqual(state);
168
+ });
169
+ (0, import_vitest.test)("handles leading slash when converting", function() {
170
+ var path = "/foo/bar/?count=42";
171
+ (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)(path)).toEqual({
172
+ routes: [
173
+ {
174
+ name: "foo",
175
+ state: {
176
+ routes: [
177
+ {
178
+ name: "bar",
179
+ params: {
180
+ count: "42"
181
+ },
182
+ path
183
+ }
184
+ ]
185
+ }
186
+ }
187
+ ]
188
+ });
189
+ });
190
+ (0, import_vitest.test)("handles ending slash when converting", function() {
191
+ var path = "foo/bar/?count=42";
192
+ (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)(path)).toEqual({
193
+ routes: [
194
+ {
195
+ name: "foo",
196
+ state: {
197
+ routes: [
198
+ {
199
+ name: "bar",
200
+ params: {
201
+ count: "42"
202
+ },
203
+ path
204
+ }
205
+ ]
206
+ }
207
+ }
208
+ ]
209
+ });
210
+ });
211
+ (0, import_vitest.test)("handles route without param", function() {
212
+ var path = "foo/bar", state = {
213
+ routes: [
214
+ {
215
+ name: "foo",
216
+ state: {
217
+ routes: [
218
+ {
219
+ name: "bar",
220
+ path
221
+ }
222
+ ]
223
+ }
224
+ }
225
+ ]
226
+ };
227
+ (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)(path)).toEqual(state), (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)((0, import_getPathFromState.getPathFromState)(state))).toEqual(changePath(state, "/foo/bar"));
228
+ });
229
+ import_vitest.test.skip("converts path string to initial state with config with nested screens", function() {
230
+ var path = "/foe/bar/sweet/apple/baz/jane?count=10&answer=42&valid=true", config = {
231
+ screens: {
232
+ Foo: {
233
+ path: "foo",
234
+ screens: {
235
+ Foe: {
236
+ path: "foe",
237
+ exact: !0,
238
+ screens: {
239
+ Bar: {
240
+ path: "bar/:type/:fruit",
241
+ screens: {
242
+ Baz: {
243
+ path: "baz/:author",
244
+ parse: {
245
+ author: function(author) {
246
+ return author.replace(/^\w/, function(c) {
247
+ return c.toUpperCase();
248
+ });
249
+ },
250
+ count: Number,
251
+ valid: Boolean
252
+ },
253
+ stringify: {
254
+ author: function(author) {
255
+ return author.toLowerCase();
256
+ }
257
+ }
258
+ }
259
+ }
260
+ }
261
+ }
262
+ }
263
+ }
264
+ }
265
+ }
266
+ }, state = {
267
+ routes: [
268
+ {
269
+ name: "Foo",
270
+ state: {
271
+ routes: [
272
+ {
273
+ name: "Foe",
274
+ state: {
275
+ routes: [
276
+ {
277
+ name: "Bar",
278
+ params: {
279
+ fruit: "apple",
280
+ type: "sweet"
281
+ },
282
+ state: {
283
+ routes: [
284
+ {
285
+ name: "Baz",
286
+ params: {
287
+ author: "Jane",
288
+ count: 10,
289
+ answer: "42",
290
+ valid: !0
291
+ },
292
+ path
293
+ }
294
+ ]
295
+ }
296
+ }
297
+ ]
298
+ }
299
+ }
300
+ ]
301
+ }
302
+ }
303
+ ]
304
+ };
305
+ (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)(path, config)).toEqual(state), (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)((0, import_getPathFromState.getPathFromState)(state, config), config)).toEqual(state);
306
+ });
307
+ import_vitest.test.skip("converts path string to initial state with config with nested screens and unused parse functions", function() {
308
+ var path = "/foe/baz/jane?count=10&answer=42&valid=true", config = {
309
+ screens: {
310
+ Foo: {
311
+ path: "foo",
312
+ screens: {
313
+ Foe: {
314
+ path: "foe",
315
+ exact: !0,
316
+ screens: {
317
+ Baz: {
318
+ path: "baz/:author",
319
+ parse: {
320
+ author: function(author) {
321
+ return author.replace(/^\w/, function(c) {
322
+ return c.toUpperCase();
323
+ });
324
+ },
325
+ count: Number,
326
+ valid: Boolean,
327
+ id: Boolean
328
+ }
329
+ }
330
+ }
331
+ }
332
+ }
333
+ }
334
+ }
335
+ }, state = {
336
+ routes: [
337
+ {
338
+ name: "Foo",
339
+ state: {
340
+ routes: [
341
+ {
342
+ name: "Foe",
343
+ state: {
344
+ routes: [
345
+ {
346
+ name: "Baz",
347
+ params: {
348
+ author: "Jane",
349
+ count: 10,
350
+ answer: "42",
351
+ valid: !0
352
+ },
353
+ path
354
+ }
355
+ ]
356
+ }
357
+ }
358
+ ]
359
+ }
360
+ }
361
+ ]
362
+ };
363
+ (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)(path, config)).toEqual(state), (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)((0, import_getPathFromState.getPathFromState)(state, config), config)).toEqual(changePath(state, "/foe/baz/Jane?count=10&answer=42&valid=true"));
364
+ });
365
+ import_vitest.test.skip("handles nested object with unused configs and with parse in it", function() {
366
+ var path = "/bar/sweet/apple/foe/bis/jane?count=10&answer=42&valid=true", config = {
367
+ screens: {
368
+ Bar: {
369
+ path: "bar/:type/:fruit",
370
+ screens: {
371
+ Foo: {
372
+ screens: {
373
+ Foe: {
374
+ path: "foe",
375
+ screens: {
376
+ Baz: {
377
+ screens: {
378
+ Bos: {
379
+ path: "bos",
380
+ exact: !0
381
+ },
382
+ Bis: {
383
+ path: "bis/:author",
384
+ stringify: {
385
+ author: function(author) {
386
+ return author.replace(/^\w/, function(c) {
387
+ return c.toLowerCase();
388
+ });
389
+ }
390
+ },
391
+ parse: {
392
+ author: function(author) {
393
+ return author.replace(/^\w/, function(c) {
394
+ return c.toUpperCase();
395
+ });
396
+ },
397
+ count: Number,
398
+ valid: Boolean
399
+ }
400
+ }
401
+ }
402
+ }
403
+ }
404
+ }
405
+ }
406
+ }
407
+ }
408
+ }
409
+ }
410
+ }, state = {
411
+ routes: [
412
+ {
413
+ name: "Bar",
414
+ params: {
415
+ fruit: "apple",
416
+ type: "sweet"
417
+ },
418
+ state: {
419
+ routes: [
420
+ {
421
+ name: "Foo",
422
+ state: {
423
+ routes: [
424
+ {
425
+ name: "Foe",
426
+ state: {
427
+ routes: [
428
+ {
429
+ name: "Baz",
430
+ state: {
431
+ routes: [
432
+ {
433
+ name: "Bis",
434
+ params: {
435
+ author: "Jane",
436
+ count: 10,
437
+ answer: "42",
438
+ valid: !0
439
+ },
440
+ path
441
+ }
442
+ ]
443
+ }
444
+ }
445
+ ]
446
+ }
447
+ }
448
+ ]
449
+ }
450
+ }
451
+ ]
452
+ }
453
+ }
454
+ ]
455
+ };
456
+ (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)(path, config)).toEqual(state), (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)((0, import_getPathFromState.getPathFromState)(state, config), config)).toEqual(state);
457
+ });
458
+ (0, import_vitest.test)("handles parse in nested object for second route depth", function() {
459
+ var path = "/baz", config = {
460
+ screens: {
461
+ Foo: {
462
+ path: "foo",
463
+ screens: {
464
+ Foe: {
465
+ path: "foe",
466
+ exact: !0
467
+ },
468
+ Bar: {
469
+ path: "bar",
470
+ exact: !0,
471
+ screens: {
472
+ Baz: {
473
+ path: "baz",
474
+ exact: !0
475
+ }
476
+ }
477
+ }
478
+ }
479
+ }
480
+ }
481
+ }, state = {
482
+ routes: [
483
+ {
484
+ name: "Foo",
485
+ state: {
486
+ routes: [
487
+ {
488
+ name: "Bar",
489
+ state: {
490
+ routes: [
491
+ {
492
+ name: "Baz",
493
+ path
494
+ }
495
+ ]
496
+ }
497
+ }
498
+ ]
499
+ }
500
+ }
501
+ ]
502
+ };
503
+ (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)(path, config)).toEqual(state), (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)((0, import_getPathFromState.getPathFromState)(state, config), config)).toEqual(state);
504
+ });
505
+ (0, import_vitest.test)("handles parse in nested object for second route depth and and path and parse in roots", function() {
506
+ var path = "/baz", config = {
507
+ screens: {
508
+ Foo: {
509
+ path: "foo/:id",
510
+ parse: {
511
+ id: Number
512
+ },
513
+ stringify: {
514
+ id: function(id) {
515
+ return `id=${id}`;
516
+ }
517
+ },
518
+ screens: {
519
+ Foe: "foe",
520
+ Bar: {
521
+ screens: {
522
+ Baz: {
523
+ path: "baz",
524
+ exact: !0
525
+ }
526
+ }
527
+ }
528
+ }
529
+ }
530
+ }
531
+ }, state = {
532
+ routes: [
533
+ {
534
+ name: "Foo",
535
+ state: {
536
+ routes: [
537
+ {
538
+ name: "Bar",
539
+ state: {
540
+ routes: [
541
+ {
542
+ name: "Baz",
543
+ path
544
+ }
545
+ ]
546
+ }
547
+ }
548
+ ]
549
+ }
550
+ }
551
+ ]
552
+ };
553
+ (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)(path, config)).toEqual(state), (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)((0, import_getPathFromState.getPathFromState)(state, config), config)).toEqual(state);
554
+ });
555
+ import_vitest.test.skip("handles path at top level", function() {
556
+ var path = "/foo/fruits/apple", config = {
557
+ path: "foo",
558
+ screens: {
559
+ Foo: {
560
+ screens: {
561
+ Fruits: "fruits/:fruit"
562
+ }
563
+ }
564
+ }
565
+ }, state = {
566
+ routes: [
567
+ {
568
+ name: "Foo",
569
+ state: {
570
+ routes: [
571
+ {
572
+ name: "Fruits",
573
+ params: {
574
+ fruit: "apple"
575
+ },
576
+ path
577
+ }
578
+ ]
579
+ }
580
+ }
581
+ ]
582
+ };
583
+ (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)(path, config)).toEqual(state), (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)((0, import_getPathFromState.getPathFromState)(state, config), config)).toEqual(state);
584
+ });
585
+ (0, import_vitest.test)("handles initialRouteName at top level", function() {
586
+ var path = "/baz", config = {
587
+ initialRouteName: "Boo",
588
+ screens: {
589
+ Foo: {
590
+ screens: {
591
+ Foe: "foe",
592
+ Bar: {
593
+ screens: {
594
+ Baz: "baz"
595
+ }
596
+ }
597
+ }
598
+ }
599
+ }
600
+ }, state = {
601
+ index: 1,
602
+ routes: [
603
+ {
604
+ name: "Boo"
605
+ },
606
+ {
607
+ name: "Foo",
608
+ state: {
609
+ routes: [
610
+ {
611
+ name: "Bar",
612
+ state: {
613
+ routes: [
614
+ {
615
+ name: "Baz",
616
+ path
617
+ }
618
+ ]
619
+ }
620
+ }
621
+ ]
622
+ }
623
+ }
624
+ ]
625
+ };
626
+ (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)(path, config)).toEqual(state), (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)((0, import_getPathFromState.getPathFromState)(state, config), config)).toEqual(state);
627
+ });
628
+ (0, import_vitest.test)("handles initialRouteName inside a screen", function() {
629
+ var path = "/baz", config = {
630
+ screens: {
631
+ Foo: {
632
+ initialRouteName: "Foe",
633
+ screens: {
634
+ Foe: "foe",
635
+ Bar: {
636
+ screens: {
637
+ Baz: "baz"
638
+ }
639
+ }
640
+ }
641
+ }
642
+ }
643
+ }, state = {
644
+ routes: [
645
+ {
646
+ name: "Foo",
647
+ state: {
648
+ index: 1,
649
+ routes: [
650
+ {
651
+ name: "Foe"
652
+ },
653
+ {
654
+ name: "Bar",
655
+ state: {
656
+ routes: [
657
+ {
658
+ name: "Baz",
659
+ path
660
+ }
661
+ ]
662
+ }
663
+ }
664
+ ]
665
+ }
666
+ }
667
+ ]
668
+ };
669
+ (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)(path, config)).toEqual(state), (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)((0, import_getPathFromState.getPathFromState)(state, config), config)).toEqual(state);
670
+ });
671
+ (0, import_vitest.test)("handles initialRouteName included in path", function() {
672
+ var path = "/baz", config = {
673
+ screens: {
674
+ Foo: {
675
+ initialRouteName: "Foe",
676
+ screens: {
677
+ Foe: {
678
+ screens: {
679
+ Baz: "baz"
680
+ }
681
+ },
682
+ Bar: "bar"
683
+ }
684
+ }
685
+ }
686
+ }, state = {
687
+ routes: [
688
+ {
689
+ name: "Foo",
690
+ state: {
691
+ routes: [
692
+ {
693
+ name: "Foe",
694
+ state: {
695
+ routes: [
696
+ {
697
+ name: "Baz",
698
+ path
699
+ }
700
+ ]
701
+ }
702
+ }
703
+ ]
704
+ }
705
+ }
706
+ ]
707
+ };
708
+ (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)(path, config)).toEqual(state), (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)((0, import_getPathFromState.getPathFromState)(state, config), config)).toEqual(state);
709
+ });
710
+ import_vitest.test.skip("handles two initialRouteNames", function() {
711
+ var path = "/bar/sweet/apple/foe/bis/jane?answer=42&count=10&valid=true", config = {
712
+ screens: {
713
+ Bar: {
714
+ path: "bar/:type/:fruit",
715
+ screens: {
716
+ Foo: {
717
+ screens: {
718
+ Foe: {
719
+ path: "foe",
720
+ screens: {
721
+ Baz: {
722
+ initialRouteName: "Bos",
723
+ screens: {
724
+ Bos: {
725
+ path: "bos",
726
+ exact: !0
727
+ },
728
+ Bis: {
729
+ path: "bis/:author",
730
+ stringify: {
731
+ author: function(author) {
732
+ return author.replace(/^\w/, function(c) {
733
+ return c.toLowerCase();
734
+ });
735
+ }
736
+ },
737
+ parse: {
738
+ author: function(author) {
739
+ return author.replace(/^\w/, function(c) {
740
+ return c.toUpperCase();
741
+ });
742
+ },
743
+ count: Number,
744
+ valid: Boolean
745
+ }
746
+ }
747
+ }
748
+ }
749
+ }
750
+ }
751
+ }
752
+ }
753
+ }
754
+ }
755
+ }
756
+ }, state = {
757
+ routes: [
758
+ {
759
+ name: "Bar",
760
+ params: {
761
+ fruit: "apple",
762
+ type: "sweet"
763
+ },
764
+ state: {
765
+ routes: [
766
+ {
767
+ name: "Foo",
768
+ state: {
769
+ routes: [
770
+ {
771
+ name: "Foe",
772
+ state: {
773
+ routes: [
774
+ {
775
+ name: "Baz",
776
+ state: {
777
+ index: 1,
778
+ routes: [
779
+ {
780
+ name: "Bos"
781
+ },
782
+ {
783
+ name: "Bis",
784
+ params: {
785
+ answer: "42",
786
+ author: "Jane",
787
+ count: 10,
788
+ valid: !0
789
+ },
790
+ path
791
+ }
792
+ ]
793
+ }
794
+ }
795
+ ]
796
+ }
797
+ }
798
+ ]
799
+ }
800
+ }
801
+ ]
802
+ }
803
+ }
804
+ ]
805
+ };
806
+ (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)(path, config)).toEqual(state), (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)((0, import_getPathFromState.getPathFromState)(state, config), config)).toEqual(state);
807
+ });
808
+ import_vitest.test.skip("accepts initialRouteName without config for it", function() {
809
+ var path = "/bar/sweet/apple/foe/bis/jane?answer=42&count=10&valid=true", config = {
810
+ screens: {
811
+ Bar: {
812
+ path: "bar/:type/:fruit",
813
+ screens: {
814
+ Foo: {
815
+ screens: {
816
+ Foe: {
817
+ path: "foe",
818
+ screens: {
819
+ Baz: {
820
+ initialRouteName: "Bas",
821
+ screens: {
822
+ Bos: {
823
+ path: "bos",
824
+ exact: !0
825
+ },
826
+ Bis: {
827
+ path: "bis/:author",
828
+ stringify: {
829
+ author: function(author) {
830
+ return author.replace(/^\w/, function(c) {
831
+ return c.toLowerCase();
832
+ });
833
+ }
834
+ },
835
+ parse: {
836
+ author: function(author) {
837
+ return author.replace(/^\w/, function(c) {
838
+ return c.toUpperCase();
839
+ });
840
+ },
841
+ count: Number,
842
+ valid: Boolean
843
+ }
844
+ }
845
+ }
846
+ }
847
+ }
848
+ }
849
+ }
850
+ }
851
+ }
852
+ }
853
+ }
854
+ }, state = {
855
+ routes: [
856
+ {
857
+ name: "Bar",
858
+ params: {
859
+ fruit: "apple",
860
+ type: "sweet"
861
+ },
862
+ state: {
863
+ routes: [
864
+ {
865
+ name: "Foo",
866
+ state: {
867
+ routes: [
868
+ {
869
+ name: "Foe",
870
+ state: {
871
+ routes: [
872
+ {
873
+ name: "Baz",
874
+ state: {
875
+ index: 1,
876
+ routes: [
877
+ {
878
+ name: "Bas"
879
+ },
880
+ {
881
+ name: "Bis",
882
+ params: {
883
+ answer: "42",
884
+ author: "Jane",
885
+ count: 10,
886
+ valid: !0
887
+ },
888
+ path
889
+ }
890
+ ]
891
+ }
892
+ }
893
+ ]
894
+ }
895
+ }
896
+ ]
897
+ }
898
+ }
899
+ ]
900
+ }
901
+ }
902
+ ]
903
+ };
904
+ (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)(path, config)).toEqual(state), (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)((0, import_getPathFromState.getPathFromState)(state, config), config)).toEqual(state);
905
+ });
906
+ (0, import_vitest.test)("returns undefined if no matching screen is present (top level path)", function() {
907
+ var path = "/foo/bar", config = {
908
+ path: "qux",
909
+ screens: {
910
+ Foo: {
911
+ screens: {
912
+ Foe: "foo",
913
+ Bar: {
914
+ screens: {
915
+ Baz: "bar"
916
+ }
917
+ }
918
+ }
919
+ }
920
+ }
921
+ };
922
+ (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)(path, config)).toBeUndefined();
923
+ });
924
+ (0, import_vitest.test)("returns undefined if no matching screen is present", function() {
925
+ var path = "/baz", config = {
926
+ screens: {
927
+ Foo: {
928
+ path: "foo",
929
+ screens: {
930
+ Foe: "foe",
931
+ Bar: {
932
+ screens: {
933
+ Baz: "baz"
934
+ }
935
+ }
936
+ }
937
+ }
938
+ }
939
+ };
940
+ (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)(path, config)).toBeUndefined();
941
+ });
942
+ (0, import_vitest.test)("returns undefined if path is empty and no matching screen is present", function() {
943
+ var path = "", config = {
944
+ screens: {
945
+ Foo: {
946
+ screens: {
947
+ Foe: "foe",
948
+ Bar: {
949
+ screens: {
950
+ Baz: "baz"
951
+ }
952
+ }
953
+ }
954
+ }
955
+ }
956
+ };
957
+ (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)(path, config)).toBeUndefined();
958
+ });
959
+ import_vitest.test.skip("returns matching screen if path is empty", function() {
960
+ var path = "", config = {
961
+ screens: {
962
+ Foo: {
963
+ screens: {
964
+ Foe: "foe",
965
+ Bar: {
966
+ screens: {
967
+ Qux: "",
968
+ Baz: "baz"
969
+ }
970
+ }
971
+ }
972
+ }
973
+ }
974
+ }, state = {
975
+ routes: [
976
+ {
977
+ name: "Foo",
978
+ state: {
979
+ routes: [
980
+ {
981
+ name: "Bar",
982
+ state: {
983
+ routes: [
984
+ {
985
+ name: "Qux",
986
+ path
987
+ }
988
+ ]
989
+ }
990
+ }
991
+ ]
992
+ }
993
+ }
994
+ ]
995
+ };
996
+ (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)(path, config)).toEqual(state), (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)((0, import_getPathFromState.getPathFromState)(state, config), config)).toEqual(changePath(state, ""));
997
+ });
998
+ import_vitest.test.skip("returns matching screen if path is only slash", function() {
999
+ var path = "/", config = {
1000
+ screens: {
1001
+ Foo: {
1002
+ screens: {
1003
+ Foe: "foe",
1004
+ Bar: {
1005
+ screens: {
1006
+ Qux: "",
1007
+ Baz: "baz"
1008
+ }
1009
+ }
1010
+ }
1011
+ }
1012
+ }
1013
+ }, state = {
1014
+ routes: [
1015
+ {
1016
+ name: "Foo",
1017
+ state: {
1018
+ routes: [
1019
+ {
1020
+ name: "Bar",
1021
+ state: {
1022
+ routes: [
1023
+ {
1024
+ name: "Qux",
1025
+ path: ""
1026
+ }
1027
+ ]
1028
+ }
1029
+ }
1030
+ ]
1031
+ }
1032
+ }
1033
+ ]
1034
+ };
1035
+ (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)(path, config)).toEqual(state), (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)((0, import_getPathFromState.getPathFromState)(state, config), config)).toEqual(changePath(state, ""));
1036
+ });
1037
+ (0, import_vitest.test)("returns matching screen with params if path is empty", function() {
1038
+ var path = "?foo=42", config = {
1039
+ screens: {
1040
+ Foo: {
1041
+ screens: {
1042
+ Foe: "foe",
1043
+ Bar: {
1044
+ screens: {
1045
+ Qux: {
1046
+ path: "",
1047
+ parse: {
1048
+ foo: Number
1049
+ }
1050
+ },
1051
+ Baz: "baz"
1052
+ }
1053
+ }
1054
+ }
1055
+ }
1056
+ }
1057
+ }, state = {
1058
+ routes: [
1059
+ {
1060
+ name: "Foo",
1061
+ state: {
1062
+ routes: [
1063
+ {
1064
+ name: "Bar",
1065
+ state: {
1066
+ routes: [
1067
+ {
1068
+ name: "Qux",
1069
+ params: {
1070
+ foo: 42
1071
+ },
1072
+ path
1073
+ }
1074
+ ]
1075
+ }
1076
+ }
1077
+ ]
1078
+ }
1079
+ }
1080
+ ]
1081
+ };
1082
+ (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)(path, config)).toEqual(state), (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)((0, import_getPathFromState.getPathFromState)(state, config), config)).toEqual(changePath(state, "/?foo=42"));
1083
+ });
1084
+ (0, import_vitest.test)("doesn't match nested screen if path is empty", function() {
1085
+ var config = {
1086
+ screens: {
1087
+ Foo: {
1088
+ screens: {
1089
+ Foe: "foe",
1090
+ Bar: {
1091
+ path: "bar",
1092
+ screens: {
1093
+ Qux: {
1094
+ path: "",
1095
+ parse: {
1096
+ foo: Number
1097
+ }
1098
+ }
1099
+ }
1100
+ }
1101
+ }
1102
+ }
1103
+ }
1104
+ }, path = "";
1105
+ (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)(path, config)).toBeUndefined();
1106
+ });
1107
+ import_vitest.test.skip("chooses more exhaustive pattern", function() {
1108
+ var path = "/foo/5", config = {
1109
+ screens: {
1110
+ Foe: {
1111
+ path: "/",
1112
+ initialRouteName: "Foo",
1113
+ screens: {
1114
+ Foo: "foo",
1115
+ Bis: {
1116
+ path: "foo/:id",
1117
+ parse: {
1118
+ id: Number
1119
+ }
1120
+ }
1121
+ }
1122
+ }
1123
+ }
1124
+ }, state = {
1125
+ routes: [
1126
+ {
1127
+ name: "Foe",
1128
+ state: {
1129
+ index: 1,
1130
+ routes: [
1131
+ {
1132
+ name: "Foo"
1133
+ },
1134
+ {
1135
+ name: "Bis",
1136
+ params: {
1137
+ id: 5
1138
+ },
1139
+ path
1140
+ }
1141
+ ]
1142
+ }
1143
+ }
1144
+ ]
1145
+ };
1146
+ (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)(path, config)).toEqual(state), (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)((0, import_getPathFromState.getPathFromState)(state, config), config)).toEqual(state);
1147
+ });
1148
+ (0, import_vitest.test)("handles same paths beginnings", function() {
1149
+ var path = "/foos", config = {
1150
+ screens: {
1151
+ Foe: {
1152
+ path: "/",
1153
+ initialRouteName: "Foo",
1154
+ screens: {
1155
+ Foo: "foo",
1156
+ Bis: {
1157
+ path: "foos"
1158
+ }
1159
+ }
1160
+ }
1161
+ }
1162
+ }, state = {
1163
+ routes: [
1164
+ {
1165
+ name: "Foe",
1166
+ state: {
1167
+ index: 1,
1168
+ routes: [
1169
+ {
1170
+ name: "Foo"
1171
+ },
1172
+ {
1173
+ name: "Bis",
1174
+ path
1175
+ }
1176
+ ]
1177
+ }
1178
+ }
1179
+ ]
1180
+ };
1181
+ (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)(path, config)).toEqual(state), (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)((0, import_getPathFromState.getPathFromState)(state, config), config)).toEqual(state);
1182
+ });
1183
+ import_vitest.test.skip("handles same paths beginnings with params", function() {
1184
+ var path = "/foos/5", config = {
1185
+ screens: {
1186
+ Foe: {
1187
+ path: "/",
1188
+ initialRouteName: "Foo",
1189
+ screens: {
1190
+ Foo: "foo",
1191
+ Bis: {
1192
+ path: "foos/:id",
1193
+ parse: {
1194
+ id: Number
1195
+ }
1196
+ }
1197
+ }
1198
+ }
1199
+ }
1200
+ }, state = {
1201
+ routes: [
1202
+ {
1203
+ name: "Foe",
1204
+ state: {
1205
+ index: 1,
1206
+ routes: [
1207
+ {
1208
+ name: "Foo"
1209
+ },
1210
+ {
1211
+ name: "Bis",
1212
+ params: {
1213
+ id: 5
1214
+ },
1215
+ path
1216
+ }
1217
+ ]
1218
+ }
1219
+ }
1220
+ ]
1221
+ };
1222
+ (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)(path, config)).toEqual(state), (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)((0, import_getPathFromState.getPathFromState)(state, config), config)).toEqual(state);
1223
+ });
1224
+ import_vitest.test.skip("handles not taking path with too many segments", function() {
1225
+ var path = "/foos/5", config = {
1226
+ screens: {
1227
+ Foe: {
1228
+ path: "/",
1229
+ initialRouteName: "Foo",
1230
+ screens: {
1231
+ Foo: "foo",
1232
+ Bis: {
1233
+ path: "foos/:id",
1234
+ parse: {
1235
+ id: Number
1236
+ }
1237
+ },
1238
+ Bas: {
1239
+ path: "foos/:id/:nip",
1240
+ parse: {
1241
+ id: Number,
1242
+ pwd: Number
1243
+ }
1244
+ }
1245
+ }
1246
+ }
1247
+ }
1248
+ }, state = {
1249
+ routes: [
1250
+ {
1251
+ name: "Foe",
1252
+ state: {
1253
+ index: 1,
1254
+ routes: [
1255
+ {
1256
+ name: "Foo"
1257
+ },
1258
+ {
1259
+ name: "Bis",
1260
+ params: {
1261
+ id: 5
1262
+ },
1263
+ path
1264
+ }
1265
+ ]
1266
+ }
1267
+ }
1268
+ ]
1269
+ };
1270
+ (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)(path, config)).toEqual(state), (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)((0, import_getPathFromState.getPathFromState)(state, config), config)).toEqual(state);
1271
+ });
1272
+ import_vitest.test.skip("handles differently ordered params v1", function() {
1273
+ var path = "/foos/5/res/20", config = {
1274
+ screens: {
1275
+ Foe: {
1276
+ path: "/",
1277
+ initialRouteName: "Foo",
1278
+ screens: {
1279
+ Foo: "foo",
1280
+ Bis: {
1281
+ path: "foos/:id",
1282
+ parse: {
1283
+ id: Number
1284
+ }
1285
+ },
1286
+ Bas: {
1287
+ path: "foos/:id/res/:pwd",
1288
+ parse: {
1289
+ id: Number,
1290
+ pwd: Number
1291
+ }
1292
+ }
1293
+ }
1294
+ }
1295
+ }
1296
+ }, state = {
1297
+ routes: [
1298
+ {
1299
+ name: "Foe",
1300
+ state: {
1301
+ index: 1,
1302
+ routes: [
1303
+ {
1304
+ name: "Foo"
1305
+ },
1306
+ {
1307
+ name: "Bas",
1308
+ params: {
1309
+ id: 5,
1310
+ pwd: 20
1311
+ },
1312
+ path
1313
+ }
1314
+ ]
1315
+ }
1316
+ }
1317
+ ]
1318
+ };
1319
+ (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)(path, config)).toEqual(state), (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)((0, import_getPathFromState.getPathFromState)(state, config), config)).toEqual(state);
1320
+ });
1321
+ import_vitest.test.skip("handles differently ordered params v2", function() {
1322
+ var path = "/5/20/foos/res", config = {
1323
+ screens: {
1324
+ Foe: {
1325
+ path: "/",
1326
+ initialRouteName: "Foo",
1327
+ screens: {
1328
+ Foo: "foo",
1329
+ Bis: {
1330
+ path: "foos/:id",
1331
+ parse: {
1332
+ id: Number
1333
+ }
1334
+ },
1335
+ Bas: {
1336
+ path: ":id/:pwd/foos/res",
1337
+ parse: {
1338
+ id: Number,
1339
+ pwd: Number
1340
+ }
1341
+ }
1342
+ }
1343
+ }
1344
+ }
1345
+ }, state = {
1346
+ routes: [
1347
+ {
1348
+ name: "Foe",
1349
+ state: {
1350
+ index: 1,
1351
+ routes: [
1352
+ {
1353
+ name: "Foo"
1354
+ },
1355
+ {
1356
+ name: "Bas",
1357
+ params: {
1358
+ id: 5,
1359
+ pwd: 20
1360
+ },
1361
+ path
1362
+ }
1363
+ ]
1364
+ }
1365
+ }
1366
+ ]
1367
+ };
1368
+ (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)(path, config)).toEqual(state), (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)((0, import_getPathFromState.getPathFromState)(state, config), config)).toEqual(state);
1369
+ });
1370
+ import_vitest.test.skip("handles differently ordered params v3", function() {
1371
+ var path = "/foos/5/20/res", config = {
1372
+ screens: {
1373
+ Foe: {
1374
+ path: "/",
1375
+ initialRouteName: "Foo",
1376
+ screens: {
1377
+ Foo: "foo",
1378
+ Bis: {
1379
+ path: "foos/:id",
1380
+ parse: {
1381
+ id: Number
1382
+ }
1383
+ },
1384
+ Bas: {
1385
+ path: "foos/:id/:pwd/res",
1386
+ parse: {
1387
+ id: Number,
1388
+ pwd: Number
1389
+ }
1390
+ }
1391
+ }
1392
+ }
1393
+ }
1394
+ }, state = {
1395
+ routes: [
1396
+ {
1397
+ name: "Foe",
1398
+ state: {
1399
+ index: 1,
1400
+ routes: [
1401
+ {
1402
+ name: "Foo"
1403
+ },
1404
+ {
1405
+ name: "Bas",
1406
+ params: {
1407
+ id: 5,
1408
+ pwd: 20
1409
+ },
1410
+ path
1411
+ }
1412
+ ]
1413
+ }
1414
+ }
1415
+ ]
1416
+ };
1417
+ (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)(path, config)).toEqual(state), (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)((0, import_getPathFromState.getPathFromState)(state, config), config)).toEqual(state);
1418
+ });
1419
+ import_vitest.test.skip("handles differently ordered params v4", function() {
1420
+ var path = "5/foos/res/20", config = {
1421
+ screens: {
1422
+ Foe: {
1423
+ path: "/",
1424
+ initialRouteName: "Foo",
1425
+ screens: {
1426
+ Foo: "foo",
1427
+ Bis: {
1428
+ path: "foos/:id",
1429
+ parse: {
1430
+ id: Number
1431
+ }
1432
+ },
1433
+ Bas: {
1434
+ path: ":id/foos/res/:pwd",
1435
+ parse: {
1436
+ id: Number,
1437
+ pwd: Number
1438
+ }
1439
+ }
1440
+ }
1441
+ }
1442
+ }
1443
+ }, state = {
1444
+ routes: [
1445
+ {
1446
+ name: "Foe",
1447
+ state: {
1448
+ index: 1,
1449
+ routes: [
1450
+ {
1451
+ name: "Foo"
1452
+ },
1453
+ {
1454
+ name: "Bas",
1455
+ params: {
1456
+ id: 5,
1457
+ pwd: 20
1458
+ },
1459
+ path
1460
+ }
1461
+ ]
1462
+ }
1463
+ }
1464
+ ]
1465
+ };
1466
+ (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)(path, config)).toEqual(state), (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)((0, import_getPathFromState.getPathFromState)(state, config), config)).toEqual(changePath(state, "/5/foos/res/20"));
1467
+ });
1468
+ import_vitest.test.skip("handles simple optional params", function() {
1469
+ var path = "/foos/5", config = {
1470
+ screens: {
1471
+ Foe: {
1472
+ path: "/",
1473
+ initialRouteName: "Foo",
1474
+ screens: {
1475
+ Foo: "foo",
1476
+ Bis: {
1477
+ path: "foo/:id",
1478
+ parse: {
1479
+ id: Number
1480
+ }
1481
+ },
1482
+ Bas: {
1483
+ path: "foos/:id/:nip?",
1484
+ parse: {
1485
+ id: Number,
1486
+ nip: Number
1487
+ }
1488
+ }
1489
+ }
1490
+ }
1491
+ }
1492
+ }, state = {
1493
+ routes: [
1494
+ {
1495
+ name: "Foe",
1496
+ state: {
1497
+ index: 1,
1498
+ routes: [
1499
+ {
1500
+ name: "Foo"
1501
+ },
1502
+ {
1503
+ name: "Bas",
1504
+ params: {
1505
+ id: 5
1506
+ },
1507
+ path
1508
+ }
1509
+ ]
1510
+ }
1511
+ }
1512
+ ]
1513
+ };
1514
+ (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)(path, config)).toEqual(state), (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)((0, import_getPathFromState.getPathFromState)(state, config), config)).toEqual(state);
1515
+ });
1516
+ import_vitest.test.skip("handle 2 optional params at the end v1", function() {
1517
+ var path = "/foos/5", config = {
1518
+ screens: {
1519
+ Foe: {
1520
+ path: "/",
1521
+ initialRouteName: "Foo",
1522
+ screens: {
1523
+ Foo: "foo",
1524
+ Bis: {
1525
+ path: "foo/:id",
1526
+ parse: {
1527
+ id: Number
1528
+ }
1529
+ },
1530
+ Bas: {
1531
+ path: "foos/:id/:nip?/:pwd?",
1532
+ parse: {
1533
+ id: Number,
1534
+ nip: Number
1535
+ }
1536
+ }
1537
+ }
1538
+ }
1539
+ }
1540
+ }, state = {
1541
+ routes: [
1542
+ {
1543
+ name: "Foe",
1544
+ state: {
1545
+ index: 1,
1546
+ routes: [
1547
+ {
1548
+ name: "Foo"
1549
+ },
1550
+ {
1551
+ name: "Bas",
1552
+ params: {
1553
+ id: 5
1554
+ },
1555
+ path
1556
+ }
1557
+ ]
1558
+ }
1559
+ }
1560
+ ]
1561
+ };
1562
+ (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)(path, config)).toEqual(state), (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)((0, import_getPathFromState.getPathFromState)(state, config), config)).toEqual(state);
1563
+ });
1564
+ import_vitest.test.skip("handle 2 optional params at the end v2", function() {
1565
+ var path = "/foos/5/10", config = {
1566
+ screens: {
1567
+ Foe: {
1568
+ path: "/",
1569
+ initialRouteName: "Foo",
1570
+ screens: {
1571
+ Foo: "foo",
1572
+ Bis: {
1573
+ path: "foo/:id",
1574
+ parse: {
1575
+ id: Number
1576
+ }
1577
+ },
1578
+ Bas: {
1579
+ path: "foos/:id/:nip?/:pwd?",
1580
+ parse: {
1581
+ id: Number,
1582
+ nip: Number
1583
+ }
1584
+ }
1585
+ }
1586
+ }
1587
+ }
1588
+ }, state = {
1589
+ routes: [
1590
+ {
1591
+ name: "Foe",
1592
+ state: {
1593
+ index: 1,
1594
+ routes: [
1595
+ {
1596
+ name: "Foo"
1597
+ },
1598
+ {
1599
+ name: "Bas",
1600
+ params: {
1601
+ id: 5,
1602
+ nip: 10
1603
+ },
1604
+ path
1605
+ }
1606
+ ]
1607
+ }
1608
+ }
1609
+ ]
1610
+ };
1611
+ (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)(path, config)).toEqual(state), (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)((0, import_getPathFromState.getPathFromState)(state, config), config)).toEqual(state);
1612
+ });
1613
+ import_vitest.test.skip("handle 2 optional params at the end v3", function() {
1614
+ var path = "/foos/5/10/15", config = {
1615
+ screens: {
1616
+ Foe: {
1617
+ path: "/",
1618
+ initialRouteName: "Foo",
1619
+ screens: {
1620
+ Foo: "foo",
1621
+ Bis: {
1622
+ path: "foo/:id",
1623
+ parse: {
1624
+ id: Number
1625
+ }
1626
+ },
1627
+ Bas: {
1628
+ path: "foos/:id/:nip?/:pwd?",
1629
+ parse: {
1630
+ id: Number,
1631
+ nip: Number,
1632
+ pwd: Number
1633
+ }
1634
+ }
1635
+ }
1636
+ }
1637
+ }
1638
+ }, state = {
1639
+ routes: [
1640
+ {
1641
+ name: "Foe",
1642
+ state: {
1643
+ index: 1,
1644
+ routes: [
1645
+ {
1646
+ name: "Foo"
1647
+ },
1648
+ {
1649
+ name: "Bas",
1650
+ params: {
1651
+ id: 5,
1652
+ nip: 10,
1653
+ pwd: 15
1654
+ },
1655
+ path
1656
+ }
1657
+ ]
1658
+ }
1659
+ }
1660
+ ]
1661
+ };
1662
+ (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)(path, config)).toEqual(state), (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)((0, import_getPathFromState.getPathFromState)(state, config), config)).toEqual(state);
1663
+ });
1664
+ import_vitest.test.skip("handle optional params in the middle v1", function() {
1665
+ var path = "/foos/5/10", config = {
1666
+ screens: {
1667
+ Foe: {
1668
+ path: "/",
1669
+ initialRouteName: "Foo",
1670
+ screens: {
1671
+ Foo: "foo",
1672
+ Bis: {
1673
+ path: "foo/:id",
1674
+ parse: {
1675
+ id: Number
1676
+ }
1677
+ },
1678
+ Bas: {
1679
+ path: "foos/:id/:nip?/:pwd",
1680
+ parse: {
1681
+ id: Number,
1682
+ nip: Number,
1683
+ pwd: Number
1684
+ }
1685
+ }
1686
+ }
1687
+ }
1688
+ }
1689
+ }, state = {
1690
+ routes: [
1691
+ {
1692
+ name: "Foe",
1693
+ state: {
1694
+ index: 1,
1695
+ routes: [
1696
+ {
1697
+ name: "Foo"
1698
+ },
1699
+ {
1700
+ name: "Bas",
1701
+ params: {
1702
+ id: 5,
1703
+ pwd: 10
1704
+ },
1705
+ path
1706
+ }
1707
+ ]
1708
+ }
1709
+ }
1710
+ ]
1711
+ };
1712
+ (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)(path, config)).toEqual(state), (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)((0, import_getPathFromState.getPathFromState)(state, config), config)).toEqual(state);
1713
+ });
1714
+ import_vitest.test.skip("handle optional params in the middle v2", function() {
1715
+ var path = "/foos/5/10/15", config = {
1716
+ screens: {
1717
+ Foe: {
1718
+ path: "/",
1719
+ initialRouteName: "Foo",
1720
+ screens: {
1721
+ Foo: "foo",
1722
+ Bis: {
1723
+ path: "foo/:id",
1724
+ parse: {
1725
+ id: Number
1726
+ }
1727
+ },
1728
+ Bas: {
1729
+ path: "foos/:id/:nip?/:pwd",
1730
+ parse: {
1731
+ id: Number,
1732
+ nip: Number,
1733
+ pwd: Number
1734
+ }
1735
+ }
1736
+ }
1737
+ }
1738
+ }
1739
+ }, state = {
1740
+ routes: [
1741
+ {
1742
+ name: "Foe",
1743
+ state: {
1744
+ index: 1,
1745
+ routes: [
1746
+ {
1747
+ name: "Foo"
1748
+ },
1749
+ {
1750
+ name: "Bas",
1751
+ params: {
1752
+ id: 5,
1753
+ nip: 10,
1754
+ pwd: 15
1755
+ },
1756
+ path
1757
+ }
1758
+ ]
1759
+ }
1760
+ }
1761
+ ]
1762
+ };
1763
+ (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)(path, config)).toEqual(state), (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)((0, import_getPathFromState.getPathFromState)(state, config), config)).toEqual(state);
1764
+ });
1765
+ import_vitest.test.skip("handle optional params in the middle v3", function() {
1766
+ var path = "/foos/5/10/15", config = {
1767
+ screens: {
1768
+ Foe: {
1769
+ path: "/",
1770
+ initialRouteName: "Foo",
1771
+ screens: {
1772
+ Foo: "foo",
1773
+ Bis: {
1774
+ path: "foo/:id",
1775
+ parse: {
1776
+ id: Number
1777
+ }
1778
+ },
1779
+ Bas: {
1780
+ path: "foos/:id/:nip?/:pwd/:smh",
1781
+ parse: {
1782
+ id: Number,
1783
+ nip: Number,
1784
+ pwd: Number,
1785
+ smh: Number
1786
+ }
1787
+ }
1788
+ }
1789
+ }
1790
+ }
1791
+ }, state = {
1792
+ routes: [
1793
+ {
1794
+ name: "Foe",
1795
+ state: {
1796
+ index: 1,
1797
+ routes: [
1798
+ {
1799
+ name: "Foo"
1800
+ },
1801
+ {
1802
+ name: "Bas",
1803
+ params: {
1804
+ id: 5,
1805
+ pwd: 10,
1806
+ smh: 15
1807
+ },
1808
+ path
1809
+ }
1810
+ ]
1811
+ }
1812
+ }
1813
+ ]
1814
+ };
1815
+ (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)(path, config)).toEqual(state), (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)((0, import_getPathFromState.getPathFromState)(state, config), config)).toEqual(state);
1816
+ });
1817
+ import_vitest.test.skip("handle optional params in the middle v4", function() {
1818
+ var path = "/foos/5/10", config = {
1819
+ screens: {
1820
+ Foe: {
1821
+ path: "/",
1822
+ initialRouteName: "Foo",
1823
+ screens: {
1824
+ Foo: "foo",
1825
+ Bis: {
1826
+ path: "foo/:id",
1827
+ parse: {
1828
+ id: Number
1829
+ }
1830
+ },
1831
+ Bas: {
1832
+ path: "foos/:nip?/:pwd/:smh?/:id",
1833
+ parse: {
1834
+ id: Number,
1835
+ nip: Number,
1836
+ pwd: Number,
1837
+ smh: Number
1838
+ }
1839
+ }
1840
+ }
1841
+ }
1842
+ }
1843
+ }, state = {
1844
+ routes: [
1845
+ {
1846
+ name: "Foe",
1847
+ state: {
1848
+ index: 1,
1849
+ routes: [
1850
+ {
1851
+ name: "Foo"
1852
+ },
1853
+ {
1854
+ name: "Bas",
1855
+ params: {
1856
+ pwd: 5,
1857
+ id: 10
1858
+ },
1859
+ path
1860
+ }
1861
+ ]
1862
+ }
1863
+ }
1864
+ ]
1865
+ };
1866
+ (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)(path, config)).toEqual(state), (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)((0, import_getPathFromState.getPathFromState)(state, config), config)).toEqual(state);
1867
+ });
1868
+ import_vitest.test.skip("handle optional params in the middle v5", function() {
1869
+ var path = "/foos/5/10/15", config = {
1870
+ screens: {
1871
+ Foe: {
1872
+ path: "/",
1873
+ initialRouteName: "Foo",
1874
+ screens: {
1875
+ Foo: "foo",
1876
+ Bis: {
1877
+ path: "foo/:id",
1878
+ parse: {
1879
+ id: Number
1880
+ }
1881
+ },
1882
+ Bas: {
1883
+ path: "foos/:nip?/:pwd/:smh?/:id",
1884
+ parse: {
1885
+ id: Number,
1886
+ nip: Number,
1887
+ pwd: Number,
1888
+ smh: Number
1889
+ }
1890
+ }
1891
+ }
1892
+ }
1893
+ }
1894
+ }, state = {
1895
+ routes: [
1896
+ {
1897
+ name: "Foe",
1898
+ state: {
1899
+ index: 1,
1900
+ routes: [
1901
+ {
1902
+ name: "Foo"
1903
+ },
1904
+ {
1905
+ name: "Bas",
1906
+ params: {
1907
+ nip: 5,
1908
+ pwd: 10,
1909
+ id: 15
1910
+ },
1911
+ path
1912
+ }
1913
+ ]
1914
+ }
1915
+ }
1916
+ ]
1917
+ };
1918
+ (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)(path, config)).toEqual(state), (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)((0, import_getPathFromState.getPathFromState)(state, config), config)).toEqual(state);
1919
+ });
1920
+ import_vitest.test.skip("handle optional params in the beginning v1", function() {
1921
+ var path = "5/10/foos/15", config = {
1922
+ screens: {
1923
+ Foe: {
1924
+ path: "/",
1925
+ initialRouteName: "Foo",
1926
+ screens: {
1927
+ Foo: "foo",
1928
+ Bis: {
1929
+ path: "foo/:id",
1930
+ parse: {
1931
+ id: Number
1932
+ }
1933
+ },
1934
+ Bas: {
1935
+ path: ":nip?/:pwd/foos/:smh?/:id",
1936
+ parse: {
1937
+ id: Number,
1938
+ nip: Number,
1939
+ pwd: Number,
1940
+ smh: Number
1941
+ }
1942
+ }
1943
+ }
1944
+ }
1945
+ }
1946
+ }, state = {
1947
+ routes: [
1948
+ {
1949
+ name: "Foe",
1950
+ state: {
1951
+ index: 1,
1952
+ routes: [
1953
+ {
1954
+ name: "Foo"
1955
+ },
1956
+ {
1957
+ name: "Bas",
1958
+ params: {
1959
+ nip: 5,
1960
+ pwd: 10,
1961
+ id: 15
1962
+ },
1963
+ path
1964
+ }
1965
+ ]
1966
+ }
1967
+ }
1968
+ ]
1969
+ };
1970
+ (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)(path, config)).toEqual(state), (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)((0, import_getPathFromState.getPathFromState)(state, config), config)).toEqual(changePath(state, "/5/10/foos/15"));
1971
+ });
1972
+ import_vitest.test.skip("handle optional params in the beginning v2", function() {
1973
+ var path = "5/10/foos/15", config = {
1974
+ screens: {
1975
+ Foe: {
1976
+ path: "/",
1977
+ initialRouteName: "Foo",
1978
+ screens: {
1979
+ Foo: "foo",
1980
+ Bis: {
1981
+ path: "foo/:id",
1982
+ parse: {
1983
+ id: Number
1984
+ }
1985
+ },
1986
+ Bas: {
1987
+ path: ":nip?/:smh?/:pwd/foos/:id",
1988
+ parse: {
1989
+ id: Number,
1990
+ nip: Number,
1991
+ pwd: Number,
1992
+ smh: Number
1993
+ }
1994
+ }
1995
+ }
1996
+ }
1997
+ }
1998
+ }, state = {
1999
+ routes: [
2000
+ {
2001
+ name: "Foe",
2002
+ state: {
2003
+ index: 1,
2004
+ routes: [
2005
+ {
2006
+ name: "Foo"
2007
+ },
2008
+ {
2009
+ name: "Bas",
2010
+ params: {
2011
+ nip: 5,
2012
+ pwd: 10,
2013
+ id: 15
2014
+ },
2015
+ path
2016
+ }
2017
+ ]
2018
+ }
2019
+ }
2020
+ ]
2021
+ };
2022
+ (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)(path, config)).toEqual(state), (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)((0, import_getPathFromState.getPathFromState)(state, config), config)).toEqual(changePath(state, "/5/10/foos/15"));
2023
+ });
2024
+ import_vitest.test.skip("merges parent patterns if needed", function() {
2025
+ var path = "foo/42/baz/babel", config = {
2026
+ screens: {
2027
+ Foo: {
2028
+ path: "foo/:bar",
2029
+ parse: {
2030
+ bar: Number
2031
+ },
2032
+ screens: {
2033
+ Baz: "baz/:qux"
2034
+ }
2035
+ }
2036
+ }
2037
+ }, state = {
2038
+ routes: [
2039
+ {
2040
+ name: "Foo",
2041
+ params: {
2042
+ bar: 42
2043
+ },
2044
+ state: {
2045
+ routes: [
2046
+ {
2047
+ name: "Baz",
2048
+ params: {
2049
+ qux: "babel"
2050
+ },
2051
+ path
2052
+ }
2053
+ ]
2054
+ }
2055
+ }
2056
+ ]
2057
+ };
2058
+ (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)(path, config)).toEqual(state), (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)((0, import_getPathFromState.getPathFromState)(state, config), config)).toEqual(changePath(state, "/foo/42/baz/babel"));
2059
+ });
2060
+ import_vitest.test.skip("ignores extra slashes in the pattern", function() {
2061
+ var path = "/bar/42", config = {
2062
+ screens: {
2063
+ Foo: {
2064
+ screens: {
2065
+ Bar: {
2066
+ path: "/bar//:id/"
2067
+ }
2068
+ }
2069
+ }
2070
+ }
2071
+ }, state = {
2072
+ routes: [
2073
+ {
2074
+ name: "Foo",
2075
+ state: {
2076
+ routes: [
2077
+ {
2078
+ name: "Bar",
2079
+ params: {
2080
+ id: "42"
2081
+ },
2082
+ path
2083
+ }
2084
+ ]
2085
+ }
2086
+ }
2087
+ ]
2088
+ };
2089
+ (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)(path, config)).toEqual(state), (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)((0, import_getPathFromState.getPathFromState)(state, config), config)).toEqual(state);
2090
+ });
2091
+ import_vitest.test.skip("matches wildcard patterns at root", function() {
2092
+ var path = "/test/bar/42/whatever", config = {
2093
+ screens: {
2094
+ 404: "*",
2095
+ Foo: {
2096
+ screens: {
2097
+ Bar: {
2098
+ path: "/bar/:id/"
2099
+ }
2100
+ }
2101
+ }
2102
+ }
2103
+ }, state = {
2104
+ routes: [
2105
+ {
2106
+ name: "404",
2107
+ path
2108
+ }
2109
+ ]
2110
+ };
2111
+ (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)(path, config)).toEqual(state), (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)((0, import_getPathFromState.getPathFromState)(state, config), config)).toEqual(changePath(state, "/404"));
2112
+ });
2113
+ import_vitest.test.skip("matches wildcard patterns at nested level", function() {
2114
+ var path = "/bar/42/whatever/baz/initt", config = {
2115
+ screens: {
2116
+ Foo: {
2117
+ screens: {
2118
+ Bar: {
2119
+ path: "/bar/:id/",
2120
+ screens: {
2121
+ 404: "*"
2122
+ }
2123
+ }
2124
+ }
2125
+ }
2126
+ }
2127
+ }, state = {
2128
+ routes: [
2129
+ {
2130
+ name: "Foo",
2131
+ state: {
2132
+ routes: [
2133
+ {
2134
+ name: "Bar",
2135
+ params: {
2136
+ id: "42"
2137
+ },
2138
+ state: {
2139
+ routes: [
2140
+ {
2141
+ name: "404",
2142
+ path
2143
+ }
2144
+ ]
2145
+ }
2146
+ }
2147
+ ]
2148
+ }
2149
+ }
2150
+ ]
2151
+ };
2152
+ (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)(path, config)).toEqual(state), (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)((0, import_getPathFromState.getPathFromState)(state, config), config)).toEqual(changePath(state, "/bar/42/404"));
2153
+ });
2154
+ import_vitest.test.skip("matches wildcard patterns at nested level with exact", function() {
2155
+ var path = "/whatever", config = {
2156
+ screens: {
2157
+ Foo: {
2158
+ screens: {
2159
+ Bar: {
2160
+ path: "/bar/:id/",
2161
+ screens: {
2162
+ 404: {
2163
+ path: "*",
2164
+ exact: !0
2165
+ }
2166
+ }
2167
+ },
2168
+ Baz: {}
2169
+ }
2170
+ }
2171
+ }
2172
+ }, state = {
2173
+ routes: [
2174
+ {
2175
+ name: "Foo",
2176
+ state: {
2177
+ routes: [
2178
+ {
2179
+ name: "Bar",
2180
+ state: {
2181
+ routes: [
2182
+ {
2183
+ name: "404",
2184
+ path
2185
+ }
2186
+ ]
2187
+ }
2188
+ }
2189
+ ]
2190
+ }
2191
+ }
2192
+ ]
2193
+ };
2194
+ (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)(path, config)).toEqual(state), (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)((0, import_getPathFromState.getPathFromState)(state, config), config)).toEqual(changePath(state, "/404"));
2195
+ });
2196
+ import_vitest.test.skip("tries to match wildcard patterns at the end", function() {
2197
+ var path = "/bar/42/test", config = {
2198
+ screens: {
2199
+ Foo: {
2200
+ screens: {
2201
+ Bar: {
2202
+ path: "/bar/:id/",
2203
+ screens: {
2204
+ 404: "*",
2205
+ UserProfile: ":userSlug",
2206
+ Test: "test"
2207
+ }
2208
+ }
2209
+ }
2210
+ }
2211
+ }
2212
+ }, state = {
2213
+ routes: [
2214
+ {
2215
+ name: "Foo",
2216
+ state: {
2217
+ routes: [
2218
+ {
2219
+ name: "Bar",
2220
+ params: {
2221
+ id: "42"
2222
+ },
2223
+ state: {
2224
+ routes: [
2225
+ {
2226
+ name: "Test",
2227
+ path
2228
+ }
2229
+ ]
2230
+ }
2231
+ }
2232
+ ]
2233
+ }
2234
+ }
2235
+ ]
2236
+ };
2237
+ (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)(path, config)).toEqual(state), (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)((0, import_getPathFromState.getPathFromState)(state, config), config)).toEqual(state);
2238
+ });
2239
+ import_vitest.test.skip("uses nearest parent wildcard match for unmatched paths", function() {
2240
+ var path = "/bar/42/baz/test", config = {
2241
+ screens: {
2242
+ Foo: {
2243
+ screens: {
2244
+ Bar: {
2245
+ path: "/bar/:id/",
2246
+ screens: {
2247
+ Baz: "baz"
2248
+ }
2249
+ },
2250
+ 404: "*"
2251
+ }
2252
+ }
2253
+ }
2254
+ }, state = {
2255
+ routes: [
2256
+ {
2257
+ name: "Foo",
2258
+ state: {
2259
+ routes: [
2260
+ {
2261
+ name: "404",
2262
+ path
2263
+ }
2264
+ ]
2265
+ }
2266
+ }
2267
+ ]
2268
+ };
2269
+ (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)(path, config)).toEqual(state), (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)((0, import_getPathFromState.getPathFromState)(state, config), config)).toEqual(changePath(state, "/404"));
2270
+ });
2271
+ import_vitest.test.skip("matches screen with overlapping initial path and wildcard", function() {
2272
+ var path = "/bar/42/baz/test/whatever", config = {
2273
+ screens: {
2274
+ Foo: {
2275
+ screens: {
2276
+ Bar: {
2277
+ path: "/bar/:id/",
2278
+ screens: {
2279
+ Baz: "baz"
2280
+ }
2281
+ },
2282
+ Baz: "/bar/:id/*"
2283
+ }
2284
+ }
2285
+ }
2286
+ }, state = {
2287
+ routes: [
2288
+ {
2289
+ name: "Foo",
2290
+ state: {
2291
+ routes: [
2292
+ {
2293
+ name: "Baz",
2294
+ params: {
2295
+ id: "42"
2296
+ },
2297
+ path
2298
+ }
2299
+ ]
2300
+ }
2301
+ }
2302
+ ]
2303
+ };
2304
+ (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)(path, config)).toEqual(state), (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)((0, import_getPathFromState.getPathFromState)(state, config), config)).toEqual(changePath(state, "/bar/42/Baz"));
2305
+ });
2306
+ (0, import_vitest.test)("throws if two screens map to the same pattern", function() {
2307
+ var path = "/bar/42/baz/test";
2308
+ (0, import_vitest.expect)(function() {
2309
+ return (0, import_getStateFromPath.getStateFromPath)(path, {
2310
+ screens: {
2311
+ Foo: {
2312
+ screens: {
2313
+ Bar: {
2314
+ path: "/bar/:id/",
2315
+ screens: {
2316
+ Baz: "baz"
2317
+ }
2318
+ },
2319
+ Bax: "/bar/:id/baz"
2320
+ }
2321
+ }
2322
+ }
2323
+ });
2324
+ }).toThrow("Found conflicting screens with the same pattern. The pattern 'bar/:id/baz' resolves to both 'Foo > Bax' and 'Foo > Bar > Baz'. Patterns must be unique and cannot resolve to more than one screen."), (0, import_vitest.expect)(function() {
2325
+ return (0, import_getStateFromPath.getStateFromPath)(path, {
2326
+ screens: {
2327
+ Foo: {
2328
+ screens: {
2329
+ Bar: {
2330
+ path: "/bar/:id/",
2331
+ screens: {
2332
+ Baz: ""
2333
+ }
2334
+ }
2335
+ }
2336
+ }
2337
+ }
2338
+ });
2339
+ }).not.toThrow();
2340
+ });
2341
+ (0, import_vitest.test)("correctly applies initialRouteName for config with similar route names", function() {
2342
+ var path = "/weekly-earnings", config = {
2343
+ screens: {
2344
+ RootTabs: {
2345
+ screens: {
2346
+ HomeTab: {
2347
+ screens: {
2348
+ Home: "",
2349
+ WeeklyEarnings: "weekly-earnings",
2350
+ EventDetails: "event-details/:eventId"
2351
+ }
2352
+ },
2353
+ EarningsTab: {
2354
+ initialRouteName: "Earnings",
2355
+ path: "earnings",
2356
+ screens: {
2357
+ Earnings: "",
2358
+ WeeklyEarnings: "weekly-earnings"
2359
+ }
2360
+ }
2361
+ }
2362
+ }
2363
+ }
2364
+ }, state = {
2365
+ routes: [
2366
+ {
2367
+ name: "RootTabs",
2368
+ state: {
2369
+ routes: [
2370
+ {
2371
+ name: "HomeTab",
2372
+ state: {
2373
+ routes: [
2374
+ {
2375
+ name: "WeeklyEarnings",
2376
+ path
2377
+ }
2378
+ ]
2379
+ }
2380
+ }
2381
+ ]
2382
+ }
2383
+ }
2384
+ ]
2385
+ };
2386
+ (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)(path, config)).toEqual(state), (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)((0, import_getPathFromState.getPathFromState)(state, config), config)).toEqual(state);
2387
+ });
2388
+ (0, import_vitest.test)("correctly applies initialRouteName for config with similar route names v2", function() {
2389
+ var path = "/earnings/weekly-earnings", config = {
2390
+ screens: {
2391
+ RootTabs: {
2392
+ screens: {
2393
+ HomeTab: {
2394
+ initialRouteName: "Home",
2395
+ screens: {
2396
+ Home: "",
2397
+ WeeklyEarnings: "weekly-earnings"
2398
+ }
2399
+ },
2400
+ EarningsTab: {
2401
+ initialRouteName: "Earnings",
2402
+ path: "earnings",
2403
+ screens: {
2404
+ Earnings: "",
2405
+ WeeklyEarnings: "weekly-earnings"
2406
+ }
2407
+ }
2408
+ }
2409
+ }
2410
+ }
2411
+ }, state = {
2412
+ routes: [
2413
+ {
2414
+ name: "RootTabs",
2415
+ state: {
2416
+ routes: [
2417
+ {
2418
+ name: "EarningsTab",
2419
+ state: {
2420
+ index: 1,
2421
+ routes: [
2422
+ {
2423
+ name: "Earnings"
2424
+ },
2425
+ {
2426
+ name: "WeeklyEarnings",
2427
+ path
2428
+ }
2429
+ ]
2430
+ }
2431
+ }
2432
+ ]
2433
+ }
2434
+ }
2435
+ ]
2436
+ };
2437
+ (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)(path, config)).toEqual(state), (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)((0, import_getPathFromState.getPathFromState)(state, config), config)).toEqual(state);
2438
+ });
2439
+ import_vitest.test.skip("throws when invalid properties are specified in the config", function() {
2440
+ (0, import_vitest.expect)(function() {
2441
+ return (0, import_getStateFromPath.getStateFromPath)("", {
2442
+ path: 42,
2443
+ Foo: "foo",
2444
+ Bar: {
2445
+ path: "bar"
2446
+ }
2447
+ });
2448
+ }).toThrowErrorMatchingInlineSnapshot(`
2449
+ "Found invalid properties in the configuration:
2450
+ - path (expected 'string', got 'number')
2451
+ - Foo (extraneous)
2452
+ - Bar (extraneous)
2453
+
2454
+ You can only specify the following properties:
2455
+ - path (string)
2456
+ - initialRouteName (string)
2457
+ - screens (object)
2458
+
2459
+ If you want to specify configuration for screens, you need to specify them under a 'screens' property.
2460
+
2461
+ See https://reactnavigation.org/docs/configuring-links for more details on how to specify a linking configuration."
2462
+ `), (0, import_vitest.expect)(function() {
2463
+ return (0, import_getStateFromPath.getStateFromPath)("", {
2464
+ screens: {
2465
+ Foo: "foo",
2466
+ Bar: {
2467
+ path: "bar"
2468
+ },
2469
+ Baz: {
2470
+ Qux: {
2471
+ path: "qux"
2472
+ }
2473
+ }
2474
+ }
2475
+ });
2476
+ }).toThrowErrorMatchingInlineSnapshot(`
2477
+ "Found invalid properties in the configuration:
2478
+ - Qux (extraneous)
2479
+
2480
+ You can only specify the following properties:
2481
+ - path (string)
2482
+ - initialRouteName (string)
2483
+ - screens (object)
2484
+ - alias (array)
2485
+ - exact (boolean)
2486
+ - stringify (object)
2487
+ - parse (object)
2488
+
2489
+ If you want to specify configuration for screens, you need to specify them under a 'screens' property.
2490
+
2491
+ See https://reactnavigation.org/docs/configuring-links for more details on how to specify a linking configuration."
2492
+ `), (0, import_vitest.expect)(function() {
2493
+ return (0, import_getStateFromPath.getStateFromPath)("", {
2494
+ path: "foo/:id"
2495
+ });
2496
+ }).toThrowErrorMatchingInlineSnapshot(`"Found invalid path 'foo/:id'. The 'path' in the top-level configuration cannot contain patterns for params."`);
2497
+ });
2498
+ import_vitest.test.skip("encodes special characters in params", function() {
2499
+ var paramWithValidSymbols = "User09-A_Z~!$&'()*+,;=:@__", invalidSymbols = "#?[]{}%<>||", queryString = "user#email@gmail.com=2&4", path = `users/id/${paramWithValidSymbols}${encodeURIComponent(invalidSymbols)}?query=${encodeURIComponent(queryString)}`, config = {
2500
+ path: "users",
2501
+ screens: {
2502
+ Users: {
2503
+ screens: {
2504
+ User: "id/:id"
2505
+ }
2506
+ }
2507
+ }
2508
+ }, state = {
2509
+ routes: [
2510
+ {
2511
+ name: "Users",
2512
+ state: {
2513
+ routes: [
2514
+ {
2515
+ name: "User",
2516
+ params: {
2517
+ id: `${paramWithValidSymbols}${invalidSymbols}`,
2518
+ query: queryString
2519
+ }
2520
+ }
2521
+ ]
2522
+ }
2523
+ }
2524
+ ]
2525
+ };
2526
+ (0, import_vitest.expect)((0, import_getPathFromState.getPathFromState)(state, config)).toBe(`/${path}`), (0, import_vitest.expect)((0, import_getPathFromState.getPathFromState)((0, import_getStateFromPath.getStateFromPath)(path, config), config)).toBe(`/${path}`);
2527
+ });
2528
+ import_vitest.test.skip("resolves nested path params with same name to correct screen", function() {
2529
+ var path = "/foo/42/bar/43", config = {
2530
+ initialRouteName: "Foo",
2531
+ screens: {
2532
+ Foo: {
2533
+ path: "foo/:id",
2534
+ screens: {
2535
+ Bar: {
2536
+ path: "bar/:id"
2537
+ }
2538
+ }
2539
+ }
2540
+ }
2541
+ }, state = {
2542
+ routes: [
2543
+ {
2544
+ name: "Foo",
2545
+ params: {
2546
+ id: "42"
2547
+ },
2548
+ state: {
2549
+ routes: [
2550
+ {
2551
+ name: "Bar",
2552
+ params: {
2553
+ id: "43"
2554
+ },
2555
+ path
2556
+ }
2557
+ ]
2558
+ }
2559
+ }
2560
+ ]
2561
+ };
2562
+ (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)(path, config)).toEqual(state);
2563
+ });
2564
+ (0, import_vitest.test)("parses / same as empty string", function() {
2565
+ var config = {
2566
+ screens: {
2567
+ Foo: {
2568
+ path: "/"
2569
+ },
2570
+ Bar: {
2571
+ path: "bar"
2572
+ }
2573
+ }
2574
+ };
2575
+ (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)("/", config)).toEqual((0, import_getStateFromPath.getStateFromPath)("", config));
2576
+ });
2577
+ import_vitest.test.skip("matches regexp patterns when provided", function() {
2578
+ var config = {
2579
+ screens: {
2580
+ Foo: {
2581
+ path: "foo/:id(\\d+)",
2582
+ parse: {
2583
+ id: Number
2584
+ }
2585
+ },
2586
+ Bar: {
2587
+ path: "foo/:id([a-z]+)"
2588
+ },
2589
+ Baz: {
2590
+ path: "foo/:id(\\d+)/:name([a-z]+)"
2591
+ },
2592
+ Qux: {
2593
+ path: "foo/:id(@[a-z]+)",
2594
+ parse: {
2595
+ id: function(id) {
2596
+ return id.slice(1);
2597
+ }
2598
+ }
2599
+ },
2600
+ Quy: {
2601
+ path: "foo/bar/:category"
2602
+ },
2603
+ Quz: {
2604
+ path: "foo/bar/:special([a-z]+)"
2605
+ },
2606
+ Quu: {
2607
+ path: "foo/bar/baz"
2608
+ },
2609
+ NotFound: {
2610
+ path: "foo/bar/*"
2611
+ }
2612
+ }
2613
+ };
2614
+ (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)("foo/42", config)).toEqual({
2615
+ routes: [
2616
+ {
2617
+ name: "Foo",
2618
+ params: {
2619
+ id: 42
2620
+ },
2621
+ path: "foo/42"
2622
+ }
2623
+ ]
2624
+ }), (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)("foo/bar", config)).toEqual({
2625
+ routes: [
2626
+ {
2627
+ name: "Bar",
2628
+ params: {
2629
+ id: "bar"
2630
+ },
2631
+ path: "foo/bar"
2632
+ }
2633
+ ]
2634
+ }), (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)("foo/42/bar", config)).toEqual({
2635
+ routes: [
2636
+ {
2637
+ name: "Baz",
2638
+ params: {
2639
+ id: "42",
2640
+ name: "bar"
2641
+ },
2642
+ path: "foo/42/bar"
2643
+ }
2644
+ ]
2645
+ }), (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)("foo/@bar", config)).toEqual({
2646
+ routes: [
2647
+ {
2648
+ name: "Qux",
2649
+ params: {
2650
+ id: "bar"
2651
+ },
2652
+ path: "foo/@bar"
2653
+ }
2654
+ ]
2655
+ }), (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)("foo/@bar", config)).toEqual({
2656
+ routes: [
2657
+ {
2658
+ name: "Qux",
2659
+ params: {
2660
+ id: "bar"
2661
+ },
2662
+ path: "foo/@bar"
2663
+ }
2664
+ ]
2665
+ }), (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)("foo/42a", config)).toBeUndefined(), (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)("foo/bar/123", config)).toEqual({
2666
+ routes: [
2667
+ {
2668
+ name: "Quy",
2669
+ params: {
2670
+ category: "123"
2671
+ },
2672
+ path: "foo/bar/123"
2673
+ }
2674
+ ]
2675
+ }), (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)("foo/bar/test", config)).toEqual({
2676
+ routes: [
2677
+ {
2678
+ name: "Quz",
2679
+ params: {
2680
+ special: "test"
2681
+ },
2682
+ path: "foo/bar/test"
2683
+ }
2684
+ ]
2685
+ }), (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)("foo/bar/baz", config)).toEqual({
2686
+ routes: [
2687
+ {
2688
+ name: "Quu",
2689
+ path: "foo/bar/baz"
2690
+ }
2691
+ ]
2692
+ }), (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)("foo/bar/hello/world", config)).toEqual({
2693
+ routes: [
2694
+ {
2695
+ name: "NotFound",
2696
+ path: "foo/bar/hello/world"
2697
+ }
2698
+ ]
2699
+ });
2700
+ });
2701
+ (0, import_vitest.test)("regexp pattern doesn't match slash", function() {
2702
+ var config = {
2703
+ screens: {
2704
+ Foo: {
2705
+ path: "foo/:id([a-z]+\\/)"
2706
+ }
2707
+ }
2708
+ };
2709
+ (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)("foo/bar/", config)).toBeUndefined(), (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)("foo/bar/baz", config)).toBeUndefined(), (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)("foo/bar/baz/qux", config)).toBeUndefined();
2710
+ });
2711
+ import_vitest.test.skip("handles alias for paths", function() {
2712
+ var config = {
2713
+ screens: {
2714
+ Foo: {
2715
+ path: "foo",
2716
+ alias: [
2717
+ "first"
2718
+ ],
2719
+ screens: {
2720
+ Baz: {
2721
+ path: "baz/:id?",
2722
+ parse: {
2723
+ id: function(value) {
2724
+ return value.replace(/@/, "");
2725
+ }
2726
+ },
2727
+ alias: [
2728
+ {
2729
+ path: "second/:id",
2730
+ exact: !0
2731
+ },
2732
+ "third",
2733
+ {
2734
+ path: "fourth/:id",
2735
+ parse: {
2736
+ id: function(value) {
2737
+ return value.replace(/\$/, "");
2738
+ }
2739
+ }
2740
+ }
2741
+ ]
2742
+ },
2743
+ Qux: {
2744
+ path: "qux/:id"
2745
+ }
2746
+ }
2747
+ }
2748
+ }
2749
+ };
2750
+ (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)("foo", config)).toEqual({
2751
+ routes: [
2752
+ {
2753
+ name: "Foo",
2754
+ path: "foo"
2755
+ }
2756
+ ]
2757
+ }), (0, import_vitest.expect)((0, import_getPathFromState.getPathFromState)((0, import_getStateFromPath.getStateFromPath)("foo", config), config)).toBe("/foo"), (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)("first", config)).toEqual({
2758
+ routes: [
2759
+ {
2760
+ name: "Foo",
2761
+ path: "first"
2762
+ }
2763
+ ]
2764
+ }), (0, import_vitest.expect)((0, import_getPathFromState.getPathFromState)((0, import_getStateFromPath.getStateFromPath)("first", config), config)).toBe("/foo"), (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)("foo/baz/@$test", config)).toEqual({
2765
+ routes: [
2766
+ {
2767
+ name: "Foo",
2768
+ state: {
2769
+ routes: [
2770
+ {
2771
+ name: "Baz",
2772
+ params: {
2773
+ id: "$test"
2774
+ },
2775
+ path: "foo/baz/@$test"
2776
+ }
2777
+ ]
2778
+ }
2779
+ }
2780
+ ]
2781
+ }), (0, import_vitest.expect)((0, import_getPathFromState.getPathFromState)((0, import_getStateFromPath.getStateFromPath)("foo/baz/@$test", config), config)).toBe("/foo/baz/$test"), (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)("second/42", config)).toEqual({
2782
+ routes: [
2783
+ {
2784
+ name: "Foo",
2785
+ state: {
2786
+ routes: [
2787
+ {
2788
+ name: "Baz",
2789
+ params: {
2790
+ id: "42"
2791
+ },
2792
+ path: "second/42"
2793
+ }
2794
+ ]
2795
+ }
2796
+ }
2797
+ ]
2798
+ }), (0, import_vitest.expect)((0, import_getPathFromState.getPathFromState)((0, import_getStateFromPath.getStateFromPath)("second/42", config), config)).toBe("/foo/baz/42"), (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)("foo/third", config)).toEqual({
2799
+ routes: [
2800
+ {
2801
+ name: "Foo",
2802
+ state: {
2803
+ routes: [
2804
+ {
2805
+ name: "Baz",
2806
+ path: "foo/third"
2807
+ }
2808
+ ]
2809
+ }
2810
+ }
2811
+ ]
2812
+ }), (0, import_vitest.expect)((0, import_getPathFromState.getPathFromState)((0, import_getStateFromPath.getStateFromPath)("foo/third", config), config)).toBe("/foo/baz"), (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)("foo/fourth/@$test", config)).toEqual({
2813
+ routes: [
2814
+ {
2815
+ name: "Foo",
2816
+ state: {
2817
+ routes: [
2818
+ {
2819
+ name: "Baz",
2820
+ params: {
2821
+ id: "@test"
2822
+ },
2823
+ path: "foo/fourth/@$test"
2824
+ }
2825
+ ]
2826
+ }
2827
+ }
2828
+ ]
2829
+ }), (0, import_vitest.expect)((0, import_getPathFromState.getPathFromState)((0, import_getStateFromPath.getStateFromPath)("foo/fourth/@$test", config), config)).toBe("/foo/baz/@test"), (0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)("foo/qux/42", config)).toEqual({
2830
+ routes: [
2831
+ {
2832
+ name: "Foo",
2833
+ state: {
2834
+ routes: [
2835
+ {
2836
+ name: "Qux",
2837
+ params: {
2838
+ id: "42"
2839
+ },
2840
+ path: "foo/qux/42"
2841
+ }
2842
+ ]
2843
+ }
2844
+ }
2845
+ ]
2846
+ }), (0, import_vitest.expect)((0, import_getPathFromState.getPathFromState)((0, import_getStateFromPath.getStateFromPath)("foo/qux/42", config), config)).toBe("/foo/qux/42");
2847
+ });
2848
+ import_vitest.test.skip("throws if screen has alias but no path", function() {
2849
+ (0, import_vitest.expect)(function() {
2850
+ return (0, import_getStateFromPath.getStateFromPath)("", {
2851
+ screens: {
2852
+ Foo: {
2853
+ alias: [
2854
+ "bar"
2855
+ ]
2856
+ }
2857
+ }
2858
+ });
2859
+ }).toThrow("Screen 'Foo' doesn't specify a 'path'. A 'path' needs to be specified in order to use 'alias'.");
2860
+ });
2861
+ //# sourceMappingURL=getStateFromPath.test.js.map