import { fromJS } from 'immutable';

import languageProviderReducer from '../reducer';
import {
  CHANGE_LOCALE,
  GET_LOCIZ_MESSAGE_REQUEST,
} from '../constants';

describe('languageProviderReducer', () => {
  it.concurrent('returns the initial state', () => {
    expect(languageProviderReducer(undefined, {})).toEqual(fromJS({
      locale: 'en',
      languageLocale: 'en',
      messages: {},
      localeLoading: false,
    }));
  });

  it.concurrent('changes the locale', () => {
    expect(languageProviderReducer(undefined, { type: CHANGE_LOCALE, locale: 'en', languageLocale: 'en' }).toJS()).toEqual({
      locale: "en",
      languageLocale: "en",
      localeLoading: false,
      messages: {},
    });
  });

  it.concurrent('make locize message request', () => {
    expect(languageProviderReducer(undefined, { type: GET_LOCIZ_MESSAGE_REQUEST, locale: 'en', languageLocale: 'en' }).toJS()).toEqual({
      locale: "en",
      languageLocale: 'en',
      localeLoading: true,
      messages: {},
    });
  });
});
