-
-
Save chudaol/e89dd0f77b1563366d5eec16bd6ae4a9 to your computer and use it in GitHub Desktop.
Unit tests for getters functions from getters.js
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
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