diff --git a/README.md b/README.md
index 618f105..6364582 100644
--- a/README.md
+++ b/README.md
@@ -5,7 +5,9 @@
+[![NPM Version][npm-image]][npm-url]
[![Build Status][travis]][travis]
+[![Coverage Status][coverage-badge]][coverage-link]
@@ -44,6 +46,6 @@ A game about space and junk.
[npm-downloads]: https://img.shields.io/npm/dt/hermes-gaame.svg
[npm-url]: https://www.npmjs.com/package/hermes-gaame
[size-image]: https://img.shields.io/bundlephobia/minzip/hermes-game.svg
-[coverage-badge]: https://coveralls.io/repos/github/alexlee-dev/hermes/badge.svg?branch=master
+[coverage-badge]: https://coveralls.io/repos/github/alexlee-dev/hermes/badge.svg?branch=develop
[coverage-link]: https://coveralls.io/github/alexlee-dev/hermes?branch=master
[travis]: https://travis-ci.org/alexlee-dev/hermes.svg?branch=master
diff --git a/package.json b/package.json
index cd55434..70abeaa 100644
--- a/package.json
+++ b/package.json
@@ -34,16 +34,22 @@
"uuid": "^3.3.3"
},
"devDependencies": {
+ "@testing-library/dom": "^6.1.0",
+ "@testing-library/react": "^9.1.3",
"coveralls": "^3.0.6",
"enzyme": "^3.10.0",
- "enzyme-adapter-react-16": "^1.14.0"
+ "enzyme-adapter-react-16": "^1.14.0",
+ "jsdom": "^15.1.1",
+ "jsdom-global": "^3.0.2",
+ "redux-mock-store": "^1.5.3"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"eject": "react-scripts eject",
"test": "react-scripts test",
- "test:coveralls": "jest --coverage --collectCoverageFrom=src/**/* --coverageReporters=text-lcov | coveralls"
+ "test:coverage": "yarn test --coverage --watchAll=false --collectCoverageFrom=src/components/**/* --collectCoverageFrom=src/views/**/*",
+ "test:coveralls": "yarn test --coverage --watchAll=false --collectCoverageFrom=src/components/**/* --collectCoverageFrom=src/views/**/* --coverageReporters=text-lcov | coveralls"
},
"eslintConfig": {
"extends": "react-app"
diff --git a/src/__tests__/App.test.js b/src/__tests__/App.test.js
index 2980574..ec3cd12 100644
--- a/src/__tests__/App.test.js
+++ b/src/__tests__/App.test.js
@@ -1,5 +1,9 @@
-describe('Fake Test', () => {
- it('Should pass.', () => {
- expect(1 + 1).toBe(2)
+import { customRender } from '../test-utils'
+import App from '../App'
+
+describe('', () => {
+ it('Should render the component.', () => {
+ const container = customRender({ component: App })
+ expect(container.asFragment()).toMatchSnapshot()
})
})
diff --git a/src/__tests__/__snapshots__/App.test.js.snap b/src/__tests__/__snapshots__/App.test.js.snap
new file mode 100644
index 0000000..2b79610
--- /dev/null
+++ b/src/__tests__/__snapshots__/App.test.js.snap
@@ -0,0 +1,86 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[` Should render the component. 1`] = `
+
+
+
+ Hermes
+
+
+ 10 minutes 0 seconds
+
+
+
+ Cash:
+
+
+ 100
+
+
+
+
+
+
+
+ Your Ship
+
+
+ Cargo
+
+
+ Location:
+
+
+
+ Value:
+
+
+
+
+
+ Name:
+
+
+
+
+
+
+
+`;
diff --git a/src/__tests__/components/CashDisplay.test.js b/src/__tests__/components/CashDisplay.test.js
new file mode 100644
index 0000000..4acc538
--- /dev/null
+++ b/src/__tests__/components/CashDisplay.test.js
@@ -0,0 +1,9 @@
+import { customRender } from '../../test-utils'
+import CashDisplay from '../../components/CashDisplay'
+
+describe('', () => {
+ it('Should render the component.', () => {
+ const container = customRender({ component: CashDisplay })
+ expect(container.asFragment()).toMatchSnapshot()
+ })
+})
diff --git a/src/__tests__/components/ItemTimer.test.js b/src/__tests__/components/ItemTimer.test.js
new file mode 100644
index 0000000..aa3f230
--- /dev/null
+++ b/src/__tests__/components/ItemTimer.test.js
@@ -0,0 +1,9 @@
+import { customRender } from '../../test-utils'
+import ItemTimer from '../../components/ItemTimer'
+
+describe('', () => {
+ it('Should render the component.', () => {
+ const container = customRender({ component: ItemTimer })
+ expect(container.asFragment()).toMatchSnapshot()
+ })
+})
diff --git a/src/__tests__/components/Title.test.js b/src/__tests__/components/Title.test.js
new file mode 100644
index 0000000..12387e1
--- /dev/null
+++ b/src/__tests__/components/Title.test.js
@@ -0,0 +1,9 @@
+import Title from '../../components/Title'
+import { customRender } from '../../test-utils'
+
+describe('', () => {
+ it('Should render the component.', () => {
+ const container = customRender({ component: Title })
+ expect(container.asFragment()).toMatchSnapshot()
+ })
+})
diff --git a/src/__tests__/components/ViewSelector.test.js b/src/__tests__/components/ViewSelector.test.js
new file mode 100644
index 0000000..1b3e507
--- /dev/null
+++ b/src/__tests__/components/ViewSelector.test.js
@@ -0,0 +1,20 @@
+import { fireEvent, waitForElement } from '@testing-library/react'
+import { customRender } from '../../test-utils'
+import ViewSelector from '../../components/ViewSelector'
+
+describe('', () => {
+ it('Should render the component.', () => {
+ const container = customRender({ component: ViewSelector })
+ expect(container.asFragment()).toMatchSnapshot()
+ })
+
+ it('Should handle changing the ViewSelector.', async () => {
+ const { getByTestId } = customRender({ component: ViewSelector })
+
+ const selector = await waitForElement(() => getByTestId('view-selector'))
+
+ expect(getByTestId('view-selector').value).toBe('Ship')
+ fireEvent.change(selector, { target: { value: 'Planets' } })
+ expect(getByTestId('view-selector').value).toBe('Planets')
+ })
+})
diff --git a/src/__tests__/components/__snapshots__/CashDisplay.test.js.snap b/src/__tests__/components/__snapshots__/CashDisplay.test.js.snap
new file mode 100644
index 0000000..93483c7
--- /dev/null
+++ b/src/__tests__/components/__snapshots__/CashDisplay.test.js.snap
@@ -0,0 +1,20 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[` Should render the component. 1`] = `
+
+
+
+ Cash:
+
+
+ 100
+
+
+
+`;
diff --git a/src/__tests__/components/__snapshots__/ItemTimer.test.js.snap b/src/__tests__/components/__snapshots__/ItemTimer.test.js.snap
new file mode 100644
index 0000000..8a8665e
--- /dev/null
+++ b/src/__tests__/components/__snapshots__/ItemTimer.test.js.snap
@@ -0,0 +1,9 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[` Should render the component. 1`] = `
+
+
+ 10 minutes 0 seconds
+
+
+`;
diff --git a/src/__tests__/components/__snapshots__/Title.test.js.snap b/src/__tests__/components/__snapshots__/Title.test.js.snap
new file mode 100644
index 0000000..fbee73a
--- /dev/null
+++ b/src/__tests__/components/__snapshots__/Title.test.js.snap
@@ -0,0 +1,11 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[` Should render the component. 1`] = `
+
+
+ Hermes
+
+
+`;
diff --git a/src/__tests__/components/__snapshots__/ViewSelector.test.js.snap b/src/__tests__/components/__snapshots__/ViewSelector.test.js.snap
new file mode 100644
index 0000000..4b99a6c
--- /dev/null
+++ b/src/__tests__/components/__snapshots__/ViewSelector.test.js.snap
@@ -0,0 +1,20 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[` Should render the component. 1`] = `
+
+
+
+
+
+`;
diff --git a/src/__tests__/views/__snapshots__/planets.js.snap b/src/__tests__/views/__snapshots__/planets.js.snap
new file mode 100644
index 0000000..b8fc0eb
--- /dev/null
+++ b/src/__tests__/views/__snapshots__/planets.js.snap
@@ -0,0 +1,802 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[` Should render the component. 1`] = `
+
+
+
+
+
+ Test Planet 1 - Home Planet
+
+
+
+ Items:
+
+
+
+
+ Name: Test Item
+
+
+
+
+ Space: 1
+
+
+
+
+ Value: 1
+
+
+
+
+ Destination: Test Planet 2
+
+
+
+
+
+
+
+ Name: Test Item
+
+
+
+
+ Space: 1
+
+
+
+
+ Value: 1
+
+
+
+
+ Destination: Test Planet 2
+
+
+
+
+
+
+
+ Name: Test Item
+
+
+
+
+ Space: 1
+
+
+
+
+ Value: 1
+
+
+
+
+ Destination: Test Planet 2
+
+
+
+
+
+
+
+ Name: Test Item
+
+
+
+
+ Space: 1
+
+
+
+
+ Value: 1
+
+
+
+
+ Destination: Test Planet 2
+
+
+
+
+
+
+
+ Name: Test Item
+
+
+
+
+ Space: 1
+
+
+
+
+ Value: 1
+
+
+
+
+ Destination: Test Planet 2
+
+
+
+
+
+
+
+
+ Test Planet 2
+
+
+
+
+
+ Items:
+
+
+
+
+ Name: Test Item
+
+
+
+
+ Space: 1
+
+
+
+
+ Value: 1
+
+
+
+
+ Destination: Test Planet 1
+
+
+
+
+
+
+ Name: Test Item
+
+
+
+
+ Space: 1
+
+
+
+
+ Value: 1
+
+
+
+
+ Destination: Test Planet 1
+
+
+
+
+
+
+ Name: Test Item
+
+
+
+
+ Space: 1
+
+
+
+
+ Value: 1
+
+
+
+
+ Destination: Test Planet 1
+
+
+
+
+
+
+ Name: Test Item
+
+
+
+
+ Space: 1
+
+
+
+
+ Value: 1
+
+
+
+
+ Destination: Test Planet 1
+
+
+
+
+
+
+ Name: Test Item
+
+
+
+
+ Space: 1
+
+
+
+
+ Value: 1
+
+
+
+
+ Destination: Test Planet 1
+
+
+
+
+
+
+
+ Test Planet 3
+
+
+
+
+
+ Items:
+
+
+
+
+ Name: Test Item
+
+
+
+
+ Space: 1
+
+
+
+
+ Value: 1
+
+
+
+
+ Destination: Test Planet 2
+
+
+
+
+
+
+ Name: Test Item
+
+
+
+
+ Space: 1
+
+
+
+
+ Value: 1
+
+
+
+
+ Destination: Test Planet 2
+
+
+
+
+
+
+ Name: Test Item
+
+
+
+
+ Space: 1
+
+
+
+
+ Value: 1
+
+
+
+
+ Destination: Test Planet 2
+
+
+
+
+
+
+ Name: Test Item
+
+
+
+
+ Space: 1
+
+
+
+
+ Value: 1
+
+
+
+
+ Destination: Test Planet 2
+
+
+
+
+
+
+ Name: Test Item
+
+
+
+
+ Space: 1
+
+
+
+
+ Value: 1
+
+
+
+
+ Destination: Test Planet 2
+
+
+
+
+
+
+`;
diff --git a/src/__tests__/views/__snapshots__/ship.js.snap b/src/__tests__/views/__snapshots__/ship.js.snap
new file mode 100644
index 0000000..c64b0ec
--- /dev/null
+++ b/src/__tests__/views/__snapshots__/ship.js.snap
@@ -0,0 +1,92 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[` Should render the component. 1`] = `
+
+
+
+ Your Ship
+
+
+ Cargo
+
+
+
+ Test Item
+
+
+
+ Destination:
+
+
+
+ Test Planet 2
+
+
+
+
+
+ Location:
+
+
+
+ Value:
+
+
+
+
+
+ Name:
+
+
+
+
+
+
+`;
diff --git a/src/__tests__/views/planets.js b/src/__tests__/views/planets.js
new file mode 100644
index 0000000..f6aa9aa
--- /dev/null
+++ b/src/__tests__/views/planets.js
@@ -0,0 +1,54 @@
+import { customRender } from '../../test-utils'
+import { defaultState } from '../../fixtures'
+import PlanetsView from '../../views/planets'
+import { waitForElement, fireEvent } from '@testing-library/dom'
+
+const customState = {
+ ...defaultState,
+ ship: {
+ ...defaultState.ship,
+ location: { name: 'Test Planet 1', value: 0 },
+ cargo: [
+ {
+ name: 'Test Item',
+ space: 1,
+ value: 1,
+ id: '0',
+ destination: {
+ name: 'Test Planet 2',
+ value: 50
+ }
+ }
+ ]
+ }
+}
+
+describe('', () => {
+ it('Should render the component.', () => {
+ const container = customRender({
+ component: PlanetsView,
+ state: customState
+ })
+ expect(container.asFragment()).toMatchSnapshot()
+ })
+
+ it('Should handle traveling.', async () => {
+ const { getByTestId } = customRender({
+ component: PlanetsView,
+ state: customState
+ })
+ const button = await waitForElement(() =>
+ getByTestId('travel-button-Test Planet 2')
+ )
+ fireEvent.click(button)
+ })
+
+ it('Should handle adding an item to ship cargo.', async () => {
+ const { getByTestId } = customRender({
+ component: PlanetsView,
+ state: customState
+ })
+ const button = await waitForElement(() => getByTestId('add-button-1'))
+ fireEvent.click(button)
+ })
+})
diff --git a/src/__tests__/views/ship.js b/src/__tests__/views/ship.js
new file mode 100644
index 0000000..7d0673a
--- /dev/null
+++ b/src/__tests__/views/ship.js
@@ -0,0 +1,39 @@
+import { customRender } from '../../test-utils'
+import ShipView from '../../views/ship'
+import { defaultState } from '../../fixtures'
+import { waitForElement, fireEvent } from '@testing-library/dom'
+
+const customState = {
+ ...defaultState,
+ ship: {
+ ...defaultState.ship,
+ cargo: [
+ {
+ name: 'Test Item',
+ space: 1,
+ value: 1,
+ id: '0',
+ destination: {
+ name: 'Test Planet 2',
+ value: 50
+ }
+ }
+ ]
+ }
+}
+
+describe('', () => {
+ it('Should render the component.', () => {
+ const container = customRender({ component: ShipView, state: customState })
+ expect(container.asFragment()).toMatchSnapshot()
+ })
+
+ it('Should handle removing an item from ship cargo.', async () => {
+ const { getByTestId } = customRender({
+ component: ShipView,
+ state: customState
+ })
+ const button = await waitForElement(() => getByTestId('remove-button-0'))
+ fireEvent.click(button)
+ })
+})
diff --git a/src/components/ViewSelector.js b/src/components/ViewSelector.js
index f9d74dc..b55e2e2 100644
--- a/src/components/ViewSelector.js
+++ b/src/components/ViewSelector.js
@@ -10,7 +10,7 @@ const ViewSelector = ({ handleSetView, view }) => {
return (
-