import { fromJS } from 'immutable';
import {
  makeSelectPreviewAndTest,
  makeSelectCustomers,
  makeSelectExtractedTags,
  makeSelectIsSearchingCustomer,
  makeSelectIsExtractingTags,
  makeSelectSearchError,
  makeSelectHasSearched,
  makeSelectApiWarnings,
  makeSelectApiErrors,
  makeSelectPreviewData,
  makeSelectIsUpdatingPreview,
  makeSelectIsSendingTestEmail,
  makeSelectTags,
  makeSelectTestCustomers,
  makeSelectIsFetchingTestCustomers,
  makeSelectTestGroups,
  makeSelectIsFetchingTestGroups,
  makeSelectMessageMetaConfigId,
  makeSelectIsCreatingMessageMeta,
  makeSelectPrefilledValues,
  makeSelectTestMessageResponse,
  makeSelectIsSendingTestMessage,
} from '../selectors';

describe('TestAndPreviewSlidebox selectors', () => {
  it('should return the expected object with default values when substate is empty for makeSelectTestCustomers', () => {
    const state = fromJS({ previewAndTest: { testCustomers: [] } });
    const expected = fromJS([]);
    const selector = makeSelectTestCustomers();
    const result = selector(state);
    expect(result).toEqual(expected);
  });
  it('should return the expected object with default values when substate is empty for makeSelectTestGroups', () => {
    const state = fromJS({ previewAndTest: { testGroups: [] } });
    const expected = fromJS([]);
    const selector = makeSelectTestGroups();
    const result = selector(state);
    expect(result).toEqual(expected);
  });
  it('should return the expected object with default values when substate is empty for makeSelectMessageMetaConfigId', () => {
    const state = fromJS({ previewAndTest: { messageMetaConfigId: null } });
    const expected = null;
    const selector = makeSelectMessageMetaConfigId();
    const result = selector(state);
    expect(result).toEqual(expected);
  });
  it('should return the expected object with default values when substate is empty for makeSelectPrefilledValues', () => {
    const state = fromJS({ previewAndTest: { prefilledValues: {} } });
    const expected = {};
    const selector = makeSelectPrefilledValues();
    const result = selector(state);
    expect(result).toEqual(expected);
  });
  it('should return the expected object with default values when substate is empty for makeSelectTestMessageResponse', () => {
    const state = fromJS({ previewAndTest: { testMessageResponse: null } });
    const expected = null;
    const selector = makeSelectTestMessageResponse();
    const result = selector(state);
    expect(result).toEqual(expected);
  });
  it('should return the expected object with default values when substate is empty for makeSelectPreviewAndTest', () => {
    const state = fromJS({ previewAndTest: { previewData: null } });
    const expected = fromJS({ previewData: null });
    const selector = makeSelectPreviewAndTest();
    const result = selector(state);
    expect(result).toEqual(expected);
  });
  it('should return the expected object with default values when substate is empty for makeSelectCustomers', () => {
    const state = fromJS({ previewAndTest: { customers: [] } });
    const expected = fromJS([]);
    const selector = makeSelectCustomers();
    const result = selector(state);
    expect(result).toEqual(expected);
  });
  it('should return the expected object with default values when substate is empty for makeSelectExtractedTags', () => {
    const state = fromJS({ previewAndTest: { extractedTags: [] } });
    const expected = fromJS([]);
    const selector = makeSelectExtractedTags();
    const result = selector(state);
    expect(result).toEqual(expected);
  });
  it('should return the expected object with default values when substate is empty for makeSelectIsSearchingCustomer', () => {
    const state = fromJS({ previewAndTest: { isSearchingCustomer: false } });
    const expected = false;
    const selector = makeSelectIsSearchingCustomer();
    const result = selector(state);
    expect(result).toEqual(expected);
  });
  it('should return the expected object with default values when substate is empty for makeSelectIsExtractingTags', () => {
    const state = fromJS({ previewAndTest: { isExtractingTags: false } });
    const expected = false;
    const selector = makeSelectIsExtractingTags();
    const result = selector(state);
    expect(result).toEqual(expected);
  });
  it('should return the expected object with default values when substate is empty for makeSelectSearchError', () => {
    const state = fromJS({ previewAndTest: { searchError: null } });
    const expected = null;
    const selector = makeSelectSearchError();
    const result = selector(state);
    expect(result).toEqual(expected);
  });
  it('should return the expected object with default values when substate is empty for makeSelectHasSearched', () => {
    const state = fromJS({ previewAndTest: { hasSearched: false } });
    const expected = false;
    const selector = makeSelectHasSearched();
    const result = selector(state);
    expect(result).toEqual(expected);
  });
  it('should return the expected object with default values when substate is empty for makeSelectApiWarnings', () => {
    const state = fromJS({ previewAndTest: { apiWarnings: [] } });
    const expected = fromJS([]);
    const selector = makeSelectApiWarnings();
    const result = selector(state);
    expect(result).toEqual(expected);
  });
  it('should return the expected object with default values when substate is empty for makeSelectApiErrors', () => {
    const state = fromJS({ previewAndTest: { apiErrors: [] } });
    const expected = fromJS([]);
    const selector = makeSelectApiErrors();
    const result = selector(state);
    expect(result).toEqual(expected);
  });
  it('should return the expected object with default values when substate is empty for makeSelectPreviewData', () => {
    const state = fromJS({ previewAndTest: { previewData: null } });
    const expected = null;
    const selector = makeSelectPreviewData();
    const result = selector(state);
    expect(result).toEqual(expected);
  });
  it('should return the expected object with default values when substate is empty for makeSelectIsUpdatingPreview', () => {
    const state = fromJS({ previewAndTest: { isUpdatingPreview: false } });
    const expected = false;
    const selector = makeSelectIsUpdatingPreview();
    const result = selector(state);
    expect(result).toEqual(expected);
  });
  it('should return the expected object with default values when substate is empty for makeSelectIsSendingTestEmail', () => {
    const state = fromJS({ previewAndTest: { isSendingTestEmail: false } });
    const expected = false;
    const selector = makeSelectIsSendingTestEmail();
    const result = selector(state);
    expect(result).toEqual(expected);
  });
  it('should return the expected object with default values when substate is empty for makeSelectTags', () => {
    const state = fromJS({ previewAndTest: { tags: [] } });
    const expected = fromJS([]);
    const selector = makeSelectTags();
    const result = selector(state);
    expect(result).toEqual(expected);
  });
  it('should return the expected object with default values when substate is empty for makeSelectIsFetchingTestCustomers', () => {
    const state = fromJS({ previewAndTest: { isFetchingTestCustomers: false } });
    const expected = false;
    const selector = makeSelectIsFetchingTestCustomers();
    const result = selector(state);
    expect(result).toEqual(expected);
  });
  it('should return the expected object with default values when substate is empty for makeSelectIsFetchingTestGroups', () => {
    const state = fromJS({ previewAndTest: { isFetchingTestGroups: false } });
    const expected = false;
    const selector = makeSelectIsFetchingTestGroups();
    const result = selector(state);
    expect(result).toEqual(expected);
  });
  it('should return the expected object with default values when substate is empty for makeSelectIsCreatingMessageMeta', () => {
    const state = fromJS({ previewAndTest: { isCreatingMessageMeta: false } });
    const expected = false;
    const selector = makeSelectIsCreatingMessageMeta();
    const result = selector(state);
    expect(result).toEqual(expected);
  });
  it('should return the expected object with default values when substate is empty for makeSelectIsSendingTestMessage', () => {
    const state = fromJS({ previewAndTest: { isSendingTestMessage: false } });
    const expected = false;
    const selector = makeSelectIsSendingTestMessage();
    const result = selector(state);
    expect(result).toEqual(expected);
  });
});
