Skip to content

Commit

Permalink
YKI(Frontend): Add snapshot tests for EvaluationOrderStatusPage
Browse files Browse the repository at this point in the history
  • Loading branch information
pkoivisto committed Oct 10, 2023
1 parent aea186a commit 3dfe6df
Show file tree
Hide file tree
Showing 2 changed files with 213 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import * as reactRouterDom from 'react-router-dom';
import renderer from 'react-test-renderer';

import { initI18nForTests } from 'configs/i18n';
import { PaymentStatus } from 'enums/api';
import { EvaluationOrderStatusPage } from 'pages/EvaluationOrderStatusPage';
import { DefaultProviders } from 'tests/jest/utils/DefaultProviders';

jest.unmock('configs/i18n');
jest.requireActual('configs/i18n');

/*
jest.mock('react-router-dom', () => ({
useSearchParams: jest.fn(),
}));
*/

beforeAll(() => {
initI18nForTests();
});

const mockUseSearchParams = (params: URLSearchParams) => {
jest
.spyOn(reactRouterDom, 'useSearchParams')
.mockReturnValue([params, jest.fn()]);
};

describe('EvaluationOrderStatusPage', () => {
it('should render view correctly on successful payment', () => {
mockUseSearchParams(
new URLSearchParams({ id: '1', status: PaymentStatus.Success })
);
const tree = renderer
.create(
<DefaultProviders>
<EvaluationOrderStatusPage />
</DefaultProviders>
)
.toJSON();
expect(tree).toMatchSnapshot();
});
it('should render view correctly on cancelled payment', () => {
mockUseSearchParams(
new URLSearchParams({ id: '1', status: PaymentStatus.Cancel })
);
const tree = renderer
.create(
<DefaultProviders>
<EvaluationOrderStatusPage />
</DefaultProviders>
)
.toJSON();
expect(tree).toMatchSnapshot();
});
it('should render view correctly on payment error', () => {
mockUseSearchParams(
new URLSearchParams({ id: '1', status: PaymentStatus.Error })
);
const tree = renderer
.create(
<DefaultProviders>
<EvaluationOrderStatusPage />
</DefaultProviders>
)
.toJSON();
expect(tree).toMatchSnapshot();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`EvaluationOrderStatusPage should render view correctly on cancelled payment 1`] = `
<div
className="public-evaluation-order-status-page MuiBox-root css-0"
>
<div
className="public-evaluation-order-status-page__heading"
>
<h1
className="MuiTypography-root MuiTypography-h1 css-o2w69a-MuiTypography-root"
>
Maksu keskeytyi
</h1>
<div
className="header-separator MuiBox-root css-0"
/>
</div>
<div
className="MuiPaper-root MuiPaper-elevation MuiPaper-rounded MuiPaper-elevation3 public-evaluation-order-status-page__paper rows gapped css-3su884-MuiPaper-root"
>
<p
className="MuiTypography-root MuiTypography-body1 css-ahj2mt-MuiTypography-root"
>
Voit yrittää maksua uudestaan. Käsittelemme vain maksetut tarkistusarviointipyynnöt.
</p>
<a
className="MuiButtonBase-root MuiButton-root MuiButton-contained MuiButton-containedSecondary MuiButton-sizeMedium MuiButton-containedSizeMedium MuiButton-root MuiButton-contained MuiButton-containedSecondary MuiButton-sizeMedium MuiButton-containedSizeMedium fit-content-max-width css-zcbmsk-MuiButtonBase-root-MuiButton-root"
href="/yki/ilmoittautuminen"
onBlur={[Function]}
onContextMenu={[Function]}
onDragLeave={[Function]}
onFocus={[Function]}
onKeyDown={[Function]}
onKeyUp={[Function]}
onMouseDown={[Function]}
onMouseLeave={[Function]}
onMouseUp={[Function]}
onTouchEnd={[Function]}
onTouchMove={[Function]}
onTouchStart={[Function]}
tabIndex={0}
>
Takaisin aloitussivulle
<span
className="MuiTouchRipple-root css-8je8zh-MuiTouchRipple-root"
/>
</a>
</div>
</div>
`;

exports[`EvaluationOrderStatusPage should render view correctly on payment error 1`] = `
<div
className="public-evaluation-order-status-page MuiBox-root css-0"
>
<div
className="public-evaluation-order-status-page__heading"
>
<h1
className="MuiTypography-root MuiTypography-h1 css-o2w69a-MuiTypography-root"
>
Maksu epäonnistui
</h1>
<div
className="header-separator MuiBox-root css-0"
/>
</div>
<div
className="MuiPaper-root MuiPaper-elevation MuiPaper-rounded MuiPaper-elevation3 public-evaluation-order-status-page__paper rows gapped css-3su884-MuiPaper-root"
>
<p
className="MuiTypography-root MuiTypography-body1 css-ahj2mt-MuiTypography-root"
>
Tarkistusarviointimaksun maksaminen ei onnistunut. Yritä maksua uudestaan.
</p>
<a
className="MuiButtonBase-root MuiButton-root MuiButton-contained MuiButton-containedSecondary MuiButton-sizeMedium MuiButton-containedSizeMedium MuiButton-root MuiButton-contained MuiButton-containedSecondary MuiButton-sizeMedium MuiButton-containedSizeMedium fit-content-max-width css-zcbmsk-MuiButtonBase-root-MuiButton-root"
href="/yki/ilmoittautuminen"
onBlur={[Function]}
onContextMenu={[Function]}
onDragLeave={[Function]}
onFocus={[Function]}
onKeyDown={[Function]}
onKeyUp={[Function]}
onMouseDown={[Function]}
onMouseLeave={[Function]}
onMouseUp={[Function]}
onTouchEnd={[Function]}
onTouchMove={[Function]}
onTouchStart={[Function]}
tabIndex={0}
>
Takaisin aloitussivulle
</a>
</div>
</div>
`;

exports[`EvaluationOrderStatusPage should render view correctly on successful payment 1`] = `
<div
className="public-evaluation-order-status-page MuiBox-root css-0"
>
<div
className="public-evaluation-order-status-page__heading"
>
<h1
className="MuiTypography-root MuiTypography-h1 css-o2w69a-MuiTypography-root"
>
Olet lähettänyt tarkistusarviointipyynnön!
</h1>
<div
className="header-separator MuiBox-root css-0"
/>
</div>
<div
className="MuiPaper-root MuiPaper-elevation MuiPaper-rounded MuiPaper-elevation3 public-evaluation-order-status-page__paper rows gapped css-3su884-MuiPaper-root"
>
<p
className="MuiTypography-root MuiTypography-body1 css-ahj2mt-MuiTypography-root"
>
Sinulle on lähetetty vahvistus tarkistusarviointipyynnöstäsi sähköpostilla. Sähköpostissa on myös kuitti tarkistusarviointimaksustasi. Jos et ole saanut viestiä, tarkista roskapostikansiosi.
</p>
<a
className="MuiButtonBase-root MuiButton-root MuiButton-contained MuiButton-containedSecondary MuiButton-sizeMedium MuiButton-containedSizeMedium MuiButton-root MuiButton-contained MuiButton-containedSecondary MuiButton-sizeMedium MuiButton-containedSizeMedium fit-content-max-width css-zcbmsk-MuiButtonBase-root-MuiButton-root"
href="/yki/ilmoittautuminen"
onBlur={[Function]}
onContextMenu={[Function]}
onDragLeave={[Function]}
onFocus={[Function]}
onKeyDown={[Function]}
onKeyUp={[Function]}
onMouseDown={[Function]}
onMouseLeave={[Function]}
onMouseUp={[Function]}
onTouchEnd={[Function]}
onTouchMove={[Function]}
onTouchStart={[Function]}
tabIndex={0}
>
Takaisin aloitussivulle
</a>
</div>
</div>
`;

0 comments on commit 3dfe6df

Please sign in to comment.