one
Version:
One is a new React Framework that makes Vite serve both native and web.
1,562 lines (1,561 loc) • 36.1 kB
JavaScript
import { expect, test } from "vitest";
import { getPathFromState } from "../getPathFromState";
import { getStateFromPath } from "../getStateFromPath";
test("converts state to path string", () => {
const state = {
routes: [
{
name: "foo",
state: {
index: 1,
routes: [
{ name: "boo" },
{
name: "bar",
params: { fruit: "apple" },
state: {
routes: [
{
name: "baz qux",
params: { author: "jane", valid: !0 }
}
]
}
}
]
}
}
]
}, path = "/foo/bar/baz%20qux?author=jane&valid=true";
expect(getPathFromState(state)).toBe(path), expect(getPathFromState(getStateFromPath(path))).toBe(path);
});
test("converts state to path string with config", () => {
const path = "/few/bar/sweet/apple/baz/jane?id=x10&valid=true", config = {
screens: {
Foo: {
path: "few",
screens: {
Bar: {
path: "bar/:type/:fruit",
screens: {
Baz: {
path: "baz/:author",
parse: {
author: (author) => author.replace(/^\w/, (c) => c.toUpperCase()),
id: (id) => Number(id.replace(/^x/, "")),
valid: Boolean
},
stringify: {
author: (author) => author.toLowerCase(),
id: (id) => `x${id}`
}
}
}
}
}
}
}
};
expect(getPathFromState({
routes: [
{
name: "Foo",
state: {
index: 1,
routes: [
{ name: "boo" },
{
name: "Bar",
params: { fruit: "apple", type: "sweet", avaliable: !1 },
state: {
routes: [
{
name: "Baz",
params: {
author: "Jane",
id: 10,
valid: !0
}
}
]
}
}
]
}
}
]
}, config)).toBe(path), expect(
getPathFromState(getStateFromPath(path, config), config)
).toBe(path);
});
test("prepends trailing slash to path", () => {
expect(
getPathFromState({
routes: [
{
name: "foo",
state: {
routes: [{ name: "bar" }]
}
}
]
})
).toBe("/foo/bar"), expect(
getPathFromState({
routes: [
{
name: "foo",
state: {
routes: [{ name: "bar", path: "foo/bar" }]
}
}
]
})
).toBe("/foo/bar");
});
test("handles route without param", () => {
const path = "/foo/bar";
expect(getPathFromState({
routes: [
{
name: "foo",
state: {
routes: [{ name: "bar" }]
}
}
]
})).toBe(path), expect(getPathFromState(getStateFromPath(path))).toBe(path);
});
test("doesn't add query param for empty params", () => {
const path = "/foo";
expect(getPathFromState({
routes: [
{
name: "foo",
params: {}
}
]
})).toBe(path), expect(getPathFromState(getStateFromPath(path))).toBe(path);
});
test("handles state with config with nested screens", () => {
const path = "/foo/foe/bar/sweet/apple/baz/jane?answer=42&count=10&valid=true", config = {
screens: {
Foo: {
path: "foo",
screens: {
Foe: {
path: "foe",
screens: {
Bar: {
path: "bar/:type/:fruit",
screens: {
Baz: {
path: "baz/:author",
parse: {
author: (author) => author.replace(/^\w/, (c) => c.toUpperCase()),
count: Number,
valid: Boolean
},
stringify: {
author: (author) => author.toLowerCase(),
id: (id) => `x${id}`,
unknown: (_) => "x"
}
}
}
}
}
}
}
}
}
};
expect(getPathFromState({
routes: [
{
name: "Foo",
state: {
routes: [
{
name: "Foe",
state: {
routes: [
{
name: "Bar",
params: { fruit: "apple", type: "sweet" },
state: {
routes: [
{
name: "Baz",
params: {
answer: "42",
author: "Jane",
count: "10",
valid: !0
}
}
]
}
}
]
}
}
]
}
}
]
}, config)).toBe(path), expect(
getPathFromState(getStateFromPath(path, config), config)
).toBe(path);
});
test("handles state with config with nested screens and exact", () => {
const path = "/foe/bar/sweet/apple/baz/jane?answer=42&count=10&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: (author) => author.replace(/^\w/, (c) => c.toUpperCase()),
count: Number,
valid: Boolean
},
stringify: {
author: (author) => author.toLowerCase(),
id: (id) => `x${id}`,
unknown: (_) => "x"
}
}
}
}
}
}
}
}
}
};
expect(getPathFromState({
routes: [
{
name: "Foo",
state: {
routes: [
{
name: "Foe",
state: {
routes: [
{
name: "Bar",
params: { fruit: "apple", type: "sweet" },
state: {
routes: [
{
name: "Baz",
params: {
answer: "42",
author: "Jane",
count: "10",
valid: !0
}
}
]
}
}
]
}
}
]
}
}
]
}, config)).toBe(path), expect(
getPathFromState(getStateFromPath(path, config), config)
).toBe(path);
});
test("handles state with config with nested screens and unused configs", () => {
const path = "/foo/foe/baz/jane?answer=42&count=10&valid=true", config = {
screens: {
Foo: {
path: "foo",
screens: {
Foe: {
path: "foe",
screens: {
Baz: {
path: "baz/:author",
parse: {
author: (author) => author.replace(/^\w/, (c) => c.toUpperCase()),
count: Number,
valid: Boolean
},
stringify: {
author: (author) => author.replace(/^\w/, (c) => c.toLowerCase()),
unknown: (_) => "x"
}
}
}
}
}
}
}
};
expect(getPathFromState({
routes: [
{
name: "Foo",
state: {
routes: [
{
name: "Foe",
state: {
routes: [
{
name: "Baz",
params: {
answer: "42",
author: "Jane",
count: 10,
valid: !0
}
}
]
}
}
]
}
}
]
}, config)).toBe(path), expect(
getPathFromState(getStateFromPath(path, config), config)
).toBe(path);
});
test("handles state with config with nested screens and unused configs with exact", () => {
const path = "/foe/baz/jane?answer=42&count=10&valid=true", config = {
screens: {
Foo: {
path: "foo",
screens: {
Foe: {
path: "foe",
exact: !0,
screens: {
Baz: {
path: "baz/:author",
parse: {
author: (author) => author.replace(/^\w/, (c) => c.toUpperCase()),
count: Number,
valid: Boolean
},
stringify: {
author: (author) => author.replace(/^\w/, (c) => c.toLowerCase()),
unknown: (_) => "x"
}
}
}
}
}
}
}
};
expect(getPathFromState({
routes: [
{
name: "Foo",
state: {
routes: [
{
name: "Foe",
state: {
routes: [
{
name: "Baz",
params: {
answer: "42",
author: "Jane",
count: 10,
valid: !0
}
}
]
}
}
]
}
}
]
}, config)).toBe(path), expect(
getPathFromState(getStateFromPath(path, config), config)
).toBe(path);
});
test("handles nested object with stringify in it", () => {
const path = "/bar/sweet/apple/foo/bis/jane?answer=42&count=10&valid=true", config = {
screens: {
Bar: {
path: "bar/:type/:fruit",
screens: {
Foo: {
path: "foo",
screens: {
Foe: {
path: "foe"
},
Baz: {
screens: {
Bos: "bos",
Bis: {
path: "bis/:author",
stringify: {
author: (author) => author.replace(/^\w/, (c) => c.toLowerCase())
},
parse: {
author: (author) => author.replace(/^\w/, (c) => c.toUpperCase()),
count: Number,
valid: Boolean
}
}
}
}
}
}
}
}
}
};
expect(getPathFromState({
routes: [
{
name: "Bar",
params: { fruit: "apple", type: "sweet" },
state: {
routes: [
{
name: "Foo",
state: {
routes: [
{
name: "Baz",
state: {
routes: [
{
name: "Bis",
params: {
answer: "42",
author: "Jane",
count: 10,
valid: !0
}
}
]
}
}
]
}
}
]
}
}
]
}, config)).toBe(path), expect(
getPathFromState(getStateFromPath(path, config), config)
).toBe(path);
});
test("handles nested object with stringify in it with exact", () => {
const path = "/bis/jane?answer=42&count=10&valid=true", config = {
screens: {
Bar: {
path: "bar/:type/:fruit",
screens: {
Foo: {
path: "foo",
screens: {
Foe: {
path: "foe"
},
Baz: {
path: "baz",
screens: {
Bos: "bos",
Bis: {
path: "bis/:author",
exact: !0,
stringify: {
author: (author) => author.replace(/^\w/, (c) => c.toLowerCase())
},
parse: {
author: (author) => author.replace(/^\w/, (c) => c.toUpperCase()),
count: Number,
valid: Boolean
}
}
}
}
}
}
}
}
}
};
expect(getPathFromState({
routes: [
{
name: "Bar",
params: { fruit: "apple", type: "sweet" },
state: {
routes: [
{
name: "Foo",
state: {
routes: [
{
name: "Baz",
state: {
routes: [
{
name: "Bis",
params: {
answer: "42",
author: "Jane",
count: 10,
valid: !0
}
}
]
}
}
]
}
}
]
}
}
]
}, config)).toBe(path), expect(
getPathFromState(getStateFromPath(path, config), config)
).toBe(path);
});
test("handles nested object for second route depth", () => {
const path = "/foo/bar/baz", config = {
screens: {
Foo: {
path: "foo",
screens: {
Foe: "foe",
Bar: {
path: "bar",
screens: {
Baz: "baz"
}
}
}
}
}
};
expect(getPathFromState({
routes: [
{
name: "Foo",
state: {
routes: [
{
name: "Bar",
state: {
routes: [{ name: "Baz" }]
}
}
]
}
}
]
}, config)).toBe(path), expect(
getPathFromState(getStateFromPath(path, config), config)
).toBe(path);
});
test("handles nested object for second route depth with exact", () => {
const path = "/baz", config = {
screens: {
Foo: {
path: "foo",
screens: {
Foe: "foe",
Bar: {
path: "bar",
screens: {
Baz: {
path: "baz",
exact: !0
}
}
}
}
}
}
};
expect(getPathFromState({
routes: [
{
name: "Foo",
state: {
routes: [
{
name: "Bar",
state: {
routes: [{ name: "Baz" }]
}
}
]
}
}
]
}, config)).toBe(path), expect(
getPathFromState(getStateFromPath(path, config), config)
).toBe(path);
});
test("handles nested object for second route depth and path and stringify in roots", () => {
const path = "/foo/dathomir/bar/42/baz", config = {
screens: {
Foo: {
path: "foo/:planet",
stringify: {
id: (id) => `planet=${id}`
},
screens: {
Foe: "foe",
Bar: {
path: "bar/:id",
parse: {
id: Number
},
screens: {
Baz: "baz"
}
}
}
}
}
};
expect(getPathFromState({
routes: [
{
name: "Foo",
params: { planet: "dathomir" },
state: {
routes: [
{
name: "Bar",
state: {
routes: [{ name: "Baz", params: { id: 42 } }]
}
}
]
}
}
]
}, config)).toBe(path), expect(
getPathFromState(getStateFromPath(path, config), config)
).toBe(path);
});
test("handles nested object for second route depth and path and stringify in roots with exact", () => {
const path = "/baz", config = {
screens: {
Foo: {
path: "foo/:id",
stringify: {
id: (id) => `id=${id}`
},
screens: {
Foe: "foe",
Bar: {
path: "bar/:id",
stringify: {
id: (id) => `id=${id}`
},
parse: {
id: Number
},
screens: {
Baz: {
path: "baz",
exact: !0
}
}
}
}
}
}
};
expect(getPathFromState({
routes: [
{
name: "Foo",
state: {
routes: [
{
name: "Bar",
state: {
routes: [{ name: "Baz" }]
}
}
]
}
}
]
}, config)).toBe(path), expect(
getPathFromState(getStateFromPath(path, config), config)
).toBe(path);
});
test("ignores empty string paths", () => {
const path = "/bar", config = {
screens: {
Foo: {
path: "",
screens: {
Foe: "foe"
}
},
Bar: "bar"
}
};
expect(getPathFromState({
routes: [
{
name: "Foo",
state: {
routes: [{ name: "Bar" }]
}
}
]
}, config)).toBe(path), expect(
getPathFromState(getStateFromPath(path, config), config)
).toBe(path);
});
test("keeps query params if path is empty", () => {
const path = "/?foo=42", config = {
screens: {
Foo: {
screens: {
Foe: "foe",
Bar: {
screens: {
Qux: {
path: "",
parse: { foo: Number }
},
Baz: "baz"
}
}
}
}
}
};
expect(getPathFromState({
routes: [
{
name: "Foo",
state: {
routes: [
{
name: "Bar",
state: {
routes: [{ name: "Qux", params: { foo: 42 } }]
}
}
]
}
}
]
}, config)).toBe(path), expect(
getPathFromState(getStateFromPath(path, config), config)
).toEqual(path);
});
test("does not use Object.prototype properties as parsing functions", () => {
const path = "/?toString=42", config = {
screens: {
Foo: {
screens: {
Foe: "foe",
Bar: {
screens: {
Qux: {
path: "",
parse: {}
},
Baz: "baz"
}
}
}
}
}
};
expect(getPathFromState({
routes: [
{
name: "Foo",
state: {
routes: [
{
name: "Bar",
state: {
routes: [{ name: "Qux", params: { toString: 42 } }]
}
}
]
}
}
]
}, config)).toBe(path), expect(
getPathFromState(getStateFromPath(path, config), config)
).toEqual(path);
});
test("cuts nested configs too", () => {
const path = "/foo/baz", config = {
screens: {
Foo: {
path: "foo",
screens: {
Bar: {
path: "",
screens: {
Baz: {
path: "baz"
}
}
}
}
}
}
};
expect(getPathFromState({
routes: [
{
name: "Foo",
state: {
routes: [
{
name: "Bar",
state: {
routes: [{ name: "Baz" }]
}
}
]
}
}
]
}, config)).toBe(path), expect(
getPathFromState(getStateFromPath(path, config), config)
).toBe(path);
});
test("cuts nested configs too with exact", () => {
const path = "/baz", config = {
screens: {
Foo: {
path: "foo",
screens: {
Bar: {
path: "",
exact: !0,
screens: {
Baz: {
path: "baz"
}
}
}
}
}
}
};
expect(getPathFromState({
routes: [
{
name: "Foo",
state: {
routes: [
{
name: "Bar",
state: {
routes: [{ name: "Baz" }]
}
}
]
}
}
]
}, config)).toBe(path), expect(
getPathFromState(getStateFromPath(path, config), config)
).toBe(path);
});
test("handles empty path at the end", () => {
const path = "/foo/bar", config = {
screens: {
Foo: {
path: "foo",
screens: {
Bar: "bar"
}
},
Baz: { path: "" }
}
};
expect(getPathFromState({
routes: [
{
name: "Foo",
state: {
routes: [
{
name: "Bar",
state: {
routes: [{ name: "Baz" }]
}
}
]
}
}
]
}, config)).toBe(path), expect(
getPathFromState(getStateFromPath(path, config), config)
).toBe(path);
});
test('returns "/" for empty path', () => {
const config = {
screens: {
Foo: {
path: "",
screens: {
Bar: ""
}
}
}
};
expect(getPathFromState({
routes: [
{
name: "Foo",
state: {
routes: [
{
name: "Bar"
}
]
}
}
]
}, config)).toBe("/"), expect(
getPathFromState(getStateFromPath("/", config), config)
).toBe("/");
});
test("parses no path specified", () => {
const path = "/bar", config = {
screens: {
Foo: {
screens: {
Foe: {},
Bar: "bar"
}
}
}
};
expect(getPathFromState({
routes: [
{
name: "Foo",
state: {
routes: [{ name: "Bar" }]
}
}
]
}, config)).toBe(path), expect(
getPathFromState(getStateFromPath(path, config), config)
).toBe(path);
});
test("strips undefined query params", () => {
const path = "/bar/sweet/apple/foo/bis/jane?count=10&valid=true", config = {
screens: {
Bar: {
path: "bar/:type/:fruit",
screens: {
Foo: {
path: "foo",
screens: {
Foe: {
path: "foe"
},
Baz: {
screens: {
Bos: "bos",
Bis: {
path: "bis/:author",
stringify: {
author: (author) => author.replace(/^\w/, (c) => c.toLowerCase())
},
parse: {
author: (author) => author.replace(/^\w/, (c) => c.toUpperCase()),
count: Number,
valid: Boolean
}
}
}
}
}
}
}
}
}
};
expect(getPathFromState({
routes: [
{
name: "Bar",
params: { fruit: "apple", type: "sweet" },
state: {
routes: [
{
name: "Foo",
state: {
routes: [
{
name: "Baz",
state: {
routes: [
{
name: "Bis",
params: {
author: "Jane",
count: 10,
valid: !0
}
}
]
}
}
]
}
}
]
}
}
]
}, config)).toBe(path), expect(
getPathFromState(getStateFromPath(path, config), config)
).toBe(path);
});
test("strips undefined query params with exact", () => {
const path = "/bis/jane?count=10&valid=true", config = {
screens: {
Bar: {
path: "bar/:type/:fruit",
screens: {
Foo: {
path: "foo",
screens: {
Foe: {
path: "foe"
},
Baz: {
screens: {
Bos: "bos",
Bis: {
path: "bis/:author",
exact: !0,
stringify: {
author: (author) => author.replace(/^\w/, (c) => c.toLowerCase())
},
parse: {
author: (author) => author.replace(/^\w/, (c) => c.toUpperCase()),
count: Number,
valid: Boolean
}
}
}
}
}
}
}
}
}
};
expect(getPathFromState({
routes: [
{
name: "Bar",
params: { fruit: "apple", type: "sweet" },
state: {
routes: [
{
name: "Foo",
state: {
routes: [
{
name: "Baz",
state: {
routes: [
{
name: "Bis",
params: {
author: "Jane",
count: 10,
valid: !0
}
}
]
}
}
]
}
}
]
}
}
]
}, config)).toBe(path), expect(
getPathFromState(getStateFromPath(path, config), config)
).toBe(path);
});
test("handles stripping all query params", () => {
const path = "/bar/sweet/apple/foo/bis/jane", config = {
screens: {
Bar: {
path: "bar/:type/:fruit",
screens: {
Foo: {
path: "foo",
screens: {
Foe: {
path: "foe"
},
Baz: {
screens: {
Bos: "bos",
Bis: {
path: "bis/:author",
stringify: {
author: (author) => author.replace(/^\w/, (c) => c.toLowerCase())
},
parse: {
author: (author) => author.replace(/^\w/, (c) => c.toUpperCase()),
count: Number,
valid: Boolean
}
}
}
}
}
}
}
}
}
};
expect(getPathFromState({
routes: [
{
name: "Bar",
params: { fruit: "apple", type: "sweet" },
state: {
routes: [
{
name: "Foo",
state: {
routes: [
{
name: "Baz",
state: {
routes: [
{
name: "Bis",
params: {
author: "Jane"
}
}
]
}
}
]
}
}
]
}
}
]
}, config)).toBe(path), expect(
getPathFromState(getStateFromPath(path, config), config)
).toBe(path);
});
test("handles stripping all query params with exact", () => {
const path = "/bis/jane", config = {
screens: {
Bar: {
path: "bar/:type/:fruit",
screens: {
Foo: {
path: "foo",
screens: {
Foe: {
path: "foe"
},
Baz: {
path: "baz",
screens: {
Bos: "bos",
Bis: {
path: "bis/:author",
exact: !0,
stringify: {
author: (author) => author.replace(/^\w/, (c) => c.toLowerCase())
},
parse: {
author: (author) => author.replace(/^\w/, (c) => c.toUpperCase()),
count: Number,
valid: Boolean
}
}
}
}
}
}
}
}
}
};
expect(getPathFromState({
routes: [
{
name: "Bar",
params: { fruit: "apple", type: "sweet" },
state: {
routes: [
{
name: "Foo",
state: {
routes: [
{
name: "Baz",
state: {
routes: [
{
name: "Bis",
params: {
author: "Jane"
}
}
]
}
}
]
}
}
]
}
}
]
}, config)).toBe(path), expect(
getPathFromState(getStateFromPath(path, config), config)
).toBe(path);
});
test("replaces undefined query params", () => {
const path = "/bar/undefined/apple", config = {
screens: {
Bar: "bar/:type/:fruit"
}
};
expect(getPathFromState({
routes: [
{
name: "Bar",
params: { fruit: "apple" }
}
]
}, config)).toBe(path), expect(
getPathFromState(getStateFromPath(path, config), config)
).toBe(path);
});
test.skip("matches wildcard patterns at root", () => {
const path = "/test/bar/42/whatever", config = {
screens: {
404: "*",
Foo: {
screens: {
Bar: {
path: "/bar/:id/"
}
}
}
}
};
expect(getPathFromState({
routes: [{ name: "404" }]
}, config)).toBe("/404"), expect(
getPathFromState(getStateFromPath(path, config), config)
).toBe("/404");
});
test.skip("matches wildcard patterns at nested level", () => {
const path = "/bar/42/whatever/baz/initt", config = {
screens: {
Foo: {
screens: {
Bar: {
path: "/bar/:id/",
screens: {
404: "*"
}
}
}
}
}
};
expect(getPathFromState({
routes: [
{
name: "Foo",
state: {
routes: [
{
name: "Bar",
params: { id: "42" },
state: {
routes: [{ name: "404" }]
}
}
]
}
}
]
}, config)).toBe("/bar/42/404"), expect(
getPathFromState(getStateFromPath(path, config), config)
).toBe("/bar/42/404");
});
test.skip("matches wildcard patterns at nested level with exact", () => {
const path = "/whatever", config = {
screens: {
Foo: {
screens: {
Bar: {
path: "/bar/:id/",
screens: {
404: {
path: "*",
exact: !0
}
}
},
Baz: {}
}
}
}
};
expect(getPathFromState({
routes: [
{
name: "Foo",
state: {
routes: [
{
name: "Bar",
state: {
routes: [{ name: "404" }]
}
}
]
}
}
]
}, config)).toBe("/404"), expect(
getPathFromState(getStateFromPath(path, config), config)
).toBe("/404");
});
test("tries to match wildcard patterns at the end", () => {
const path = "/bar/42/test", config = {
screens: {
Foo: {
screens: {
Bar: {
path: "/bar/:id/",
screens: {
404: "*",
Test: "test"
}
}
}
}
}
};
expect(getPathFromState({
routes: [
{
name: "Foo",
state: {
routes: [
{
name: "Bar",
params: { id: "42" },
state: {
routes: [{ name: "Test" }]
}
}
]
}
}
]
}, config)).toBe(path), expect(
getPathFromState(getStateFromPath(path, config), config)
).toBe(path);
});
test.skip("uses nearest parent wildcard match for unmatched paths", () => {
const path = "/bar/42/baz/test", config = {
screens: {
Foo: {
screens: {
Bar: {
path: "/bar/:id/",
screens: {
Baz: "baz"
}
},
404: "*"
}
}
}
};
expect(getPathFromState({
routes: [
{
name: "Foo",
state: {
routes: [{ name: "404" }]
}
}
]
}, config)).toBe("/404"), expect(
getPathFromState(getStateFromPath(path, config), config)
).toBe("/404");
});
test.skip("handles path at top level", () => {
const path = "foo/fruits/apple", config = {
path: "foo",
screens: {
Foo: {
screens: {
Fruits: "fruits/:fruit"
}
}
}
};
expect(getPathFromState({
routes: [
{
name: "Foo",
state: {
routes: [
{
name: "Fruits",
params: { fruit: "apple" }
}
]
}
}
]
}, config)).toBe(`/${path}`), expect(getPathFromState(getStateFromPath(path, config), config)).toBe(
`/${path}`
);
});
test.skip("ignores regexp patterns when provided", () => {
const config = {
screens: {
Foo: {
path: "foo/:id(\\d+)",
parse: {
id: Number
}
},
Bar: {
path: "foo/:id([a-z]+)"
},
Baz: {
path: "foo/:id(\\d+)/:name([a-z]+)"
},
Qux: {
path: "foo/:id(@[a-z]+)",
stringify: {
id: (id) => `@${id}`
}
}
}
};
expect(
getPathFromState(
{
routes: [
{
name: "Foo",
params: { id: 42 }
}
]
},
config
)
).toBe("/foo/42"), expect(
getPathFromState(
{
routes: [
{
name: "Bar",
params: { id: "bar" }
}
]
},
config
)
).toBe("/foo/bar"), expect(
getPathFromState(
{
routes: [
{
name: "Baz",
params: { id: 42, name: "bar" }
}
]
},
config
)
).toBe("/foo/42/bar"), expect(
getPathFromState(
{
routes: [
{
name: "Qux",
params: { id: "bar" }
}
]
},
config
)
).toBe("/foo/@bar");
});
test.skip("correctly handles regex pattern with slash", () => {
expect(
getPathFromState(
{
routes: [
{
name: "Foo",
params: { id: "bar" }
}
]
},
{
screens: {
Foo: {
path: "foo/:id([a-z]+\\/)"
}
}
}
)
).toBe("/foo/bar");
});
//# sourceMappingURL=getPathFromState.test.js.map