import { <%= className %>Loaded } from './<%= fileName %>.actions';
import { <%= className %>State, Entity, initialState, <%= propertyName %>Reducer } from './<%= fileName %>.reducer';

describe('<%= className %> Reducer', () => {
  const get<%= className %>Id = (it) => it['id'];
  let create<%= className %>;

  beforeEach(() => {
     create<%= className %> = ( id:string, name = '' ): Entity => ({
       id,
       name: name || `name-${id}`
     });
  });

  describe('valid <%= className %> actions ', () => {
    it('should return set the list of known <%= className %>', () => {
        const <%= propertyName %>s = [create<%= className %>( 'PRODUCT-AAA' ),create<%= className %>( 'PRODUCT-zzz' )];
        const action = new <%= className %>Loaded(<%= propertyName %>s);
        const result : <%= className %>State = <%= propertyName %>Reducer(initialState, action);
        const selId : string = get<%= className %>Id(result.list[1]);

        expect(result.loaded).toBe(true);
        expect(result.list.length).toBe(2);
        expect(selId).toBe('PRODUCT-zzz');
    });
  });

  describe('unknown action', () => {
    it('should return the initial state', () => {
      const action = {} as any;
      const result = <%= propertyName %>Reducer(initialState, action);

      expect(result).toBe(initialState);
    });
  });
});
