-
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
alexlee-dev
committed
Aug 22, 2019
1 parent
ab24851
commit 36133fd
Showing
14 changed files
with
281 additions
and
242 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 |
---|---|---|
@@ -1,53 +1,16 @@ | ||
/** | ||
* @jest-environment node | ||
*/ | ||
|
||
import React from 'react' | ||
import App from '../App' | ||
import { mount, shallow } from 'enzyme' | ||
import { render } from '@testing-library/react' | ||
import { Provider } from 'react-redux' | ||
import configureStore from 'redux-mock-store' | ||
|
||
const middlewares = [] | ||
const mockStore = configureStore(middlewares) | ||
|
||
const defaultState = { | ||
ship: { | ||
cargo: [], | ||
location: { | ||
name: null, | ||
value: null | ||
} | ||
}, | ||
ui: { | ||
view: 'Ship' | ||
}, | ||
user: { | ||
cash: 100 | ||
}, | ||
world: { | ||
isTimerRunning: false, | ||
planets: [] | ||
} | ||
} | ||
|
||
const rerenderShallow = customState => | ||
shallow( | ||
<Provider store={mockStore(customState ? customState : defaultState)}> | ||
<App /> | ||
</Provider> | ||
) | ||
|
||
const rerenderMount = customState => | ||
mount( | ||
<Provider store={mockStore(customState ? customState : defaultState)}> | ||
<App /> | ||
</Provider> | ||
) | ||
import { defaultState, mockStore } from '../fixtures' | ||
import App from '../App' | ||
|
||
describe('<App />', () => { | ||
it('Should render the <App /> component.', () => { | ||
const wrapper = rerenderShallow() | ||
expect(wrapper.html()).toMatchSnapshot() | ||
const container = render( | ||
<Provider store={mockStore(defaultState)}> | ||
<App /> | ||
</Provider> | ||
) | ||
expect(container.asFragment()).toMatchSnapshot() | ||
}) | ||
}) |
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,3 +1,84 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`<App /> Should render the <App /> component. 1`] = `"<div class=\\"StyledBox-sc-13pk1d4-0 cXRmiT\\"><h1 class=\\"StyledHeading-sc-1rdh4aw-0 rfVJR\\">Hermes</h1><span>10 minutes 0 seconds</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><option>Ship</option><option>Planets</option></select></div><div><h2>Your Ship</h2><h3>Cargo</h3><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\\"></div><span class=\\"StyledText-sc-1sadyjn-0 gNZQxf\\"></span><div class=\\"StyledBox__StyledBoxGap-sc-13pk1d4-1 hPsznL\\"></div><span class=\\"StyledText-sc-1sadyjn-0 isVaoK\\">Name:</span><div class=\\"StyledBox__StyledBoxGap-sc-13pk1d4-1 hPsznL\\"></div><span class=\\"StyledText-sc-1sadyjn-0 gNZQxf\\"></span></div></div></div>"`; | ||
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> | ||
10 minutes 0 seconds | ||
</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> | ||
<option> | ||
Ship | ||
</option> | ||
<option> | ||
Planets | ||
</option> | ||
</select> | ||
</div> | ||
<div> | ||
<h2> | ||
Your Ship | ||
</h2> | ||
<h3> | ||
Cargo | ||
</h3> | ||
<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> | ||
`; |
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,53 +1,16 @@ | ||
/** | ||
* @jest-environment node | ||
*/ | ||
|
||
import React from 'react' | ||
import CashDisplay from '../../components/CashDisplay' | ||
import { mount, shallow } from 'enzyme' | ||
import { render } from '@testing-library/react' | ||
import { Provider } from 'react-redux' | ||
import configureStore from 'redux-mock-store' | ||
|
||
const middlewares = [] | ||
const mockStore = configureStore(middlewares) | ||
|
||
const defaultState = { | ||
ship: { | ||
cargo: [], | ||
location: { | ||
name: null, | ||
value: null | ||
} | ||
}, | ||
ui: { | ||
view: 'Ship' | ||
}, | ||
user: { | ||
cash: 100 | ||
}, | ||
world: { | ||
isTimerRunning: false, | ||
planets: [] | ||
} | ||
} | ||
|
||
const rerenderShallow = customState => | ||
shallow( | ||
<Provider store={mockStore(customState ? customState : defaultState)}> | ||
<CashDisplay /> | ||
</Provider> | ||
) | ||
|
||
const rerenderMount = customState => | ||
mount( | ||
<Provider store={mockStore(customState ? customState : defaultState)}> | ||
<CashDisplay /> | ||
</Provider> | ||
) | ||
import { defaultState, mockStore } from '../../fixtures' | ||
import CashDisplay from '../../components/CashDisplay' | ||
|
||
describe('<CashDisplay />', () => { | ||
it('Should render the <CashDisplay /> component.', () => { | ||
const wrapper = rerenderShallow() | ||
expect(wrapper.html()).toMatchSnapshot() | ||
const container = render( | ||
<Provider store={mockStore(defaultState)}> | ||
<CashDisplay /> | ||
</Provider> | ||
) | ||
expect(container.asFragment()).toMatchSnapshot() | ||
}) | ||
}) |
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,53 +1,16 @@ | ||
/** | ||
* @jest-environment node | ||
*/ | ||
|
||
import React from 'react' | ||
import ItemTimer from '../../components/ItemTimer' | ||
import { mount, shallow } from 'enzyme' | ||
import { render } from '@testing-library/react' | ||
import { Provider } from 'react-redux' | ||
import configureStore from 'redux-mock-store' | ||
|
||
const middlewares = [] | ||
const mockStore = configureStore(middlewares) | ||
|
||
const defaultState = { | ||
ship: { | ||
cargo: [], | ||
location: { | ||
name: null, | ||
value: null | ||
} | ||
}, | ||
ui: { | ||
view: 'Ship' | ||
}, | ||
user: { | ||
cash: 100 | ||
}, | ||
world: { | ||
isTimerRunning: false, | ||
planets: [] | ||
} | ||
} | ||
|
||
const rerenderShallow = customState => | ||
shallow( | ||
<Provider store={mockStore(customState ? customState : defaultState)}> | ||
<ItemTimer /> | ||
</Provider> | ||
) | ||
|
||
const rerenderMount = customState => | ||
mount( | ||
<Provider store={mockStore(customState ? customState : defaultState)}> | ||
<ItemTimer /> | ||
</Provider> | ||
) | ||
import { defaultState, mockStore } from '../../fixtures' | ||
import ItemTimer from '../../components/ItemTimer' | ||
|
||
describe('<ItemTimer />', () => { | ||
it('Should render the <ItemTimer /> component.', () => { | ||
const wrapper = rerenderShallow() | ||
expect(wrapper.html()).toMatchSnapshot() | ||
const container = render( | ||
<Provider store={mockStore(defaultState)}> | ||
<ItemTimer /> | ||
</Provider> | ||
) | ||
expect(container.asFragment()).toMatchSnapshot() | ||
}) | ||
}) |
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,53 +1,10 @@ | ||
/** | ||
* @jest-environment node | ||
*/ | ||
|
||
import React from 'react' | ||
import { render } from '@testing-library/react' | ||
import Title from '../../components/Title' | ||
import { mount, shallow } from 'enzyme' | ||
import { Provider } from 'react-redux' | ||
import configureStore from 'redux-mock-store' | ||
|
||
const middlewares = [] | ||
const mockStore = configureStore(middlewares) | ||
|
||
const defaultState = { | ||
ship: { | ||
cargo: [], | ||
location: { | ||
name: null, | ||
value: null | ||
} | ||
}, | ||
ui: { | ||
view: 'Ship' | ||
}, | ||
user: { | ||
cash: 100 | ||
}, | ||
world: { | ||
isTimerRunning: false, | ||
planets: [] | ||
} | ||
} | ||
|
||
const rerenderShallow = customState => | ||
shallow( | ||
<Provider store={mockStore(customState ? customState : defaultState)}> | ||
<Title /> | ||
</Provider> | ||
) | ||
|
||
const rerenderMount = customState => | ||
mount( | ||
<Provider store={mockStore(customState ? customState : defaultState)}> | ||
<Title /> | ||
</Provider> | ||
) | ||
|
||
describe('<Title />', () => { | ||
it('Should render the <Title /> component.', () => { | ||
const wrapper = rerenderShallow() | ||
expect(wrapper.html()).toMatchSnapshot() | ||
const container = render(<Title />) | ||
expect(container.asFragment()).toMatchSnapshot() | ||
}) | ||
}) |
Oops, something went wrong.