-
Notifications
You must be signed in to change notification settings - Fork 1
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
13 changed files
with
3,107 additions
and
52 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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
node_modules/ | ||
dist/ | ||
coverage |
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,8 +1,12 @@ | ||
language: node_js | ||
node_js: | ||
- "10" | ||
- "12" | ||
- "14" | ||
cache: | ||
yarn: true | ||
directories: | ||
- "node_modules" | ||
before_install: | ||
- export TZ=Europe/Berlin | ||
script: | ||
- yarn ci |
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", | ||
testPathIgnorePatterns: ["/dist/", "/node_modules/"], | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,88 @@ | ||
import React from "react"; | ||
import { screen, render } from "@testing-library/react"; | ||
import { createMemoryHistory } from "history"; | ||
import { Router } from "react-router-dom"; | ||
import Walls, { Props } from "../Walls"; | ||
|
||
import "@testing-library/jest-dom/extend-expect"; | ||
|
||
const ROUTE = { | ||
id: "foo", | ||
route: "/foo", | ||
render: () => <>foo</>, | ||
private: false, | ||
}; | ||
|
||
const renderWrapper = (props: Props, currentRoute: string) => { | ||
const history = createMemoryHistory(); | ||
history.push(currentRoute); | ||
|
||
render( | ||
<Router history={history}> | ||
<Walls {...props} /> | ||
</Router>, | ||
); | ||
}; | ||
|
||
describe("Walls", () => { | ||
describe("Given an existing walls garden", () => { | ||
describe("then a route is public ", () => { | ||
describe("can be visited", () => { | ||
beforeEach(() => { | ||
renderWrapper({ routes: [ROUTE] }, ROUTE.route); | ||
}); | ||
|
||
it("renders Route component", () => { | ||
expect(screen.getByText(/foo/i)).toBeInTheDocument(); | ||
}); | ||
}); | ||
}); | ||
|
||
describe("then a route is private", () => { | ||
describe("and the user is authorized", () => { | ||
describe("can be visited", () => { | ||
beforeEach(() => { | ||
renderWrapper( | ||
{ | ||
isAuthorized: true, | ||
routes: [ | ||
{ ...ROUTE, render: () => <>private</>, private: true }, | ||
], | ||
}, | ||
ROUTE.route, | ||
); | ||
}); | ||
|
||
it("renders as Private Route", () => { | ||
expect(screen.getByText(/private/i)).toBeInTheDocument(); | ||
}); | ||
}); | ||
}); | ||
|
||
describe("and the user is not authorized", () => { | ||
describe("can not be visited", () => { | ||
beforeEach(() => { | ||
renderWrapper( | ||
{ | ||
isAuthorized: false, | ||
routes: [ | ||
{ | ||
...ROUTE, | ||
render: () => <>private</>, | ||
fallback: () => <>fallback</>, | ||
private: true, | ||
}, | ||
], | ||
}, | ||
ROUTE.route, | ||
); | ||
}); | ||
|
||
it("does not render the private route", () => { | ||
expect(screen.getByText(/fallback/i)).toBeInTheDocument(); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); |
2 changes: 1 addition & 1 deletion
2
src/__tests__/visual/Container.tsx → src/__visual__/Container.tsx
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.