-
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.
- Loading branch information
1 parent
37bd8c2
commit 56416b0
Showing
11 changed files
with
120 additions
and
33 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 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
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,26 @@ | ||
import React from 'react'; | ||
import CounterComponent from './CounterComponent'; | ||
import { mount } from 'enzyme'; | ||
import sinon from 'sinon'; | ||
|
||
describe('(Component) CounterComponent', () => { | ||
let _component; | ||
const _dispatch = sinon.spy(); | ||
const incrementFunc = sinon.spy(); | ||
const _actions = { | ||
incrementCounter: incrementFunc | ||
}; | ||
beforeEach(() => { | ||
_component = mount(<CounterComponent count={0} dispatch={_dispatch} actions={_actions} />); | ||
}); | ||
|
||
it('Can mount', () => { | ||
expect(_component.type()).to.equal(CounterComponent); | ||
}); | ||
|
||
it('Can increment the counter', () => { | ||
_component.find('#incrementButton').first().simulate('click'); | ||
expect(_dispatch).to.have.been.calledOnce(); | ||
expect(incrementFunc).to.have.been.calledOnce(); | ||
}); | ||
}); |
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,21 @@ | ||
import React from 'react'; | ||
import MainComponent from './MainComponent'; | ||
import { mount } from 'enzyme'; | ||
import sinon from 'sinon'; | ||
|
||
describe('(Component) MainComponent', () => { | ||
let _component; | ||
const _dispatch = sinon.spy(); | ||
const incrementFunc = sinon.spy(); | ||
const _actions = { | ||
incrementCounter: incrementFunc | ||
}; | ||
beforeEach(() => { | ||
_component = mount(<MainComponent count={0} dispatch={_dispatch} actions={_actions} />); | ||
}); | ||
|
||
it('Can mount', () => { | ||
expect(_component.type()).to.equal(MainComponent); | ||
expect(_component.html()).to.equal('<div>hi!</div>'); | ||
}); | ||
}); |
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,2 @@ | ||
export const INCREMENT_COUNT = 'INCREMENT_COUNT'; | ||
export const DOUBLE_COUNT = 'DOUBLE_COUNT'; | ||
export const RESET_COUNTER = 'RESET_COUNTER'; |
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,15 @@ | ||
import React from 'react'; | ||
import AppContainer from './AppContainer'; | ||
import { shallow } from 'enzyme'; | ||
import { Provider } from 'react-redux'; | ||
|
||
describe('(Component) AppContainer', () => { | ||
let _component; | ||
beforeEach(() => { | ||
_component = shallow(<AppContainer routes={{}} store={{ subscribe: () => {} }} />); | ||
}); | ||
|
||
it('Can mount', () => { | ||
expect(_component.type()).to.equal(Provider); | ||
}); | ||
}); |
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
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,33 @@ | ||
import countReducer from './countReducer'; | ||
import sinon from 'sinon'; | ||
import actions from '../actions/countActions'; | ||
describe('(Store) countReducer', () => { | ||
let _globalState; | ||
let _dispatchSpy; | ||
let _getStateSpy; | ||
beforeEach(() => { | ||
_globalState = countReducer(); | ||
_dispatchSpy = sinon.spy((action) => { | ||
_globalState = { | ||
..._globalState, | ||
...countReducer(_globalState, action) | ||
}; | ||
}); | ||
_getStateSpy = sinon.spy(() => { | ||
return _globalState; | ||
}); | ||
}); | ||
it('starts with a count of 0', () => { | ||
expect(_globalState).to.exist(); | ||
expect(_globalState).to.have.property('count'); | ||
expect(_globalState.count).to.equal(0); | ||
}); | ||
|
||
it('will increment when the increment action is called', () => { | ||
_dispatchSpy(actions.incrementCounter()); | ||
const incrementedState = _getStateSpy(); | ||
expect(incrementedState).to.exist(); | ||
expect(incrementedState).to.have.property('count'); | ||
expect(incrementedState.count).to.equal(1); | ||
}); | ||
}); |
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,2 +1,17 @@ | ||
import createStore from './createStore'; | ||
describe('(Store) createStore', () => { | ||
let _store; | ||
|
||
beforeEach(() => { | ||
_store = createStore(); | ||
}); | ||
|
||
it('Creates a store object with functions', () => { | ||
expect(_store).to.exist(); | ||
expect(_store).to.be.an('object'); | ||
expect(_store).to.have.property('dispatch'); | ||
expect(_store.dispatch).to.be.a('function'); | ||
expect(_store).to.have.property('subscribe'); | ||
expect(_store.subscribe).to.be.a('function'); | ||
}); | ||
}); |