-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
61 changed files
with
6,930 additions
and
5,765 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,6 @@ dist/ | |
example/ | ||
docs/ | ||
|
||
vite.config.ts | ||
vite.config.mts | ||
vitest-setup.ts | ||
.eslintrc.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
name: Build | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
pull_request: | ||
branches: [main] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20 | ||
cache: yarn | ||
|
||
- run: yarn install --pure-lockfile | ||
- run: yarn prepack | ||
|
||
- name: Build docs | ||
run: cd docs && yarn && yarn build | ||
|
||
- name: Deploy | ||
if: "contains('refs/heads/main', github.ref)" | ||
uses: peaceiris/actions-gh-pages@v3 | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
publish_dir: ./docs/build |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html | ||
|
||
exports[`Should render home page correctly 1`] = `"<div><a href=\\"/\\" class=\\"active\\">Home</a><a href=\\"/users\\">Users</a><a href=\\"/users/123\\">User</a><div>Home</div></div>"`; | ||
exports[`Should render home page correctly 1`] = `"<div><a href="/" class="active">Home</a><a href="/users">Users</a><a href="/users/123">User</a><div>Home</div></div>"`; | ||
|
||
exports[`Should render user page correctly 1`] = `"<div><a href=\\"/\\">Home</a><a href=\\"/users\\">Users</a><a href=\\"/users/123\\" class=\\"active\\">User</a><div>User 123</div></div>"`; | ||
exports[`Should render user page correctly 1`] = `"<div><a href="/">Home</a><a href="/users">Users</a><a href="/users/123" class="active">User</a><div>User 123</div></div>"`; | ||
|
||
exports[`Should render users page correctly 1`] = `"<div><a href=\\"/\\">Home</a><a href=\\"/users\\" class=\\"active\\">Users</a><a href=\\"/users/123\\">User</a><div>Users</div></div>"`; | ||
exports[`Should render users page correctly 1`] = `"<div><a href="/">Home</a><a href="/users" class="active">Users</a><a href="/users/123">User</a><div>Users</div></div>"`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,76 +1,63 @@ | ||
import { describe, expect, test } from "vitest"; | ||
import { expect, test } from "vitest"; | ||
import { | ||
areParamsArrayEqual, | ||
extractParamNameUnion, | ||
first, | ||
isMultipleParam, | ||
isNonEmpty, | ||
isParam, | ||
} from "../src/helpers"; | ||
|
||
describe("first", () => { | ||
test("returns the first element of an array", () => { | ||
expect(first(["a", "b", "c"])).toBe("a"); | ||
expect(first([1, 2, 3])).toBe(1); | ||
}); | ||
test("first", () => { | ||
expect(first(["a", "b", "c"])).toBe("a"); | ||
expect(first([1, 2, 3])).toBe(1); | ||
|
||
test("returns undefined if the array is empty", () => { | ||
expect(first([])).toBeUndefined(); | ||
}); | ||
expect(first([])).toBeUndefined(); | ||
}); | ||
|
||
describe("isNonEmpty", () => { | ||
test("returns true if the value is not an empty string", () => { | ||
expect(isNonEmpty("test")).toBe(true); | ||
expect(isNonEmpty(" ")).toBe(true); | ||
}); | ||
test("isNonEmpty", () => { | ||
expect(isNonEmpty("test")).toBe(true); | ||
expect(isNonEmpty(" ")).toBe(true); | ||
|
||
test("returns false if the value is an empty string", () => { | ||
expect(isNonEmpty("")).toBe(false); | ||
}); | ||
expect(isNonEmpty("")).toBe(false); | ||
}); | ||
|
||
describe("isParam", () => { | ||
test("returns true if the value is a well-formed route param", () => { | ||
expect(isParam(":test")).toBe(true); | ||
expect(isParam(":")).toBe(true); | ||
expect(isParam(": ")).toBe(true); | ||
}); | ||
test("isParam", () => { | ||
expect(isParam(":test")).toBe(true); | ||
expect(isParam(":")).toBe(true); | ||
expect(isParam(": ")).toBe(true); | ||
|
||
test("returns false if the value is not a well-formed route param", () => { | ||
expect(isParam(" :test")).toBe(false); | ||
expect(isParam("test")).toBe(false); | ||
}); | ||
expect(isParam(" :test")).toBe(false); | ||
expect(isParam("test")).toBe(false); | ||
}); | ||
|
||
describe("areParamsArrayEqual", () => { | ||
test("returns true with identical arrays", () => { | ||
expect(areParamsArrayEqual([], [])).toBe(true); | ||
expect(areParamsArrayEqual(["foo"], ["foo"])).toBe(true); | ||
expect(areParamsArrayEqual(["foo", "bar"], ["foo", "bar"])).toBe(true); | ||
}); | ||
test("areParamsArrayEqual", () => { | ||
expect(areParamsArrayEqual([], [])).toBe(true); | ||
expect(areParamsArrayEqual(["foo"], ["foo"])).toBe(true); | ||
expect(areParamsArrayEqual(["foo", "bar"], ["foo", "bar"])).toBe(true); | ||
|
||
test("returns false with different arrays", () => { | ||
expect(areParamsArrayEqual(["foo"], [])).toBe(false); | ||
expect(areParamsArrayEqual(["foo"], ["bar"])).toBe(false); | ||
expect(areParamsArrayEqual(["foo", "bar"], ["bar", "foo"])).toBe(false); | ||
}); | ||
expect(areParamsArrayEqual(["foo"], [])).toBe(false); | ||
expect(areParamsArrayEqual(["foo"], ["bar"])).toBe(false); | ||
expect(areParamsArrayEqual(["foo", "bar"], ["bar", "foo"])).toBe(false); | ||
}); | ||
|
||
describe("isMultipleParam", () => { | ||
test("returns true if the value is a well-formed route multiple param", () => { | ||
expect(isMultipleParam(":test[]")).toBe(true); | ||
expect(isMultipleParam(":[]")).toBe(true); | ||
expect(isMultipleParam(": []")).toBe(true); | ||
test("extractParamNameUnion", () => { | ||
expect(extractParamNameUnion("foo")).toStrictEqual({ name: "foo" }); | ||
expect(extractParamNameUnion("foo{")).toStrictEqual({ name: "foo{" }); | ||
expect(extractParamNameUnion("foo}")).toStrictEqual({ name: "foo}" }); | ||
expect(extractParamNameUnion("{}foo")).toStrictEqual({ name: "{}foo" }); | ||
|
||
expect(extractParamNameUnion("foo{}")).toStrictEqual({ | ||
name: "foo", | ||
union: [], | ||
}); | ||
|
||
expect(extractParamNameUnion("foo{a}")).toStrictEqual({ | ||
name: "foo", | ||
union: ["a"], | ||
}); | ||
|
||
test("returns false if the value is not a well-formed route multiple param", () => { | ||
expect(isMultipleParam(" :test[]")).toBe(false); | ||
expect(isMultipleParam("test[]")).toBe(false); | ||
expect(isMultipleParam(":test]")).toBe(false); | ||
expect(isMultipleParam(":test[")).toBe(false); | ||
expect(isMultipleParam(": ")).toBe(false); | ||
expect(isMultipleParam(":")).toBe(false); | ||
expect(isMultipleParam(":test")).toBe(false); | ||
expect(isMultipleParam("test")).toBe(false); | ||
expect(extractParamNameUnion("foo{a|b}")).toStrictEqual({ | ||
name: "foo", | ||
union: ["a", "b"], | ||
}); | ||
}); |
Oops, something went wrong.