mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-29 15:12:58 +03:00
Updated tests for magiclink page
no issue - Add test for close button firing correct action(closePopup) on magic link page - Use common test utils setup
This commit is contained in:
parent
30a14023cf
commit
712ac5cd74
@ -1,15 +1,33 @@
|
||||
import React from 'react';
|
||||
import {render} from '@testing-library/react';
|
||||
import {render, fireEvent} from 'test-utils';
|
||||
import MagicLinkPage from './MagicLinkPage';
|
||||
|
||||
const setup = (overrides) => {
|
||||
const {mockOnActionFn, ...utils} = render(
|
||||
<MagicLinkPage />
|
||||
);
|
||||
const inboxText = utils.getByText(/check your inbox!/i);
|
||||
const closeBtn = utils.queryByRole('button', {name: 'Close'});
|
||||
return {
|
||||
inboxText,
|
||||
closeBtn,
|
||||
mockOnActionFn,
|
||||
...utils
|
||||
};
|
||||
};
|
||||
|
||||
describe('MagicLinkPage', () => {
|
||||
test('renders', () => {
|
||||
const {getByText} = render(
|
||||
<MagicLinkPage />
|
||||
);
|
||||
|
||||
const inboxText = getByText(/check your inbox!/i);
|
||||
const {inboxText, closeBtn} = setup();
|
||||
|
||||
expect(inboxText).toBeInTheDocument();
|
||||
expect(closeBtn).toBeInTheDocument();
|
||||
});
|
||||
|
||||
test('calls on action with close popup', () => {
|
||||
const {closeBtn, mockOnActionFn} = setup();
|
||||
|
||||
fireEvent.click(closeBtn);
|
||||
expect(mockOnActionFn).toHaveBeenCalledWith('closePopup');
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user