-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
YKI(Frontend): Add snapshot tests for EvaluationOrderStatusPage
- Loading branch information
Showing
2 changed files
with
213 additions
and
0 deletions.
There are no files selected for viewing
68 changes: 68 additions & 0 deletions
68
...nd/packages/yki/src/tests/jest/components/reassessment/EvaluationOrderStatusPage.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
}); | ||
}); |
145 changes: 145 additions & 0 deletions
145
.../tests/jest/components/reassessment/__snapshots__/EvaluationOrderStatusPage.test.tsx.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
`; |