Last active
September 16, 2017 16:30
-
-
Save bmfteixeira/5a5878507f40be7c7e8ff19ba45893ec to your computer and use it in GitHub Desktop.
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
// 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