-
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.
add test for core.containers.newpost
- Loading branch information
Showing
1 changed file
with
62 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,75 @@ | ||
const { describe, it } = global; | ||
// import {expect} from 'chai'; | ||
// import {stub, spy} from 'sinon'; | ||
// import {composer, depsMapper} from '../newpost'; | ||
import {expect} from 'chai'; | ||
import {spy, stub} from 'sinon'; | ||
import {composer, depsMapper} from '../newpost'; | ||
|
||
describe('containers.newpost', () => { | ||
describe('core.containers.newpost', () => { | ||
describe('composer', () => { | ||
it('should get SAVING_ERROR from local state'); | ||
it('should get SAVING_ERROR from local state', () => { | ||
const LocalState = {get: spy()}; | ||
const context = () => ({LocalState}); | ||
|
||
composer({context}, spy()); | ||
|
||
const args = LocalState.get.args[0]; | ||
expect(args).to.have.length(1); | ||
expect(args[0]).to.be.equal('SAVING_ERROR'); | ||
}); | ||
|
||
it('should call onData with null and {error}', () => { | ||
const LocalState = {get: stub().returns('error')}; | ||
const context = () => ({LocalState}); | ||
const onData = spy(); | ||
|
||
composer({context}, onData); | ||
|
||
const args = onData.args[0]; | ||
|
||
expect(args[0]).to.be.equal(null); | ||
expect(args[1]).to.be.deep.equal({error: 'error'}); | ||
}); | ||
|
||
it('should return clearErrors', () => { | ||
const LocalState = {get: spy()}; | ||
const context = () => ({LocalState}); | ||
const clearErrors = spy(); | ||
|
||
const clearFunc = composer({context, clearErrors}, spy()); | ||
|
||
expect(clearFunc).to.be.equal(clearErrors); | ||
}); | ||
|
||
it('should get SAVING_NEW_POST from local state'); | ||
}); | ||
|
||
describe('depsMapper', () => { | ||
describe('actions', () => { | ||
it('should map posts.create'); | ||
it('should map posts.clearErrors'); | ||
it('should map posts.create', () => { | ||
const actions = {posts: {create: spy()}}; | ||
|
||
const deps = depsMapper({}, actions); | ||
|
||
expect(deps.create).to.be.equal(actions.posts.create); | ||
}); | ||
|
||
it('should map posts.clearErrors', () => { | ||
const actions = {posts: {clearErrors: spy()}}; | ||
|
||
const deps = depsMapper({}, actions); | ||
|
||
expect(deps.clearErrors).to.be.equal(actions.posts.clearErrors); | ||
}); | ||
}); | ||
|
||
describe('context', () => { | ||
it('should map the whole context as a function'); | ||
it('should map the whole context as a function', () => { | ||
const actions = {posts: {create: spy(), clearErrors: spy()}}; | ||
const context = spy(); | ||
|
||
const deps = depsMapper(context, actions); | ||
|
||
expect(deps.context()).to.be.equal(context); | ||
}); | ||
}); | ||
}); | ||
}); |