Filtered.selector.test.js
1 import filteredDapps from './Filtered.selector' 2 3 describe('filteredDapps', () => { 4 const dapps = [ 5 { 6 name: 'DAPP_1', 7 category: 'CATEGORY_1', 8 }, 9 { 10 name: 'DAPP_2', 11 category: 'CATEGORY_2', 12 }, 13 ] 14 15 test('it should return all the dapps when the category is not set', () => { 16 // Given a state where the selected category is null 17 const state = { 18 dapps, 19 selectedCategory: null, 20 } 21 22 // We expect to get back all the dapps 23 expect(filteredDapps(state)).toEqual(dapps) 24 }) 25 26 test('it should return only the matching dapps when the category is set', () => { 27 // Given a state where the selected category is set 28 const state = { 29 dapps, 30 selectedCategory: 'CATEGORY_1', 31 } 32 33 // We expect to get back only the matching dapps 34 expect(filteredDapps(state)).toEqual([ 35 { name: 'DAPP_1', category: 'CATEGORY_1' }, 36 ]) 37 }) 38 })