Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
willybrauner committed Nov 9, 2023
1 parent 5d1ae14 commit 9a4ece2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/tests/_fixtures/routeList.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { TRoute } from ".."
import { TRoute } from "../../components/Router"

export const routeList: TRoute[] = [
{
Expand Down
16 changes: 16 additions & 0 deletions src/tests/core.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,22 @@ describe("public", () => {
expect(createUrl({ name: "ZooPage" }, base, routeList)).toBe("/hello/foo/zoo")
})

it("should create URL properly if is base URL", () => {
const routes = [
{ path: "/a", name: "a-page" },
{
path: "/b",
name: "b-page",
children: [
{ path: "/c", name: "c-page" },
{ path: "/d", name: "d-page" },
],
},
]
expect(createUrl("/a", "/foo/", routes)).toBe("/foo/a")
expect(createUrl("/d", "/foo/", routes)).toBe("/foo/d")
})

it("should create URL with params and hash", () => {
const base = "/custom-base/"
const routes = [
Expand Down

0 comments on commit 9a4ece2

Please sign in to comment.