Ejemplo n.º 1
0
 test('SET_FILTER adds a new filter', () => {
   const key = 'test';
   const value = 'test-value';
   const expected = {
     test: ['test-value']
   };
   expect(reducer({}, { type: 'SET_FILTER', key, value })).toEqual(expected);
 });
Ejemplo n.º 2
0
 test('SET_FILTER ignores duplicates', () => {
   const key = 'test';
   const value = 'test-value-1';
   const initial = {
     test: ['test-value-1']
   };
   const expected = {
     test: ['test-value-1']
   };
   expect(reducer(initial, { type: 'SET_FILTER', key, value })).toEqual(expected);
 });
Ejemplo n.º 3
0
 test('SET_FILTER sets to an empty array if passed a falsy value', () => {
   const key = 'test';
   const value = null;
   const initial = {
     test: ['test-value-1']
   };
   const expected = {
     test: []
   };
   expect(reducer(initial, { type: 'SET_FILTER', key, value })).toEqual(expected);
 });
Ejemplo n.º 4
0
 test('SET_FILTER replaces an existing filter for a key', () => {
   const key = 'test';
   const value = 'test-value-2';
   const initial = {
     test: ['test-value-1']
   };
   const expected = {
     test: ['test-value-2']
   };
   expect(reducer(initial, { type: 'SET_FILTER', key, value })).toEqual(expected);
 });
Ejemplo n.º 5
0
 test('SET_FILTERS overwrites existing filters', () => {
   const initial = {
     test: ['test-value-1']
   };
   const input = {
     test: ['test-value-2']
   };
   const expected = {
     test: ['test-value-2']
   };
   expect(reducer(initial, { type: 'SET_FILTERS', filters: input })).toEqual(expected);
 });
Ejemplo n.º 6
0
 test('SET_FILTER removes filters on other keys', () => {
   const initial = {
     test: ['test-value-1']
   };
   const input = {
     '*': ['test']
   };
   const expected = {
     '*': ['test']
   };
   expect(reducer(initial, { type: 'SET_FILTERS', filters: input })).toEqual(expected);
 });
Ejemplo n.º 7
0
 filters: (state, action) => history.filters(filters(state, action), action),
Ejemplo n.º 8
0
 test('returns an empty object on init', () => {
   const expected = {};
   expect(reducer(undefined, {})).toEqual(expected);
 });
Ejemplo n.º 9
0
 test('SET_FILTERS sets the state', () => {
   const expected = {
     '*': ['test']
   };
   expect(reducer(undefined, { type: 'SET_FILTERS', filters: expected })).toEqual(expected);
 });