Skip to content

Commit

Permalink
Revert "Remove GamePage test for old 'trying-out' code"
Browse files Browse the repository at this point in the history
This reverts commit 604a002.
  • Loading branch information
OlafSzmidt authored and mrniket committed Apr 4, 2018
1 parent 604a002 commit 14bd2ee
Show file tree
Hide file tree
Showing 2 changed files with 187 additions and 0 deletions.
143 changes: 143 additions & 0 deletions game_frontend/src/containers/GamePage/__snapshots__/index.test.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`<GamePage /> should render successfully with no movies 1`] = `
ShallowWrapper {
"length": 1,
Symbol(enzyme.__root__): [Circular],
Symbol(enzyme.__unrendered__): <GamePage
movies={Array []}
/>,
Symbol(enzyme.__renderer__): Object {
"batchedUpdates": [Function],
"getNode": [Function],
"render": [Function],
"simulateEvent": [Function],
"unmount": [Function],
},
Symbol(enzyme.__node__): Object {
"instance": null,
"key": undefined,
"nodeType": "function",
"props": Object {
"children": Array [
<div>
Welcome to the AIMMO game screen
</div>,
<styled.button
id="fetch-movies-button"
onClick={[Function]}
>
Get the GhibliMovies!
</styled.button>,
<ul />,
],
},
"ref": null,
"rendered": Array [
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": "Welcome to the AIMMO game screen",
},
"ref": null,
"rendered": "Welcome to the AIMMO game screen",
"type": "div",
},
Object {
"instance": null,
"key": undefined,
"nodeType": "class",
"props": Object {
"children": "Get the GhibliMovies!",
"id": "fetch-movies-button",
"onClick": [Function],
},
"ref": null,
"rendered": "Get the GhibliMovies!",
"type": [Function],
},
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": Array [],
},
"ref": null,
"rendered": Array [],
"type": "ul",
},
],
"type": Symbol(react.fragment),
},
Symbol(enzyme.__nodes__): Array [
Object {
"instance": null,
"key": undefined,
"nodeType": "function",
"props": Object {
"children": Array [
<div>
Welcome to the AIMMO game screen
</div>,
<styled.button
id="fetch-movies-button"
onClick={[Function]}
>
Get the GhibliMovies!
</styled.button>,
<ul />,
],
},
"ref": null,
"rendered": Array [
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": "Welcome to the AIMMO game screen",
},
"ref": null,
"rendered": "Welcome to the AIMMO game screen",
"type": "div",
},
Object {
"instance": null,
"key": undefined,
"nodeType": "class",
"props": Object {
"children": "Get the GhibliMovies!",
"id": "fetch-movies-button",
"onClick": [Function],
},
"ref": null,
"rendered": "Get the GhibliMovies!",
"type": [Function],
},
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": Array [],
},
"ref": null,
"rendered": Array [],
"type": "ul",
},
],
"type": Symbol(react.fragment),
},
],
Symbol(enzyme.__options__): Object {
"adapter": ReactSixteenAdapter {
"options": Object {
"enableComponentDidUpdateOnSetState": true,
},
},
},
}
`;
44 changes: 44 additions & 0 deletions game_frontend/src/containers/GamePage/index.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/* eslint-env jest */
import ConnectedGamePage, { GamePage } from 'containers/GamePage'
import configureStore from 'redux-mock-store'
import { shallow } from 'enzyme'
import shallowWithStore from 'containers/testHelpers/shallowWithStore'
import React from 'react'

describe('<GamePage />', () => {
it('should render successfully with a mock store', () => {
const testState = {
movieReducer: {
movies: []
}
}

const store = configureStore([])(testState)
const component = shallowWithStore(<ConnectedGamePage />, store)

expect(component.dive()).toBeDefined()
})

it('should render successfully with no movies', () => {
const props = {
movies: []
}

const component = shallow(<GamePage {...props} />)

expect(component).toMatchSnapshot()
})

it('should call fetchMovies when I click on the button', () => {
const fetchMovies = jest.fn()
const props = {
movies: [],
fetchMovies
}

const component = shallow(<GamePage {...props} />)

component.find('#fetch-movies-button').simulate('click')
expect(fetchMovies.mock.calls.length).toBe(1)
})
})

0 comments on commit 14bd2ee

Please sign in to comment.