-
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.
🔀 Merge pull request #44 from charliegdev/feature/unit-test
Feature/unit test
- Loading branch information
Showing
13 changed files
with
209 additions
and
15 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 |
---|---|---|
|
@@ -22,4 +22,6 @@ npm-debug.log* | |
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
.env | ||
.env | ||
src/__snapshots__ | ||
src/components/**/__snapshots__ |
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 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,17 @@ | ||
import React from "react"; | ||
import ReactDOM from "react-dom"; | ||
import renderer from "react-test-renderer"; | ||
import { Provider } from "react-redux"; | ||
import App from "./App"; | ||
import { routineTests } from "./components/test-utils"; | ||
import { store } from "./redux"; | ||
|
||
describe("App root", () => { | ||
const component = ( | ||
<Provider store={store}> | ||
<App /> | ||
</Provider> | ||
); | ||
|
||
routineTests(component); | ||
}); |
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,23 @@ | ||
import React from "react"; | ||
import { Button } from "evergreen-ui"; | ||
import { routineTests } from "../test-utils"; | ||
import Dialog from "./Dialog"; | ||
|
||
describe("Dialog", () => { | ||
let dialog; | ||
|
||
beforeEach(() => { | ||
dialog = ( | ||
<Dialog | ||
confirmLabel="OK" | ||
onConfirm={() => undefined} | ||
title="Sample Dialog" | ||
trigger={<Button>Open Dialog</Button>} | ||
> | ||
<p>Sample Dialog content</p> | ||
</Dialog> | ||
); | ||
}); | ||
|
||
routineTests(dialog); | ||
}); |
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,13 @@ | ||
import React from "react"; | ||
import NewTaskDialog from "./NewTaskDialog"; | ||
import { routineTests } from "../test-utils"; | ||
|
||
describe("Dialog", () => { | ||
let dialog; | ||
|
||
beforeEach(() => { | ||
dialog = <NewTaskDialog onConfirm={() => undefined} />; | ||
}); | ||
|
||
routineTests(dialog); | ||
}); |
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,31 @@ | ||
import React from "react"; | ||
import SelectMenu from "./SelectMenu"; | ||
import { routineTests } from "../test-utils"; | ||
|
||
describe("Dialog", () => { | ||
let selectMenu; | ||
|
||
beforeEach(() => { | ||
selectMenu = ( | ||
<SelectMenu | ||
options={[ | ||
{ | ||
label: "option 1", | ||
value: "option 1" | ||
}, | ||
{ | ||
label: "option 2", | ||
value: "option 2" | ||
}, | ||
{ | ||
label: "option 3", | ||
value: "option 3" | ||
} | ||
]} | ||
onSelect={() => undefined} | ||
/> | ||
); | ||
}); | ||
|
||
routineTests(selectMenu); | ||
}); |
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,24 @@ | ||
import React from "react"; | ||
import Task from "./Task"; | ||
import { emptyFiller, routineTests } from "../test-utils"; | ||
|
||
describe("Task", () => { | ||
let task; | ||
|
||
beforeEach(() => { | ||
task = ( | ||
<Task | ||
changeStatus={emptyFiller} | ||
deleteTask={emptyFiller} | ||
task={{ | ||
id: 1, | ||
title: "Review iPhone XS Max", | ||
description: "Review the newest flagship iPhone.", | ||
status: "To Do" | ||
}} | ||
/> | ||
); | ||
}); | ||
|
||
routineTests(task); | ||
}); |
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,37 @@ | ||
import React from "react"; | ||
import Task from "./Task"; | ||
import TaskLane from "./TaskLane"; | ||
import { emptyFiller, routineTests } from "../test-utils"; | ||
|
||
describe("TaskLane", () => { | ||
let taskLane; | ||
|
||
beforeEach(() => { | ||
taskLane = ( | ||
<TaskLane icon="pulse" title="In Progress"> | ||
<Task | ||
changeStatus={emptyFiller} | ||
deleteTask={emptyFiller} | ||
task={{ | ||
id: 1, | ||
title: "Review iPhone XS Max", | ||
description: "Review the newest flagship iPhone.", | ||
status: "To Do" | ||
}} | ||
/> | ||
<Task | ||
changeStatus={emptyFiller} | ||
deleteTask={emptyFiller} | ||
task={{ | ||
id: 2, | ||
title: "Review iPhone XS Max", | ||
description: "Review the newest flagship iPhone.", | ||
status: "To Do" | ||
}} | ||
/> | ||
</TaskLane> | ||
); | ||
}); | ||
|
||
routineTests(taskLane); | ||
}); |
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,23 @@ | ||
import ReactDOM from "react-dom"; | ||
import renderer from "react-test-renderer"; | ||
|
||
export const emptyFiller = () => undefined; | ||
|
||
export const renderWithoutCrashing = component => | ||
test(`renders without crashing`, () => { | ||
const div = document.createElement("div"); | ||
ReactDOM.render(component, div); | ||
ReactDOM.unmountComponentAtNode(div); | ||
}); | ||
|
||
export const renderSameSnapshot = component => | ||
test("renders the same snapshot", () => { | ||
const output = renderer.create(component); | ||
const tree = output.toJSON(); | ||
expect(tree).toMatchSnapshot(); | ||
}); | ||
|
||
export const routineTests = component => { | ||
renderWithoutCrashing(component); | ||
renderSameSnapshot(component); | ||
}; |
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,17 @@ | ||
import React from "react"; | ||
import Topbar from "./Topbar"; | ||
import { routineTests } from "../test-utils"; | ||
|
||
describe("Topbar", () => { | ||
let topbar; | ||
|
||
beforeEach(() => { | ||
topbar = ( | ||
<Topbar> | ||
<p>Test</p> | ||
</Topbar> | ||
); | ||
}); | ||
|
||
routineTests(topbar); | ||
}); |
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 @@ | ||
/* eslint no-console: 0 */ | ||
// Evergreen keeps spitting out console warnings about a deprecated CSS prop which we're not using; | ||
// it clobs up the jest unit test output! Disable warnings. | ||
console.warn = jest.fn(); |
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