mercredi 25 avril 2018

how to test redux form state

I would like to know how to test redux-form form-values-selector function?

my Selectrs.js file

import { formValueSelector } from 'redux-form';

export const formSelector = formValueSelector('params');

const getSummParam = state => formSelector(state, 'summ');

export default getSummParam;

and here is my testing file Selectrs.test.js

import getSummParam, { formSelector } from './Selectors';

describe('selectors test', () => {
  const state = {
    form: {
      params: {
        values: {
            summ: '12',
        }
      }
    }
  };

  it('should return formSelector value', () => {
        expect(formSelector(state)).toEqual(state.form.params);
    });
  it('should return getSummParam value', () => {
    const expectedResult = state.form.params.summ;

        expect(getSummParam(state)).toEqual(expectedResult);
    })
});

I have got an error:

Invariant Violation: No fields specified

Aucun commentaire:

Enregistrer un commentaire