Skip to content

Instantly share code, notes, and snippets.

@chudaol
Created November 20, 2016 17:13
Show Gist options
  • Save chudaol/e89dd0f77b1563366d5eec16bd6ae4a9 to your computer and use it in GitHub Desktop.
Save chudaol/e89dd0f77b1563366d5eec16bd6ae4a9 to your computer and use it in GitHub Desktop.
Unit tests for getters functions from getters.js
import getters from 'src/vuex/getters'
describe('getters.js', () => {
var state, lists
beforeEach(() => {
lists = [{id: '1', title: 'groceries'}, {id: '2', title: 'clothes'}]
state = {
shoppinglists: lists
}
})
describe('getLists', () => {
it('should return lists', () => {
expect(getters.getLists(state)).to.eql(lists)
})
})
describe('getListById', () => {
it('should return the shopping list object by its id', () => {
expect(getters.getListById(state, '1')).to.eql({id: '1', title: 'groceries'})
})
it('should not return anything if the passed id is not in the list', () => {
expect(getters.getListById(state, 'notexisting')).to.be.empty
})
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment