1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00
metamask-extension/ui/pages/onboarding-flow/onboarding-app-header/onboarding-app-header.test.js

42 lines
1.2 KiB
JavaScript

import { fireEvent } from '@testing-library/react';
import React from 'react';
import configureMockStore from 'redux-mock-store';
import thunk from 'redux-thunk';
import { renderWithProvider } from '../../../../test/lib/render-helpers';
import OnboardingAppHeader from './onboarding-app-header';
const mockUpdateCurrentLocale = jest.fn();
jest.mock('../../../../app/_locales/index.json', () => {
return [{ code: 'en', name: 'English' }];
});
jest.mock('../../../store/actions.ts', () => ({
updateCurrentLocale: () => mockUpdateCurrentLocale,
}));
describe('OnboardingAppHeader', () => {
const mockState = {
localeMessages: {
currentLocale: 'en',
},
};
const store = configureMockStore([thunk])(mockState);
it('should match snapshot', () => {
const { container } = renderWithProvider(<OnboardingAppHeader />, store);
expect(container).toMatchSnapshot();
});
it('should call updateCurrentLocale action', () => {
const { getByRole } = renderWithProvider(<OnboardingAppHeader />, store);
const selectCombobox = getByRole('combobox');
fireEvent.change(selectCombobox);
expect(mockUpdateCurrentLocale).toHaveBeenCalled();
});
});