Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

📦 v0.2.0 #54

Merged
merged 9 commits into from
Aug 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@

<div align="center">

[![NPM Version][npm-image]][npm-url]
[![Build Status][travis]][travis]
[![Coverage Status][coverage-badge]][coverage-link]

</div>

Expand Down Expand Up @@ -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
10 changes: 8 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
15 changes: 12 additions & 3 deletions src/__tests__/App.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
describe('Fake Test', () => {
it('Should pass.', () => {
expect(1 + 1).toBe(2)
import React from 'react'
import { customRender } from '../test-utils'
import App from '../App'

jest.mock('../components/ItemTimer', () => {
return () => <span>MockedTime</span>
})

describe('<App />', () => {
it('Should render the <App /> component.', () => {
const container = customRender({ component: App })
expect(container.asFragment()).toMatchSnapshot()
})
})
100 changes: 100 additions & 0 deletions src/__tests__/__snapshots__/App.test.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`<App /> Should render the <App /> component. 1`] = `
<DocumentFragment>
<div
class="StyledBox-sc-13pk1d4-0 cXRmiT"
>
<h1
class="StyledHeading-sc-1rdh4aw-0 rfVJR"
>
Hermes
</h1>
<span>
MockedTime
</span>
<div
class="StyledBox-sc-13pk1d4-0 CAsMy"
>
<h2
class="StyledHeading-sc-1rdh4aw-0 gBloPj"
>
Cash:
</h2>
<span
class="StyledText-sc-1sadyjn-0 fWSbXS"
>
100
</span>
</div>
<div
class="StyledBox-sc-13pk1d4-0 dfMVfp"
>
<select
data-testid="view-selector"
>
actuallyReallyAlex marked this conversation as resolved.
Show resolved Hide resolved
<option>
Ship
</option>
<option>
Planets
</option>
</select>
</div>
<div>
<h2>
Your Ship
</h2>
<h3>
Cargo
</h3>
<div
class="StyledBox-sc-13pk1d4-0 IRSNj"
>
<span
class="StyledText-sc-1sadyjn-0 bnqisW"
>
Volume Remaining:
</span>
<span
class="StyledText-sc-1sadyjn-0 fWSbXS"
>
5
</span>
</div>
<h3>
Location:
</h3>
<div
class="StyledBox-sc-13pk1d4-0 MmWcm"
>
<span
class="StyledText-sc-1sadyjn-0 isVaoK"
>
Value:
</span>
<div
class="StyledBox__StyledBoxGap-sc-13pk1d4-1 hPsznL"
/>
<span
class="StyledText-sc-1sadyjn-0 gNZQxf"
/>
<div
class="StyledBox__StyledBoxGap-sc-13pk1d4-1 hPsznL"
/>
<span
class="StyledText-sc-1sadyjn-0 isVaoK"
>
Name:
</span>
<div
class="StyledBox__StyledBoxGap-sc-13pk1d4-1 hPsznL"
/>
<span
class="StyledText-sc-1sadyjn-0 gNZQxf"
/>
</div>
</div>
</div>
</DocumentFragment>
`;
9 changes: 9 additions & 0 deletions src/__tests__/components/CashDisplay.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { customRender } from '../../test-utils'
import CashDisplay from '../../components/CashDisplay'

describe('<CashDisplay />', () => {
it('Should render the <CashDisplay /> component.', () => {
const container = customRender({ component: CashDisplay })
expect(container.asFragment()).toMatchSnapshot()
})
})
17 changes: 17 additions & 0 deletions src/__tests__/components/ItemTimer.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { customRender } from '../../test-utils'
import ItemTimer from '../../components/ItemTimer'

jest.mock('../../util', () => {
const moment = require('moment')
const mockCreateDuration = () => moment.duration({ minutes: 60, seconds: 0 })
return {
createDuration: mockCreateDuration
}
})

describe('<ItemTimer />', () => {
it('Should render the <ItemTimer /> component.', () => {
const container = customRender({ component: ItemTimer })
expect(container.asFragment()).toMatchSnapshot()
})
})
9 changes: 9 additions & 0 deletions src/__tests__/components/Title.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import Title from '../../components/Title'
import { customRender } from '../../test-utils'

describe('<Title />', () => {
it('Should render the <Title /> component.', () => {
const container = customRender({ component: Title })
expect(container.asFragment()).toMatchSnapshot()
})
})
20 changes: 20 additions & 0 deletions src/__tests__/components/ViewSelector.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { fireEvent, waitForElement } from '@testing-library/react'
import { customRender } from '../../test-utils'
import ViewSelector from '../../components/ViewSelector'

describe('<ViewSelector />', () => {
it('Should render the <ViewSelector /> 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')
})
})
20 changes: 20 additions & 0 deletions src/__tests__/components/__snapshots__/CashDisplay.test.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`<CashDisplay /> Should render the <CashDisplay /> component. 1`] = `
<DocumentFragment>
<div
class="StyledBox-sc-13pk1d4-0 CAsMy"
>
<h2
class="StyledHeading-sc-1rdh4aw-0 gBloPj"
>
Cash:
</h2>
<span
class="StyledText-sc-1sadyjn-0 fWSbXS"
>
100
</span>
</div>
</DocumentFragment>
`;
9 changes: 9 additions & 0 deletions src/__tests__/components/__snapshots__/ItemTimer.test.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`<ItemTimer /> Should render the <ItemTimer /> component. 1`] = `
<DocumentFragment>
<span>
0 minutes 0 seconds
</span>
</DocumentFragment>
`;
11 changes: 11 additions & 0 deletions src/__tests__/components/__snapshots__/Title.test.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`<Title /> Should render the <Title /> component. 1`] = `
<DocumentFragment>
<h1
class="StyledHeading-sc-1rdh4aw-0 rfVJR"
>
Hermes
</h1>
</DocumentFragment>
`;
20 changes: 20 additions & 0 deletions src/__tests__/components/__snapshots__/ViewSelector.test.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`<ViewSelector /> Should render the <ViewSelector /> component. 1`] = `
<DocumentFragment>
<div
class="StyledBox-sc-13pk1d4-0 dfMVfp"
>
<select
data-testid="view-selector"
>
actuallyReallyAlex marked this conversation as resolved.
Show resolved Hide resolved
<option>
Ship
</option>
<option>
Planets
</option>
</select>
</div>
</DocumentFragment>
`;
Loading