one
Version:
One is a new React Framework that makes Vite serve both native and web.
1,897 lines (1,896 loc) • 76.7 kB
JavaScript
"use strict";
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) {
return (0, import_immer.produce)(state, function(draftState) {
var route = (0, import_findFocusedRoute.findFocusedRoute)(draftState);
route.path = path;
});
};
(0, import_vitest.test)("returns undefined for invalid path", function() {
(0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)("//")).toBeUndefined();
});
import_vitest.test.skip("converts path string to initial state", function() {
var path = "foo/bar/baz%20qux?author=jane%20%26%20co&valid=true", state = {
routes: [
{
name: "foo",
state: {
routes: [
{
name: "bar",
state: {
routes: [
{
name: "baz qux",
params: {
author: "jane & co",
valid: "true"
},
path
}
]
}
}
]
}
}
]
};
(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"));
});
import_vitest.test.skip("decodes encoded params in path", function() {
var path = "/foo/bar/bar_%23_foo", config = {
screens: {
Foo: {
path: "foo",
screens: {
Bar: {
path: "/bar/:id"
}
}
}
}
}, state = {
routes: [
{
name: "Foo",
state: {
routes: [
{
name: "Bar",
params: {
id: "bar_#_foo"
},
path
}
]
}
}
]
};
(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);
});
import_vitest.test.skip("decodes encoded params in path that have encoded /", function() {
var path = "/foo/bar/bar_%2F_foo", config = {
screens: {
Foo: {
path: "foo",
screens: {
Bar: {
path: "/bar/:id"
}
}
}
}
}, state = {
routes: [
{
name: "Foo",
state: {
routes: [
{
name: "Bar",
params: {
id: "bar_/_foo"
},
path
}
]
}
}
]
};
(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);
});
import_vitest.test.skip("converts path string to initial state with config", function() {
var path = "/foo/bar/sweet/apple/baz/jane?count=10&answer=42&valid=true", config = {
screens: {
Foo: {
path: "foo",
screens: {
Bar: {
path: "bar/:type/:fruit",
screens: {
Baz: {
path: "baz/:author",
parse: {
author: function(author) {
return author.replace(/^\w/, function(c) {
return c.toUpperCase();
});
},
count: Number,
valid: Boolean
},
stringify: {
author: function(author) {
return author.toLowerCase();
}
}
}
}
}
}
}
}
}, state = {
routes: [
{
name: "Foo",
state: {
routes: [
{
name: "Bar",
params: {
fruit: "apple",
type: "sweet"
},
state: {
routes: [
{
name: "Baz",
params: {
author: "Jane",
count: 10,
answer: "42",
valid: !0
},
path
}
]
}
}
]
}
}
]
};
(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);
});
(0, import_vitest.test)("handles leading slash when converting", function() {
var path = "/foo/bar/?count=42";
(0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)(path)).toEqual({
routes: [
{
name: "foo",
state: {
routes: [
{
name: "bar",
params: {
count: "42"
},
path
}
]
}
}
]
});
});
(0, import_vitest.test)("handles ending slash when converting", function() {
var path = "foo/bar/?count=42";
(0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)(path)).toEqual({
routes: [
{
name: "foo",
state: {
routes: [
{
name: "bar",
params: {
count: "42"
},
path
}
]
}
}
]
});
});
(0, import_vitest.test)("handles route without param", function() {
var path = "foo/bar", state = {
routes: [
{
name: "foo",
state: {
routes: [
{
name: "bar",
path
}
]
}
}
]
};
(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"));
});
import_vitest.test.skip("converts path string to initial state with config with nested screens", function() {
var path = "/foe/bar/sweet/apple/baz/jane?count=10&answer=42&valid=true", config = {
screens: {
Foo: {
path: "foo",
screens: {
Foe: {
path: "foe",
exact: !0,
screens: {
Bar: {
path: "bar/:type/:fruit",
screens: {
Baz: {
path: "baz/:author",
parse: {
author: function(author) {
return author.replace(/^\w/, function(c) {
return c.toUpperCase();
});
},
count: Number,
valid: Boolean
},
stringify: {
author: function(author) {
return author.toLowerCase();
}
}
}
}
}
}
}
}
}
}
}, state = {
routes: [
{
name: "Foo",
state: {
routes: [
{
name: "Foe",
state: {
routes: [
{
name: "Bar",
params: {
fruit: "apple",
type: "sweet"
},
state: {
routes: [
{
name: "Baz",
params: {
author: "Jane",
count: 10,
answer: "42",
valid: !0
},
path
}
]
}
}
]
}
}
]
}
}
]
};
(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);
});
import_vitest.test.skip("converts path string to initial state with config with nested screens and unused parse functions", function() {
var path = "/foe/baz/jane?count=10&answer=42&valid=true", config = {
screens: {
Foo: {
path: "foo",
screens: {
Foe: {
path: "foe",
exact: !0,
screens: {
Baz: {
path: "baz/:author",
parse: {
author: function(author) {
return author.replace(/^\w/, function(c) {
return c.toUpperCase();
});
},
count: Number,
valid: Boolean,
id: Boolean
}
}
}
}
}
}
}
}, state = {
routes: [
{
name: "Foo",
state: {
routes: [
{
name: "Foe",
state: {
routes: [
{
name: "Baz",
params: {
author: "Jane",
count: 10,
answer: "42",
valid: !0
},
path
}
]
}
}
]
}
}
]
};
(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"));
});
import_vitest.test.skip("handles nested object with unused configs and with parse in it", function() {
var path = "/bar/sweet/apple/foe/bis/jane?count=10&answer=42&valid=true", config = {
screens: {
Bar: {
path: "bar/:type/:fruit",
screens: {
Foo: {
screens: {
Foe: {
path: "foe",
screens: {
Baz: {
screens: {
Bos: {
path: "bos",
exact: !0
},
Bis: {
path: "bis/:author",
stringify: {
author: function(author) {
return author.replace(/^\w/, function(c) {
return c.toLowerCase();
});
}
},
parse: {
author: function(author) {
return author.replace(/^\w/, function(c) {
return c.toUpperCase();
});
},
count: Number,
valid: Boolean
}
}
}
}
}
}
}
}
}
}
}
}, state = {
routes: [
{
name: "Bar",
params: {
fruit: "apple",
type: "sweet"
},
state: {
routes: [
{
name: "Foo",
state: {
routes: [
{
name: "Foe",
state: {
routes: [
{
name: "Baz",
state: {
routes: [
{
name: "Bis",
params: {
author: "Jane",
count: 10,
answer: "42",
valid: !0
},
path
}
]
}
}
]
}
}
]
}
}
]
}
}
]
};
(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);
});
(0, import_vitest.test)("handles parse in nested object for second route depth", function() {
var path = "/baz", config = {
screens: {
Foo: {
path: "foo",
screens: {
Foe: {
path: "foe",
exact: !0
},
Bar: {
path: "bar",
exact: !0,
screens: {
Baz: {
path: "baz",
exact: !0
}
}
}
}
}
}
}, state = {
routes: [
{
name: "Foo",
state: {
routes: [
{
name: "Bar",
state: {
routes: [
{
name: "Baz",
path
}
]
}
}
]
}
}
]
};
(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);
});
(0, import_vitest.test)("handles parse in nested object for second route depth and and path and parse in roots", function() {
var path = "/baz", config = {
screens: {
Foo: {
path: "foo/:id",
parse: {
id: Number
},
stringify: {
id: function(id) {
return `id=${id}`;
}
},
screens: {
Foe: "foe",
Bar: {
screens: {
Baz: {
path: "baz",
exact: !0
}
}
}
}
}
}
}, state = {
routes: [
{
name: "Foo",
state: {
routes: [
{
name: "Bar",
state: {
routes: [
{
name: "Baz",
path
}
]
}
}
]
}
}
]
};
(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);
});
import_vitest.test.skip("handles path at top level", function() {
var path = "/foo/fruits/apple", config = {
path: "foo",
screens: {
Foo: {
screens: {
Fruits: "fruits/:fruit"
}
}
}
}, state = {
routes: [
{
name: "Foo",
state: {
routes: [
{
name: "Fruits",
params: {
fruit: "apple"
},
path
}
]
}
}
]
};
(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);
});
(0, import_vitest.test)("handles initialRouteName at top level", function() {
var path = "/baz", config = {
initialRouteName: "Boo",
screens: {
Foo: {
screens: {
Foe: "foe",
Bar: {
screens: {
Baz: "baz"
}
}
}
}
}
}, state = {
index: 1,
routes: [
{
name: "Boo"
},
{
name: "Foo",
state: {
routes: [
{
name: "Bar",
state: {
routes: [
{
name: "Baz",
path
}
]
}
}
]
}
}
]
};
(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);
});
(0, import_vitest.test)("handles initialRouteName inside a screen", function() {
var path = "/baz", config = {
screens: {
Foo: {
initialRouteName: "Foe",
screens: {
Foe: "foe",
Bar: {
screens: {
Baz: "baz"
}
}
}
}
}
}, state = {
routes: [
{
name: "Foo",
state: {
index: 1,
routes: [
{
name: "Foe"
},
{
name: "Bar",
state: {
routes: [
{
name: "Baz",
path
}
]
}
}
]
}
}
]
};
(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);
});
(0, import_vitest.test)("handles initialRouteName included in path", function() {
var path = "/baz", config = {
screens: {
Foo: {
initialRouteName: "Foe",
screens: {
Foe: {
screens: {
Baz: "baz"
}
},
Bar: "bar"
}
}
}
}, state = {
routes: [
{
name: "Foo",
state: {
routes: [
{
name: "Foe",
state: {
routes: [
{
name: "Baz",
path
}
]
}
}
]
}
}
]
};
(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);
});
import_vitest.test.skip("handles two initialRouteNames", function() {
var path = "/bar/sweet/apple/foe/bis/jane?answer=42&count=10&valid=true", config = {
screens: {
Bar: {
path: "bar/:type/:fruit",
screens: {
Foo: {
screens: {
Foe: {
path: "foe",
screens: {
Baz: {
initialRouteName: "Bos",
screens: {
Bos: {
path: "bos",
exact: !0
},
Bis: {
path: "bis/:author",
stringify: {
author: function(author) {
return author.replace(/^\w/, function(c) {
return c.toLowerCase();
});
}
},
parse: {
author: function(author) {
return author.replace(/^\w/, function(c) {
return c.toUpperCase();
});
},
count: Number,
valid: Boolean
}
}
}
}
}
}
}
}
}
}
}
}, state = {
routes: [
{
name: "Bar",
params: {
fruit: "apple",
type: "sweet"
},
state: {
routes: [
{
name: "Foo",
state: {
routes: [
{
name: "Foe",
state: {
routes: [
{
name: "Baz",
state: {
index: 1,
routes: [
{
name: "Bos"
},
{
name: "Bis",
params: {
answer: "42",
author: "Jane",
count: 10,
valid: !0
},
path
}
]
}
}
]
}
}
]
}
}
]
}
}
]
};
(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);
});
import_vitest.test.skip("accepts initialRouteName without config for it", function() {
var path = "/bar/sweet/apple/foe/bis/jane?answer=42&count=10&valid=true", config = {
screens: {
Bar: {
path: "bar/:type/:fruit",
screens: {
Foo: {
screens: {
Foe: {
path: "foe",
screens: {
Baz: {
initialRouteName: "Bas",
screens: {
Bos: {
path: "bos",
exact: !0
},
Bis: {
path: "bis/:author",
stringify: {
author: function(author) {
return author.replace(/^\w/, function(c) {
return c.toLowerCase();
});
}
},
parse: {
author: function(author) {
return author.replace(/^\w/, function(c) {
return c.toUpperCase();
});
},
count: Number,
valid: Boolean
}
}
}
}
}
}
}
}
}
}
}
}, state = {
routes: [
{
name: "Bar",
params: {
fruit: "apple",
type: "sweet"
},
state: {
routes: [
{
name: "Foo",
state: {
routes: [
{
name: "Foe",
state: {
routes: [
{
name: "Baz",
state: {
index: 1,
routes: [
{
name: "Bas"
},
{
name: "Bis",
params: {
answer: "42",
author: "Jane",
count: 10,
valid: !0
},
path
}
]
}
}
]
}
}
]
}
}
]
}
}
]
};
(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);
});
(0, import_vitest.test)("returns undefined if no matching screen is present (top level path)", function() {
var path = "/foo/bar", config = {
path: "qux",
screens: {
Foo: {
screens: {
Foe: "foo",
Bar: {
screens: {
Baz: "bar"
}
}
}
}
}
};
(0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)(path, config)).toBeUndefined();
});
(0, import_vitest.test)("returns undefined if no matching screen is present", function() {
var path = "/baz", config = {
screens: {
Foo: {
path: "foo",
screens: {
Foe: "foe",
Bar: {
screens: {
Baz: "baz"
}
}
}
}
}
};
(0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)(path, config)).toBeUndefined();
});
(0, import_vitest.test)("returns undefined if path is empty and no matching screen is present", function() {
var path = "", config = {
screens: {
Foo: {
screens: {
Foe: "foe",
Bar: {
screens: {
Baz: "baz"
}
}
}
}
}
};
(0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)(path, config)).toBeUndefined();
});
import_vitest.test.skip("returns matching screen if path is empty", function() {
var path = "", config = {
screens: {
Foo: {
screens: {
Foe: "foe",
Bar: {
screens: {
Qux: "",
Baz: "baz"
}
}
}
}
}
}, state = {
routes: [
{
name: "Foo",
state: {
routes: [
{
name: "Bar",
state: {
routes: [
{
name: "Qux",
path
}
]
}
}
]
}
}
]
};
(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, ""));
});
import_vitest.test.skip("returns matching screen if path is only slash", function() {
var path = "/", config = {
screens: {
Foo: {
screens: {
Foe: "foe",
Bar: {
screens: {
Qux: "",
Baz: "baz"
}
}
}
}
}
}, state = {
routes: [
{
name: "Foo",
state: {
routes: [
{
name: "Bar",
state: {
routes: [
{
name: "Qux",
path: ""
}
]
}
}
]
}
}
]
};
(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, ""));
});
(0, import_vitest.test)("returns matching screen with params if path is empty", function() {
var path = "?foo=42", config = {
screens: {
Foo: {
screens: {
Foe: "foe",
Bar: {
screens: {
Qux: {
path: "",
parse: {
foo: Number
}
},
Baz: "baz"
}
}
}
}
}
}, state = {
routes: [
{
name: "Foo",
state: {
routes: [
{
name: "Bar",
state: {
routes: [
{
name: "Qux",
params: {
foo: 42
},
path
}
]
}
}
]
}
}
]
};
(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"));
});
(0, import_vitest.test)("doesn't match nested screen if path is empty", function() {
var config = {
screens: {
Foo: {
screens: {
Foe: "foe",
Bar: {
path: "bar",
screens: {
Qux: {
path: "",
parse: {
foo: Number
}
}
}
}
}
}
}
}, path = "";
(0, import_vitest.expect)((0, import_getStateFromPath.getStateFromPath)(path, config)).toBeUndefined();
});
import_vitest.test.skip("chooses more exhaustive pattern", function() {
var path = "/foo/5", config = {
screens: {
Foe: {
path: "/",
initialRouteName: "Foo",
screens: {
Foo: "foo",
Bis: {
path: "foo/:id",
parse: {
id: Number
}
}
}
}
}
}, state = {
routes: [
{
name: "Foe",
state: {
index: 1,
routes: [
{
name: "Foo"
},
{
name: "Bis",
params: {
id: 5
},
path
}
]
}
}
]
};
(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);
});
(0, import_vitest.test)("handles same paths beginnings", function() {
var path = "/foos", config = {
screens: {
Foe: {
path: "/",
initialRouteName: "Foo",
screens: {
Foo: "foo",
Bis: {
path: "foos"
}
}
}
}
}, state = {
routes: [
{
name: "Foe",
state: {
index: 1,
routes: [
{
name: "Foo"
},
{
name: "Bis",
path
}
]
}
}
]
};
(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);
});
import_vitest.test.skip("handles same paths beginnings with params", function() {
var path = "/foos/5", config = {
screens: {
Foe: {
path: "/",
initialRouteName: "Foo",
screens: {
Foo: "foo",
Bis: {
path: "foos/:id",
parse: {
id: Number
}
}
}
}
}
}, state = {
routes: [
{
name: "Foe",
state: {
index: 1,
routes: [
{
name: "Foo"
},
{
name: "Bis",
params: {
id: 5
},
path
}
]
}
}
]
};
(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);
});
import_vitest.test.skip("handles not taking path with too many segments", function() {
var path = "/foos/5", config = {
screens: {
Foe: {
path: "/",
initialRouteName: "Foo",
screens: {
Foo: "foo",
Bis: {
path: "foos/:id",
parse: {
id: Number
}
},
Bas: {
path: "foos/:id/:nip",
parse: {
id: Number,
pwd: Number
}
}
}
}
}
}, state = {
routes: [
{
name: "Foe",
state: {
index: 1,
routes: [
{
name: "Foo"
},
{
name: "Bis",
params: {
id: 5
},
path
}
]
}
}
]
};
(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);
});
import_vitest.test.skip("handles differently ordered params v1", function() {
var path = "/foos/5/res/20", config = {
screens: {
Foe: {
path: "/",
initialRouteName: "Foo",
screens: {
Foo: "foo",
Bis: {
path: "foos/:id",
parse: {
id: Number
}
},
Bas: {
path: "foos/:id/res/:pwd",
parse: {
id: Number,
pwd: Number
}
}
}
}
}
}, state = {
routes: [
{
name: "Foe",
state: {
index: 1,
routes: [
{
name: "Foo"
},
{
name: "Bas",
params: {
id: 5,
pwd: 20
},
path
}
]
}
}
]
};
(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);
});
import_vitest.test.skip("handles differently ordered params v2", function() {
var path = "/5/20/foos/res", config = {
screens: {
Foe: {
path: "/",
initialRouteName: "Foo",
screens: {
Foo: "foo",
Bis: {
path: "foos/:id",
parse: {
id: Number
}
},
Bas: {
path: ":id/:pwd/foos/res",
parse: {
id: Number,
pwd: Number
}
}
}
}
}
}, state = {
routes: [
{
name: "Foe",
state: {
index: 1,
routes: [
{
name: "Foo"
},
{
name: "Bas",
params: {
id: 5,
pwd: 20
},
path
}
]
}
}
]
};
(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);
});
import_vitest.test.skip("handles differently ordered params v3", function() {
var path = "/foos/5/20/res", config = {
screens: {
Foe: {
path: "/",
initialRouteName: "Foo",
screens: {
Foo: "foo",
Bis: {
path: "foos/:id",
parse: {
id: Number
}
},
Bas: {
path: "foos/:id/:pwd/res",
parse: {
id: Number,
pwd: Number
}
}
}
}
}
}, state = {
routes: [
{
name: "Foe",
state: {
index: 1,
routes: [
{
name: "Foo"
},
{
name: "Bas",
params: {
id: 5,
pwd: 20
},
path
}
]
}
}
]
};
(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);
});
import_vitest.test.skip("handles differently ordered params v4", function() {
var path = "5/foos/res/20", config = {
screens: {
Foe: {
path: "/",
initialRouteName: "Foo",
screens: {
Foo: "foo",
Bis: {
path: "foos/:id",
parse: {
id: Number
}
},
Bas: {
path: ":id/foos/res/:pwd",
parse: {
id: Number,
pwd: Number
}
}
}
}
}
}, state = {
routes: [
{
name: "Foe",
state: {
index: 1,
routes: [
{
name: "Foo"
},
{
name: "Bas",
params: {
id: 5,
pwd: 20
},
path
}
]
}
}
]
};
(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"));
});
import_vitest.test.skip("handles simple optional params", function() {
var path = "/foos/5", config = {
screens: {
Foe: {
path: "/",
initialRouteName: "Foo",
screens: {
Foo: "foo",
Bis: {
path: "foo/:id",
parse: {
id: Number
}
},
Bas: {
path: "foos/:id/:nip?",
parse: {
id: Number,
nip: Number
}
}
}
}
}
}, state = {
routes: [
{
name: "Foe",
state: {
index: 1,
routes: [
{
name: "Foo"
},
{
name: "Bas",
params: {
id: 5
},
path
}
]
}
}
]
};
(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);
});
import_vitest.test.skip("handle 2 optional params at the end v1", function() {
var path = "/foos/5", config = {
screens: {
Foe: {
path: "/",
initialRouteName: "Foo",
screens: {
Foo: "foo",
Bis: {
path: "foo/:id",
parse: {
id: Number
}
},
Bas: {
path: "foos/:id/:nip?/:pwd?",
parse: {
id: Number,
nip: Number
}
}
}
}
}
}, state = {
routes: [
{
name: "Foe",
state: {
index: 1,
routes: [
{
name: "Foo"
},
{
name: "Bas",
params: {
id: 5
},
path
}
]
}
}
]
};
(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);
});
import_vitest.test.skip("handle 2 optional params at the end v2", function() {
var path = "/foos/5/10", config = {
screens: {
Foe: {
path: "/",
initialRouteName: "Foo",
screens: {
Foo: "foo",
Bis: {
path: "foo/:id",
parse: {
id: Number
}
},
Bas: {
path: "foos/:id/:nip?/:pwd?",
parse: {
id: Number,
nip: Number
}
}
}
}
}
}, state = {
routes: [
{
name: "Foe",
state: {
index: 1,
routes: [
{
name: "Foo"
},
{
name: "Bas",
params: {
id: 5,
nip: 10
},
path
}
]
}
}
]
};
(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);
});
import_vitest.test.skip("handle 2 optional params at the end v3", function() {
var path = "/foos/5/10/15", config = {
screens: {
Foe: {
path: "/",
initialRouteName: "Foo",
screens: {
Foo: "foo",
Bis: {
path: "foo/:id",
parse: {
id: Number
}
},
Bas: {
path: "foos/:id/:nip?/:pwd?",
parse: {
id: Number,
nip: Number,
pwd: Number
}
}
}
}
}
}, state = {
routes: [
{
name: "Foe",
state: {
index: 1,
routes: [
{
name: "Foo"
},
{
name: "Bas",
params: {
id: 5,
nip: 10,
pwd: 15
},
path
}
]
}
}
]
};
(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);
});
import_vitest.test.skip("handle optional params in the middle v1", function() {
var path = "/foos/5/10", config = {
screens: {
Foe: {
path: "/",
initialRouteName: "Foo",
screens: {
Foo: "foo",
Bis: {
path: "foo/:id",
parse: {
id: Number
}
},
Bas: {
path: "foos/:id/:nip?/:pwd",
parse: {
id: Number,
nip: Number,
pwd: Number
}
}
}
}
}
}, state = {
routes: [
{
name: "Foe",
state: {
index: 1,
routes: [
{
name: "Foo"
},
{
name: "Bas",
params: {
id: 5,
pwd: 10
},
path
}
]
}
}
]
};
(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);
});
import_vitest.test.skip("handle optional params in the middle v2", function() {
var path = "/foos/5/10/15", config = {
screens: {
Foe: {
path: "/",
initialRouteName: "Foo",
screens: {
Foo: "foo",
Bis: {
path: "foo/:id",
parse: {
id: Number
}
},
Bas: {
path: "foos/:id/:nip?/:pwd",
parse: {
id: Number,
nip: Number,
pwd: Number
}
}
}
}
}
}, state = {
routes: [
{
name: "Foe",
state: {
index: 1,
routes: [
{
name: "Foo"
},
{
name: "Bas",
params: {
id: 5,
nip: 10,
pwd: 15
},
path
}
]
}
}
]
};
(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);
});
import_vitest.test.skip("handle optional params in the middle v3", function() {
var path = "/foos/5/10/15", config = {
screens: {
Foe: {
path: "/",
initialRouteName: "Foo",
screens: {
Foo: "foo",
Bis: {
path: "foo/:id",
parse: {
id: Number
}
},
Bas: {
path: "foos/:id/:nip?/:pwd/:smh",
parse: {
id: Number,
nip: Number,
pwd: Number,
smh: Number
}
}
}
}
}
}, state = {
routes: [
{
name: "Foe",
state: {
index: 1,
routes: [
{
name: "Foo"
},
{
name: "Bas",
params: {
id: 5,
pwd: 10,
smh: 15
},
path
}
]
}
}
]
};
(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);
});
import_vitest.test.skip("handle optional params in the middle v4", function() {
var path = "/foos/5/10", config = {
screens: {
Foe: {
path: "/",
initialRouteName: "Foo",
screens: {
Foo: "foo",
Bis: {
path: "foo/:id",
parse: {
id: Number
}
},
Bas: {
path: "foos/:nip?/:pwd/:smh?/:id",
parse: {
id: Number,
nip: Number,
pwd: Number,
smh: Number
}
}
}
}
}
}, state = {
routes: [
{
name: "Foe",
state: {
index: 1,
routes: [
{
name: "Foo"
},
{
name: "Bas",
params: {
pwd: 5,
id: 10
},
path
}
]
}
}
]
};
(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);
});
import_vitest.test.skip("handle optional params in the middle v5", function() {
var path = "/foos/5/10/15", config = {
screens: {
Foe: {
path: "/",
initialRouteName: "Foo",
screens: {
Foo: "foo",
Bis: {
path: "foo/:id",
parse: {
id: Number
}
},
Bas: {
path: "foos/:nip?/:pwd/:smh?/:id",
parse: {
id: Number,
nip: Number,
pwd: Number,
smh: Number
}
}
}
}
}
}, state = {
routes: [
{