1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-01 21:57:06 +01:00
metamask-extension/ui/pages/institutional/institutional-entity-done-page/institutional-entity-done-page.test.js
Albert Olivé f7aea9dc34
[MMI] Created institutional-entity-done-page component (#18096)
* Created institutional-entity-done-page component

* Added index file

* Added css file and Boxes

* Fixing prettier formatter

* Fixed prettier format

* Fixing prettier issues

* Fixed prettier

* Adding Text component

* Removed styles and added story

* Moving component to pages and improving styles

---------

Co-authored-by: António Regadas <apregadas@gmail.com>
2023-03-30 08:33:12 +02:00

60 lines
1.6 KiB
JavaScript

import React from 'react';
import { fireEvent, screen } from '@testing-library/react';
import { renderWithProvider } from '../../../../test/jest';
import configureStore from '../../../store/store';
import mockState from '../../../../test/data/mock-state.json';
import InstitutionalEntityDonePage from '.';
const props = {
history: {
push: jest.fn(),
},
mostRecentOverviewPage: 'test',
location: {
state: { imgSrc: 'test', title: 'title', description: 'description' },
},
};
const render = () => {
const store = configureStore({
...mockState,
metamask: {
provider: {
type: 'test',
},
},
history: {
mostRecentOverviewPage: 'test',
},
});
return renderWithProvider(<InstitutionalEntityDonePage {...props} />, store);
};
describe('InstitutionalEntityDonePage', () => {
beforeEach(() => {
render();
});
it('renders the component and shows the title', () => {
expect(screen.getByText(props.location.state.title)).toBeInTheDocument();
});
it('renders the component and shows the description', () => {
expect(
screen.getByText(props.location.state.description),
).toBeInTheDocument();
});
it('renders the component and sets the image correctly', () => {
const image = screen.getByAltText('Entity image');
expect(image.src).toContain(props.location.state.imgSrc);
});
it('calls history push on button click', () => {
const clickButton = screen.getByTestId('click-most-recent-overview-page');
fireEvent.click(clickButton);
expect(props.history.push).toHaveBeenCalledTimes(1);
});
});