A Metamask fork with Infura removed and default networks editable
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
ciphermask/ui/pages/unlock-page/unlock-page.test.js

65 lines
1.7 KiB

import React from 'react';
import configureMockStore from 'redux-mock-store';
import { fireEvent } from '@testing-library/react';
import thunk from 'redux-thunk';
import { renderWithProvider } from '../../../test/lib/render-helpers';
import UnlockPage from '.';
const mockMarkPasswordForgotten = jest.fn();
jest.mock('../../store/actions.js', () => ({
markPasswordForgotten: () => mockMarkPasswordForgotten,
}));
const mockElement = document.createElement('svg');
jest.mock('@metamask/logo', () => () => {
return {
container: mockElement,
setFollowMouse: jest.fn(),
stopAnimation: jest.fn(),
lookAt: jest.fn(),
};
});
describe('Unlock Page', () => {
const mockState = {
metamask: {},
};
const mockStore = configureMockStore([thunk])(mockState);
it('should match snapshot', () => {
const { container } = renderWithProvider(<UnlockPage />, mockStore);
expect(container).toMatchSnapshot();
});
it('changes password and submits', () => {
const props = {
onSubmit: jest.fn(),
};
const { queryByTestId } = renderWithProvider(
<UnlockPage {...props} />,
mockStore,
);
const passwordField = queryByTestId('unlock-password');
const loginButton = queryByTestId('unlock-submit');
fireEvent.change(passwordField, { target: { value: 'a-password' } });
expect(passwordField).toHaveAttribute('value', 'a-password');
fireEvent.click(loginButton);
expect(props.onSubmit).toHaveBeenCalled();
});
it('clicks imports seed button', () => {
const { getByText } = renderWithProvider(<UnlockPage />, mockStore);
fireEvent.click(getByText('Forgot password?'));
expect(mockMarkPasswordForgotten).toHaveBeenCalled();
});
});