-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat!: rename
buildPath
to $path
, echoPath
to $echoPath
- Loading branch information
1 parent
f773bf9
commit 6ae8e65
Showing
12 changed files
with
93 additions
and
93 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
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,47 +1,47 @@ | ||
/* eslint-disable @typescript-eslint/ban-ts-comment */ | ||
import { test, assertType } from "vitest"; | ||
import { buildPath } from "./output"; | ||
import { $path } from "./output"; | ||
|
||
test("valid", () => { | ||
assertType(buildPath("/posts/[id]/comments/[commentId]", { params: { id: 1, commentId: 1 } })); | ||
assertType($path("/posts/[id]/comments/[commentId]", { params: { id: 1, commentId: 1 } })); | ||
assertType( | ||
buildPath("/posts/[id]/comments/[commentId]", { | ||
$path("/posts/[id]/comments/[commentId]", { | ||
params: { id: 1, commentId: 1 }, | ||
query: { q: "foo" }, | ||
}), | ||
); | ||
assertType( | ||
buildPath("/posts/[id]/comments/[commentId]", { | ||
$path("/posts/[id]/comments/[commentId]", { | ||
params: { id: 1, commentId: 1 }, | ||
hash: "section", | ||
}), | ||
); | ||
assertType( | ||
buildPath("/posts/[id]/comments/[commentId]", { | ||
$path("/posts/[id]/comments/[commentId]", { | ||
params: { id: 1, commentId: 1 }, | ||
query: { q: 1 }, | ||
hash: "section", | ||
}), | ||
); | ||
|
||
assertType(buildPath("/about", { query: { q: "foo" } })); | ||
assertType(buildPath("/about", { query: { q: "foo" } })); | ||
assertType(buildPath("/about", { query: { q: "foo" }, hash: "section" })); | ||
assertType($path("/about", { query: { q: "foo" } })); | ||
assertType($path("/about", { query: { q: "foo" } })); | ||
assertType($path("/about", { query: { q: "foo" }, hash: "section" })); | ||
}); | ||
|
||
test("invalid", () => { | ||
// @ts-expect-error missing all of param | ||
assertType(buildPath("/posts/[id]/comments/[commentId]")); | ||
assertType($path("/posts/[id]/comments/[commentId]")); | ||
// @ts-expect-error missing commentId param | ||
assertType(buildPath("/posts/[id]/comments/[commentId]", { id: 1 })); | ||
assertType($path("/posts/[id]/comments/[commentId]", { id: 1 })); | ||
// @ts-expect-error missing id param | ||
assertType(buildPath("/posts/[id]/comments/[commentId]", { commentId: 1 })); | ||
assertType($path("/posts/[id]/comments/[commentId]", { commentId: 1 })); | ||
// @ts-expect-error | ||
assertType(buildPath("/about", { id: 1 })); | ||
assertType($path("/about", { id: 1 })); | ||
// @ts-expect-error | ||
assertType(buildPath("/about", { searchParams: 1 })); | ||
assertType($path("/about", { searchParams: 1 })); | ||
// @ts-expect-error | ||
assertType(buildPath("/about", { hash: 1 })); | ||
assertType($path("/about", { hash: 1 })); | ||
// @ts-expect-error | ||
assertType(buildPath("not-defined")); | ||
assertType($path("not-defined")); | ||
}); |
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,18 +1,18 @@ | ||
import { expect, test } from "vitest"; | ||
import { buildPath, echoPath } from "./output"; | ||
import { $path, $echoPath } from "./output"; | ||
|
||
test("build path with params, query, hash", () => { | ||
expect( | ||
buildPath("/posts/[id]/comments/[commentId]", { | ||
$path("/posts/[id]/comments/[commentId]", { | ||
params: { id: 1, commentId: 2 }, | ||
query: { q: 1 }, | ||
hash: "section", | ||
}), | ||
).toBe("/posts/1/comments/2?q=1#section"); | ||
|
||
expect(buildPath("/about", { query: { q: "hoge" } })); | ||
expect($path("/about", { query: { q: "hoge" } })); | ||
}); | ||
|
||
test("echoPath should returns the argument", () => { | ||
expect(echoPath("/posts/[id]/comments/[commentId]")).toBe("/posts/[id]/comments/[commentId]"); | ||
test("$echoPath should returns the argument", () => { | ||
expect($echoPath("/posts/[id]/comments/[commentId]")).toBe("/posts/[id]/comments/[commentId]"); | ||
}); |
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,47 +1,47 @@ | ||
/* eslint-disable @typescript-eslint/ban-ts-comment */ | ||
import { test, assertType } from "vitest"; | ||
import { buildPath } from "./output"; | ||
import { $path } from "./output"; | ||
|
||
test("valid", () => { | ||
assertType(buildPath("/posts/:id/comments/:commentId", { params: { id: 1, commentId: 1 } })); | ||
assertType($path("/posts/:id/comments/:commentId", { params: { id: 1, commentId: 1 } })); | ||
assertType( | ||
buildPath("/posts/:id/comments/:commentId", { | ||
$path("/posts/:id/comments/:commentId", { | ||
params: { id: 1, commentId: 1 }, | ||
query: { q: "foo" }, | ||
}), | ||
); | ||
assertType( | ||
buildPath("/posts/:id/comments/:commentId", { | ||
$path("/posts/:id/comments/:commentId", { | ||
params: { id: 1, commentId: 1 }, | ||
hash: "section", | ||
}), | ||
); | ||
assertType( | ||
buildPath("/posts/:id/comments/:commentId", { | ||
$path("/posts/:id/comments/:commentId", { | ||
params: { id: 1, commentId: 1 }, | ||
query: { q: 1 }, | ||
hash: "section", | ||
}), | ||
); | ||
|
||
assertType(buildPath("/about", { query: { q: "foo" } })); | ||
assertType(buildPath("/about", { query: { q: "foo" } })); | ||
assertType(buildPath("/about", { query: { q: "foo", hash: "section" } })); | ||
assertType($path("/about", { query: { q: "foo" } })); | ||
assertType($path("/about", { query: { q: "foo" } })); | ||
assertType($path("/about", { query: { q: "foo", hash: "section" } })); | ||
}); | ||
|
||
test("invalid", () => { | ||
// @ts-expect-error | ||
assertType(buildPath("posts/:id/comments/:commentId")); | ||
assertType($path("posts/:id/comments/:commentId")); | ||
// @ts-expect-error | ||
assertType(buildPath("posts/:id/comments/:commentId", { id: 1 })); | ||
assertType($path("posts/:id/comments/:commentId", { id: 1 })); | ||
// @ts-expect-error | ||
assertType(buildPath("posts/:id/comments/:commentId", { commentId: 1 })); | ||
assertType($path("posts/:id/comments/:commentId", { commentId: 1 })); | ||
// @ts-expect-error | ||
assertType(buildPath("about", { id: 1 })); | ||
assertType($path("about", { id: 1 })); | ||
// @ts-expect-error | ||
assertType(buildPath("about", { query: 1 })); | ||
assertType($path("about", { query: 1 })); | ||
// @ts-expect-error | ||
assertType(buildPath("about", { hash: 1 })); | ||
assertType($path("about", { hash: 1 })); | ||
// @ts-expect-error | ||
assertType(buildPath("not-defined")); | ||
assertType($path("not-defined")); | ||
}); |
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,16 +1,16 @@ | ||
import { expect, test } from "vitest"; | ||
import { buildPath, echoPath } from "./output"; | ||
import { $path, $echoPath } from "./output"; | ||
|
||
test("build path with params, query, hash", () => { | ||
expect( | ||
buildPath("/posts/:id/comments/:commentId", { | ||
$path("/posts/:id/comments/:commentId", { | ||
params: { id: 1, commentId: 2 }, | ||
query: { q: 1 }, | ||
hash: "section", | ||
}), | ||
).toBe("/posts/1/comments/2?q=1#section"); | ||
}); | ||
|
||
test("echoPath should returns the argument", () => { | ||
expect(echoPath("/posts/:id/comments/:commentId")).toBe("/posts/:id/comments/:commentId"); | ||
test("$echoPath should returns the argument", () => { | ||
expect($echoPath("/posts/:id/comments/:commentId")).toBe("/posts/:id/comments/:commentId"); | ||
}); |
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,47 +1,47 @@ | ||
/* eslint-disable @typescript-eslint/ban-ts-comment */ | ||
import { test, assertType } from "vitest"; | ||
import { buildPath } from "./output"; | ||
import { $path } from "./output"; | ||
|
||
test("valid", () => { | ||
assertType(buildPath("/posts/[id]/comments/[commentId]", { params: { id: 1, commentId: 1 } })); | ||
assertType($path("/posts/[id]/comments/[commentId]", { params: { id: 1, commentId: 1 } })); | ||
assertType( | ||
buildPath("/posts/[id]/comments/[commentId]", { | ||
$path("/posts/[id]/comments/[commentId]", { | ||
params: { id: 1, commentId: 1 }, | ||
query: { q: "foo" }, | ||
}), | ||
); | ||
assertType( | ||
buildPath("/posts/[id]/comments/[commentId]", { | ||
$path("/posts/[id]/comments/[commentId]", { | ||
params: { id: 1, commentId: 1 }, | ||
hash: "section", | ||
}), | ||
); | ||
assertType( | ||
buildPath("/posts/[id]/comments/[commentId]", { | ||
$path("/posts/[id]/comments/[commentId]", { | ||
params: { id: 1, commentId: 1 }, | ||
query: { q: 1 }, | ||
hash: "section", | ||
}), | ||
); | ||
|
||
assertType(buildPath("/about", { query: { q: "foo" } })); | ||
assertType(buildPath("/about", { query: { q: "foo" } })); | ||
assertType(buildPath("/about", { query: { q: "foo" }, hash: "section" })); | ||
assertType($path("/about", { query: { q: "foo" } })); | ||
assertType($path("/about", { query: { q: "foo" } })); | ||
assertType($path("/about", { query: { q: "foo" }, hash: "section" })); | ||
}); | ||
|
||
test("invalid", () => { | ||
// @ts-expect-error missing all of param | ||
assertType(buildPath("/posts/[id]/comments/[commentId]")); | ||
assertType($path("/posts/[id]/comments/[commentId]")); | ||
// @ts-expect-error missing commentId param | ||
assertType(buildPath("/posts/[id]/comments/[commentId]", { id: 1 })); | ||
assertType($path("/posts/[id]/comments/[commentId]", { id: 1 })); | ||
// @ts-expect-error missing id param | ||
assertType(buildPath("/posts/[id]/comments/[commentId]", { commentId: 1 })); | ||
assertType($path("/posts/[id]/comments/[commentId]", { commentId: 1 })); | ||
// @ts-expect-error | ||
assertType(buildPath("/about", { id: 1 })); | ||
assertType($path("/about", { id: 1 })); | ||
// @ts-expect-error | ||
assertType(buildPath("/about", { searchParams: 1 })); | ||
assertType($path("/about", { searchParams: 1 })); | ||
// @ts-expect-error | ||
assertType(buildPath("/about", { hash: 1 })); | ||
assertType($path("/about", { hash: 1 })); | ||
// @ts-expect-error | ||
assertType(buildPath("not-defined")); | ||
assertType($path("not-defined")); | ||
}); |
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,19 +1,19 @@ | ||
import { expect, test } from "vitest"; | ||
import { buildPath, echoPath } from "./output"; | ||
import { $path, $echoPath } from "./output"; | ||
|
||
test("build path with params, query, hash", () => { | ||
expect( | ||
buildPath("/posts/[id]/comments/[commentId]", { | ||
$path("/posts/[id]/comments/[commentId]", { | ||
params: { id: 1, commentId: 2 }, | ||
query: { q: 1 }, | ||
hash: "section", | ||
}), | ||
).toBe("/posts/1/comments/2?q=1#section"); | ||
|
||
expect(buildPath("/about", { query: { q: "hoge" } })); | ||
expect($path("/about", { query: { q: "hoge" } })); | ||
}); | ||
|
||
test("echoPath should returns the argument", () => { | ||
expect(echoPath("/posts/[id]/comments/[commentId]")).toBe("/posts/[id]/comments/[commentId]"); | ||
expect(echoPath("/api/hello")).toBe("/api/hello"); | ||
test("$echoPath should returns the argument", () => { | ||
expect($echoPath("/posts/[id]/comments/[commentId]")).toBe("/posts/[id]/comments/[commentId]"); | ||
expect($echoPath("/api/hello")).toBe("/api/hello"); | ||
}); |
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
Oops, something went wrong.