Skip to content
Darin Haener edited this page Oct 5, 2015 · 2 revisions

#Testing Alt Stores

Testing your stores is super simple with this wrapper:

import TestStore from 'legit-tests/alt/store'
import MyStore from 'path/to/your/store'
import MyActions from 'path/to/your/actions'

describe('My Store', () => {
  it('should do all the things', () => {
    TestStore(MyStore, MyActions)
    .addTodo({ text: 'Get Milk', completed: false })
    .test(({ state }) => {
      expect(state.todos[0].text).to.equal('Get Milk')
    })
  })
})

The wrapper will attempt to proxy any function calls other than test to your actions, so you can chain any actions you have defined right onto the test object and it will just work.

The only object returned on the test method is the store, so any functions or objects available on the store singleton can be retrieved in the test callback.

Clone this wiki locally