Q:

Jest Test to check redux-form name

I am newbie in Jest, redux. My redux form (in Typescript) is as below:
let SelectorForms = reduxForm({
  form: 'selector-form',
  validate,
})(SelectorForms);

SelectorForms = connect(state => (
  {initialValues: {code: state.code,
    region:state.region}}))(SelectorForms);

export default SelectorForms

I am trying to write a test to verify the form name as:

import * as React from "react";
import {mount} from "enzyme";
import thunk from "redux-thunk";
import {Provider} from "react-redux";
import SelectorForms from "./SelectorForm";
import {mockClient} from "./mockClientData";
import configureStore from "redux-mock-store";

const mockStore = configureStore([thunk]);
const store = mockStore({
  selectedClient: {
    clientInfo: mockClient
  },
  cimplicityQueryStringData:{Code:'1234',region:'REG'}
});
let component;
describe("Header", () => {
  beforeEach(() => {
    component = mount(
      <Provider store={store}>
        <SelectorForms />
      </Provider>
    );
  });

  it("should have selector-form", () => {
    console.log(component);
    expect(component.find("selector-form").length).toBe(1);
  });

});

However, the test is failing. I need to know how to get the form name.
Should I just export it before connecting the state? If so how?

A:

You should export reduxForm options object.
export const selectorFormOptions = {
  form: 'selector-form',
  validate,
};

let SelectorForms = reduxForm(selectorFormOptions)(SelectorForms);

And then you can import { selectorFormOptions } and expect(selectorFormOptions).toEqual(...).

