示例#1
0
 it('sets the query and loading', () => {
   const state = search(
     {query: 'bar', loading: false, results: [{slug: 'bar'}]},
     {type: 'SEARCH_STARTED', payload: {query: 'foo'}});
   assert.equal(state.query, 'foo');
   assert.strictEqual(state.loading, true);
   assert.deepEqual(state.results, []);
 });
示例#2
0
 function getNextState() {
   return search(initialState, {
     type: 'SEARCH_LOADED',
     payload: {
       query: 'foo',
       ...response,
     },
   });
 }
示例#3
0
 it('defaults to not loading', () => {
   const { loading } = search(undefined, {type: 'unrelated'});
   assert.strictEqual(loading, false);
 });
示例#4
0
 it('defaults to a null query', () => {
   const { query } = search(undefined, {type: 'unrelated'});
   assert.strictEqual(query, null);
 });
示例#5
0
 it('sets the query', () => {
   const state = search(undefined, {type: 'SET_QUERY', payload: {query: 'foo'}});
   assert.equal(state.query, 'foo');
   const newState = search(state, {type: 'SET_QUERY', payload: {query: 'bar'}});
   assert.equal(newState.query, 'bar');
 });
示例#6
0
 it('defaults to empty results', () => {
   const { results } = search(undefined, {type: 'unrelated'});
   assert.deepEqual(results, []);
 });