Skip to content

Instantly share code, notes, and snippets.

@bmfteixeira
Last active September 16, 2017 16:30
Show Gist options
  • Save bmfteixeira/5a5878507f40be7c7e8ff19ba45893ec to your computer and use it in GitHub Desktop.
Save bmfteixeira/5a5878507f40be7c7e8ff19ba45893ec to your computer and use it in GitHub Desktop.
// the getter
getElemsByCategory: state => (category) => {
return state.elems.filter((el, index, arr) => el.category === category)
}
// the test
it('should return the elements that have Cat1 as category', done => {
const expected = [
{
'id': '1',
'category': 'Cat1'
},
{
'id': '2',
'category': 'Cat1'
}
]
const state = [
{
'id': '1',
'category': 'Cat1'
},
{
'id': '2',
'category': 'Cat1'
},
{
'id': '3',
'category': 'Cat2'
}
]
expect(getters.getElemsByCategory(state)('Cat1')).to.be.deep.equal(expected)
done()
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment