text: import expensesReducer from '../../reducers/expenses';
  
  import expenses from '../fixtures/expenses';
  
  test('should set default state', () => {
    const state = expensesReducer(undefined, { type: '@@INIT' });
  
    expect(state).toEqual([]);
  });
  
  test('should remove expense by id', () => {
    const action = {
      type: 'REMOVE_EXPENSE',
      id: expenses[1].id
    };
    const state = expensesReducer(expenses, action);
  
    expect(state).toEqual([ expenses[0], expenses[2] ]);
  });
  
  test('should not remove expenses if id not found', () => {
    const action = {
      type: 'REMOVE_EXPENSE',
      id: '-1'
    };
    const state = expensesReducer(expenses, action);
  
    expect(state).toEqual(expenses);
  });
  
  test('should add expense', () => {
    const expense = {
      id: '123abc',
      description: 'Gas',
      note: '',
      amount: 2790,
      createdAt: 5000
    };
    const action = {
      type: 'ADD_EXPENSE',
      expense
    };
    const state = expensesReducer(expenses, action);
  
    expect(state).toEqual([ ...expenses, expense ]);
  });
  
  test('should edit expense with matching id', () => {
    const note = 'for January';
    const updates = {
      note
    };
    const action = {
      type: 'EDIT_EXPENSE',
      id: expenses[1].id,
      updates
    };
    const state = expensesReducer(expenses, action);
  
    expect(state[1].note).toBe(note);
  });
  
  test('should not edit expense if no matching id', () => {
    const note = 'for January';
    const updates = {
      note
    };
    const action = {
      type: 'EDIT_EXPENSE',
      id: '-1',
      updates
    };
    const state = expensesReducer(expenses, action);
  
    expect(state).toEqual(expenses);
  });
  
  test('should set expenses', () => {
    const action = {
      type: 'SET_EXPENSES',
      expenses: [expenses[1]]
    };
    const state = expensesReducer(expenses, action);
  
    expect(state).toEqual([expenses[1]]);
  });
  