-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from ckastbjerg/add-basic-tests
Setup testing solution + add unit tests for utils
- Loading branch information
Showing
8 changed files
with
3,407 additions
and
147 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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
name: CI | ||
on: push | ||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Install modules | ||
run: yarn | ||
- name: Run tests | ||
run: yarn test |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module.exports = { | ||
preset: 'ts-jest', | ||
testEnvironment: 'node', | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { getRoute, getPathname } from "./utils"; | ||
|
||
describe("utils/getRoute", () => { | ||
it("works as expected for basic routes", () => { | ||
expect(getRoute("/routes")).toBe("/routes"); | ||
}); | ||
|
||
it("works as expected when having (untyped) query params", () => { | ||
expect(getRoute("/routes", { a: "b" })).toBe("/routes?a=b"); | ||
}); | ||
|
||
it("works as expected for dynamic routes", () => { | ||
const route = getRoute({ route: "/routes/[routeId]", routeId: 1 }); | ||
expect(route).toBe("/routes/1"); | ||
}); | ||
|
||
it("works as expected when having (untyped) query params for dynamic routes", () => { | ||
const route = getRoute( | ||
{ route: "/routes/[routeId]", routeId: 1 }, | ||
{ a: "b" } | ||
); | ||
expect(route).toBe("/routes/1?a=b"); | ||
}); | ||
}); | ||
|
||
describe("utils/getPathname", () => { | ||
it("works as expected for basic routes", () => { | ||
expect(getPathname("/routes")).toBe("/routes"); | ||
}); | ||
|
||
it("works as expected for dynamic routes", () => { | ||
const route = getPathname({ route: "/routes/[routeId]", routeId: 1 }); | ||
expect(route).toBe("/routes/[routeId]"); | ||
}); | ||
}); |
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.