vitest: jest --> vi
This commit is contained in:
parent
afaac6eed2
commit
5ab87616c1
|
@ -20,7 +20,7 @@ function renderApp() {
|
||||||
}
|
}
|
||||||
|
|
||||||
beforeAll(() => {
|
beforeAll(() => {
|
||||||
jest.spyOn(console, 'error').mockImplementation(() => {});
|
vi.spyOn(console, 'error').mockImplementation(() => {});
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
|
|
|
@ -41,7 +41,7 @@ describe('uploadCompose()', () => {
|
||||||
|
|
||||||
it('creates an alert if exceeds max size', async() => {
|
it('creates an alert if exceeds max size', async() => {
|
||||||
const mockIntl = {
|
const mockIntl = {
|
||||||
formatMessage: jest.fn().mockReturnValue('Image exceeds the current file size limit (10 Bytes)'),
|
formatMessage: vi.fn().mockReturnValue('Image exceeds the current file size limit (10 Bytes)'),
|
||||||
} as unknown as IntlShape;
|
} as unknown as IntlShape;
|
||||||
|
|
||||||
const expectedActions = [
|
const expectedActions = [
|
||||||
|
@ -87,7 +87,7 @@ describe('uploadCompose()', () => {
|
||||||
|
|
||||||
it('creates an alert if exceeds max size', async() => {
|
it('creates an alert if exceeds max size', async() => {
|
||||||
const mockIntl = {
|
const mockIntl = {
|
||||||
formatMessage: jest.fn().mockReturnValue('Video exceeds the current file size limit (10 Bytes)'),
|
formatMessage: vi.fn().mockReturnValue('Video exceeds the current file size limit (10 Bytes)'),
|
||||||
} as unknown as IntlShape;
|
} as unknown as IntlShape;
|
||||||
|
|
||||||
const expectedActions = [
|
const expectedActions = [
|
||||||
|
|
|
@ -7,10 +7,10 @@ import { AuthUserRecord, ReducerRecord } from 'soapbox/reducers/auth';
|
||||||
|
|
||||||
import { fetchMe, patchMe } from '../me';
|
import { fetchMe, patchMe } from '../me';
|
||||||
|
|
||||||
jest.mock('../../storage/kv-store', () => ({
|
vi.mock('../../storage/kv-store', () => ({
|
||||||
__esModule: true,
|
__esModule: true,
|
||||||
default: {
|
default: {
|
||||||
getItemOrError: jest.fn().mockReturnValue(Promise.resolve({})),
|
getItemOrError: vi.fn().mockReturnValue(Promise.resolve({})),
|
||||||
},
|
},
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
|
@ -10,11 +10,11 @@ describe('checkOnboarding()', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
mockGetItem = jest.fn().mockReturnValue(null);
|
mockGetItem = vi.fn().mockReturnValue(null);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('does nothing if localStorage item is not set', async() => {
|
it('does nothing if localStorage item is not set', async() => {
|
||||||
mockGetItem = jest.fn().mockReturnValue(null);
|
mockGetItem = vi.fn().mockReturnValue(null);
|
||||||
|
|
||||||
const state = rootState.setIn(['onboarding', 'needsOnboarding'], false);
|
const state = rootState.setIn(['onboarding', 'needsOnboarding'], false);
|
||||||
const store = mockStore(state);
|
const store = mockStore(state);
|
||||||
|
@ -27,7 +27,7 @@ describe('checkOnboarding()', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('does nothing if localStorage item is invalid', async() => {
|
it('does nothing if localStorage item is invalid', async() => {
|
||||||
mockGetItem = jest.fn().mockReturnValue('invalid');
|
mockGetItem = vi.fn().mockReturnValue('invalid');
|
||||||
|
|
||||||
const state = rootState.setIn(['onboarding', 'needsOnboarding'], false);
|
const state = rootState.setIn(['onboarding', 'needsOnboarding'], false);
|
||||||
const store = mockStore(state);
|
const store = mockStore(state);
|
||||||
|
@ -40,7 +40,7 @@ describe('checkOnboarding()', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('dispatches the correct action', async() => {
|
it('dispatches the correct action', async() => {
|
||||||
mockGetItem = jest.fn().mockReturnValue('1');
|
mockGetItem = vi.fn().mockReturnValue('1');
|
||||||
|
|
||||||
const state = rootState.setIn(['onboarding', 'needsOnboarding'], false);
|
const state = rootState.setIn(['onboarding', 'needsOnboarding'], false);
|
||||||
const store = mockStore(state);
|
const store = mockStore(state);
|
||||||
|
@ -61,7 +61,7 @@ describe('startOnboarding()', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
mockSetItem = jest.fn();
|
mockSetItem = vi.fn();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('dispatches the correct action', async() => {
|
it('dispatches the correct action', async() => {
|
||||||
|
@ -84,7 +84,7 @@ describe('endOnboarding()', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
mockRemoveItem = jest.fn();
|
mockRemoveItem = vi.fn();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('dispatches the correct action', async() => {
|
it('dispatches the correct action', async() => {
|
||||||
|
|
|
@ -27,7 +27,7 @@ describe('<Button />', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('handles click events using the given handler', () => {
|
it('handles click events using the given handler', () => {
|
||||||
const handler = jest.fn();
|
const handler = vi.fn();
|
||||||
render(<Button onClick={handler} />);
|
render(<Button onClick={handler} />);
|
||||||
|
|
||||||
fireEvent.click(screen.getByRole('button'));
|
fireEvent.click(screen.getByRole('button'));
|
||||||
|
@ -35,7 +35,7 @@ describe('<Button />', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('does not handle click events if props.disabled given', () => {
|
it('does not handle click events if props.disabled given', () => {
|
||||||
const handler = jest.fn();
|
const handler = vi.fn();
|
||||||
render(<Button onClick={handler} disabled />);
|
render(<Button onClick={handler} disabled />);
|
||||||
|
|
||||||
fireEvent.click(screen.getByRole('button'));
|
fireEvent.click(screen.getByRole('button'));
|
||||||
|
|
|
@ -6,7 +6,7 @@ import Datepicker from '../datepicker';
|
||||||
|
|
||||||
describe('<Datepicker />', () => {
|
describe('<Datepicker />', () => {
|
||||||
it('defaults to the current date', () => {
|
it('defaults to the current date', () => {
|
||||||
const handler = jest.fn();
|
const handler = vi.fn();
|
||||||
render(<Datepicker onChange={handler} />);
|
render(<Datepicker onChange={handler} />);
|
||||||
const today = new Date();
|
const today = new Date();
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ describe('<Datepicker />', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('changes number of days based on selected month and year', async() => {
|
it('changes number of days based on selected month and year', async() => {
|
||||||
const handler = jest.fn();
|
const handler = vi.fn();
|
||||||
render(<Datepicker onChange={handler} />);
|
render(<Datepicker onChange={handler} />);
|
||||||
|
|
||||||
await userEvent.selectOptions(
|
await userEvent.selectOptions(
|
||||||
|
@ -43,7 +43,7 @@ describe('<Datepicker />', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('ranges from the current year to 120 years ago', () => {
|
it('ranges from the current year to 120 years ago', () => {
|
||||||
const handler = jest.fn();
|
const handler = vi.fn();
|
||||||
render(<Datepicker onChange={handler} />);
|
render(<Datepicker onChange={handler} />);
|
||||||
const today = new Date();
|
const today = new Date();
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ describe('<Datepicker />', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('calls the onChange function when the inputs change', async() => {
|
it('calls the onChange function when the inputs change', async() => {
|
||||||
const handler = jest.fn();
|
const handler = vi.fn();
|
||||||
render(<Datepicker onChange={handler} />);
|
render(<Datepicker onChange={handler} />);
|
||||||
const today = new Date();
|
const today = new Date();
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ import Form from '../form';
|
||||||
|
|
||||||
describe('<Form />', () => {
|
describe('<Form />', () => {
|
||||||
it('renders children', () => {
|
it('renders children', () => {
|
||||||
const onSubmitMock = jest.fn();
|
const onSubmitMock = vi.fn();
|
||||||
render(
|
render(
|
||||||
<Form onSubmit={onSubmitMock}>children</Form>,
|
<Form onSubmit={onSubmitMock}>children</Form>,
|
||||||
);
|
);
|
||||||
|
@ -14,7 +14,7 @@ describe('<Form />', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('handles onSubmit prop', () => {
|
it('handles onSubmit prop', () => {
|
||||||
const onSubmitMock = jest.fn();
|
const onSubmitMock = vi.fn();
|
||||||
render(
|
render(
|
||||||
<Form onSubmit={onSubmitMock}>children</Form>,
|
<Form onSubmit={onSubmitMock}>children</Form>,
|
||||||
);
|
);
|
||||||
|
|
|
@ -29,7 +29,7 @@ describe('<Modal />', () => {
|
||||||
|
|
||||||
describe('onClose prop', () => {
|
describe('onClose prop', () => {
|
||||||
it('renders the Icon to close the modal', async() => {
|
it('renders the Icon to close the modal', async() => {
|
||||||
const mockFn = jest.fn();
|
const mockFn = vi.fn();
|
||||||
const user = userEvent.setup();
|
const user = userEvent.setup();
|
||||||
|
|
||||||
render(<Modal title='Modal title' onClose={mockFn} />);
|
render(<Modal title='Modal title' onClose={mockFn} />);
|
||||||
|
@ -48,7 +48,7 @@ describe('<Modal />', () => {
|
||||||
|
|
||||||
describe('confirmationAction prop', () => {
|
describe('confirmationAction prop', () => {
|
||||||
it('renders the confirmation button', async() => {
|
it('renders the confirmation button', async() => {
|
||||||
const mockFn = jest.fn();
|
const mockFn = vi.fn();
|
||||||
const user = userEvent.setup();
|
const user = userEvent.setup();
|
||||||
|
|
||||||
render(
|
render(
|
||||||
|
@ -71,8 +71,8 @@ describe('<Modal />', () => {
|
||||||
|
|
||||||
describe('with secondaryAction', () => {
|
describe('with secondaryAction', () => {
|
||||||
it('renders the secondary button', async() => {
|
it('renders the secondary button', async() => {
|
||||||
const confirmationAction = jest.fn();
|
const confirmationAction = vi.fn();
|
||||||
const secondaryAction = jest.fn();
|
const secondaryAction = vi.fn();
|
||||||
const user = userEvent.setup();
|
const user = userEvent.setup();
|
||||||
|
|
||||||
render(
|
render(
|
||||||
|
@ -104,8 +104,8 @@ describe('<Modal />', () => {
|
||||||
|
|
||||||
describe('with cancelAction', () => {
|
describe('with cancelAction', () => {
|
||||||
it('renders the cancel button', async() => {
|
it('renders the cancel button', async() => {
|
||||||
const confirmationAction = jest.fn();
|
const confirmationAction = vi.fn();
|
||||||
const cancelAction = jest.fn();
|
const cancelAction = vi.fn();
|
||||||
const user = userEvent.setup();
|
const user = userEvent.setup();
|
||||||
|
|
||||||
render(
|
render(
|
||||||
|
|
|
@ -7,7 +7,7 @@ import LoginForm from '../login-form';
|
||||||
|
|
||||||
describe('<LoginForm />', () => {
|
describe('<LoginForm />', () => {
|
||||||
it('renders for Pleroma', () => {
|
it('renders for Pleroma', () => {
|
||||||
const mockFn = jest.fn();
|
const mockFn = vi.fn();
|
||||||
const store = {
|
const store = {
|
||||||
instance: normalizeInstance({
|
instance: normalizeInstance({
|
||||||
version: '2.7.2 (compatible; Pleroma 2.3.0)',
|
version: '2.7.2 (compatible; Pleroma 2.3.0)',
|
||||||
|
@ -20,7 +20,7 @@ describe('<LoginForm />', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('renders for Mastodon', () => {
|
it('renders for Mastodon', () => {
|
||||||
const mockFn = jest.fn();
|
const mockFn = vi.fn();
|
||||||
const store = {
|
const store = {
|
||||||
instance: normalizeInstance({
|
instance: normalizeInstance({
|
||||||
version: '3.0.0',
|
version: '3.0.0',
|
||||||
|
@ -33,7 +33,7 @@ describe('<LoginForm />', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('responds to the handleSubmit prop', () => {
|
it('responds to the handleSubmit prop', () => {
|
||||||
const mockFn = jest.fn();
|
const mockFn = vi.fn();
|
||||||
render(<LoginForm handleSubmit={mockFn} isLoading={false} />);
|
render(<LoginForm handleSubmit={mockFn} isLoading={false} />);
|
||||||
fireEvent.submit(screen.getByTestId(/button/i));
|
fireEvent.submit(screen.getByTestId(/button/i));
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ const chat: any = {
|
||||||
|
|
||||||
describe('<ChatListItem />', () => {
|
describe('<ChatListItem />', () => {
|
||||||
it('renders correctly', () => {
|
it('renders correctly', () => {
|
||||||
render(<ChatListItem chat={chat as IChat} onClick={jest.fn()} />);
|
render(<ChatListItem chat={chat as IChat} onClick={vi.fn()} />);
|
||||||
|
|
||||||
expect(screen.getByTestId('chat-list-item')).toBeInTheDocument();
|
expect(screen.getByTestId('chat-list-item')).toBeInTheDocument();
|
||||||
expect(screen.getByTestId('chat-list-item')).toHaveTextContent(chat.account.display_name);
|
expect(screen.getByTestId('chat-list-item')).toHaveTextContent(chat.account.display_name);
|
||||||
|
@ -38,28 +38,28 @@ describe('<ChatListItem />', () => {
|
||||||
|
|
||||||
describe('last message content', () => {
|
describe('last message content', () => {
|
||||||
it('renders the last message', () => {
|
it('renders the last message', () => {
|
||||||
render(<ChatListItem chat={chat as IChat} onClick={jest.fn()} />);
|
render(<ChatListItem chat={chat as IChat} onClick={vi.fn()} />);
|
||||||
|
|
||||||
expect(screen.getByTestId('chat-last-message')).toBeInTheDocument();
|
expect(screen.getByTestId('chat-last-message')).toBeInTheDocument();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('does not render the last message', () => {
|
it('does not render the last message', () => {
|
||||||
const changedChat = { ...chat, last_message: null };
|
const changedChat = { ...chat, last_message: null };
|
||||||
render(<ChatListItem chat={changedChat as IChat} onClick={jest.fn()} />);
|
render(<ChatListItem chat={changedChat as IChat} onClick={vi.fn()} />);
|
||||||
|
|
||||||
expect(screen.queryAllByTestId('chat-last-message')).toHaveLength(0);
|
expect(screen.queryAllByTestId('chat-last-message')).toHaveLength(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('unread', () => {
|
describe('unread', () => {
|
||||||
it('renders the unread dot', () => {
|
it('renders the unread dot', () => {
|
||||||
render(<ChatListItem chat={chat as IChat} onClick={jest.fn()} />);
|
render(<ChatListItem chat={chat as IChat} onClick={vi.fn()} />);
|
||||||
|
|
||||||
expect(screen.getByTestId('chat-unread-indicator')).toBeInTheDocument();
|
expect(screen.getByTestId('chat-unread-indicator')).toBeInTheDocument();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('does not render the unread dot', () => {
|
it('does not render the unread dot', () => {
|
||||||
const changedChat = { ...chat, last_message: { ...chat.last_message, unread: false } };
|
const changedChat = { ...chat, last_message: { ...chat.last_message, unread: false } };
|
||||||
render(<ChatListItem chat={changedChat as IChat} onClick={jest.fn()} />);
|
render(<ChatListItem chat={changedChat as IChat} onClick={vi.fn()} />);
|
||||||
|
|
||||||
expect(screen.queryAllByTestId('chat-unread-indicator')).toHaveLength(0);
|
expect(screen.queryAllByTestId('chat-unread-indicator')).toHaveLength(0);
|
||||||
});
|
});
|
||||||
|
|
|
@ -15,8 +15,8 @@ describe('<ChatMessageReaction />', () => {
|
||||||
render(
|
render(
|
||||||
<ChatMessageReaction
|
<ChatMessageReaction
|
||||||
emojiReaction={emojiReaction}
|
emojiReaction={emojiReaction}
|
||||||
onAddReaction={jest.fn()}
|
onAddReaction={vi.fn()}
|
||||||
onRemoveReaction={jest.fn()}
|
onRemoveReaction={vi.fn()}
|
||||||
/>,
|
/>,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -25,8 +25,8 @@ describe('<ChatMessageReaction />', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('triggers the "onAddReaction" function', async () => {
|
it('triggers the "onAddReaction" function', async () => {
|
||||||
const onAddFn = jest.fn();
|
const onAddFn = vi.fn();
|
||||||
const onRemoveFn = jest.fn();
|
const onRemoveFn = vi.fn();
|
||||||
const user = userEvent.setup();
|
const user = userEvent.setup();
|
||||||
|
|
||||||
render(
|
render(
|
||||||
|
@ -48,8 +48,8 @@ describe('<ChatMessageReaction />', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('triggers the "onRemoveReaction" function', async () => {
|
it('triggers the "onRemoveReaction" function', async () => {
|
||||||
const onAddFn = jest.fn();
|
const onAddFn = vi.fn();
|
||||||
const onRemoveFn = jest.fn();
|
const onRemoveFn = vi.fn();
|
||||||
const user = userEvent.setup();
|
const user = userEvent.setup();
|
||||||
|
|
||||||
render(
|
render(
|
||||||
|
|
|
@ -6,7 +6,7 @@ import ChatPaneHeader from '../chat-widget/chat-pane-header';
|
||||||
|
|
||||||
describe('<ChatPaneHeader />', () => {
|
describe('<ChatPaneHeader />', () => {
|
||||||
it('handles the onToggle prop', async () => {
|
it('handles the onToggle prop', async () => {
|
||||||
const mockFn = jest.fn();
|
const mockFn = vi.fn();
|
||||||
render(<ChatPaneHeader title='title' onToggle={mockFn} isOpen />);
|
render(<ChatPaneHeader title='title' onToggle={mockFn} isOpen />);
|
||||||
|
|
||||||
await userEvent.click(screen.getByTestId('icon-button'));
|
await userEvent.click(screen.getByTestId('icon-button'));
|
||||||
|
@ -17,7 +17,7 @@ describe('<ChatPaneHeader />', () => {
|
||||||
describe('when it is a string', () => {
|
describe('when it is a string', () => {
|
||||||
it('renders the title', () => {
|
it('renders the title', () => {
|
||||||
const title = 'Messages';
|
const title = 'Messages';
|
||||||
render(<ChatPaneHeader title={title} onToggle={jest.fn()} isOpen />);
|
render(<ChatPaneHeader title={title} onToggle={vi.fn()} isOpen />);
|
||||||
|
|
||||||
expect(screen.getByTestId('title')).toHaveTextContent(title);
|
expect(screen.getByTestId('title')).toHaveTextContent(title);
|
||||||
});
|
});
|
||||||
|
@ -28,7 +28,7 @@ describe('<ChatPaneHeader />', () => {
|
||||||
const title = (
|
const title = (
|
||||||
<div><p>hello world</p></div>
|
<div><p>hello world</p></div>
|
||||||
);
|
);
|
||||||
render(<ChatPaneHeader title={title} onToggle={jest.fn()} isOpen />);
|
render(<ChatPaneHeader title={title} onToggle={vi.fn()} isOpen />);
|
||||||
|
|
||||||
expect(screen.getByTestId('title')).toHaveTextContent('hello world');
|
expect(screen.getByTestId('title')).toHaveTextContent('hello world');
|
||||||
});
|
});
|
||||||
|
@ -39,7 +39,7 @@ describe('<ChatPaneHeader />', () => {
|
||||||
describe('when present', () => {
|
describe('when present', () => {
|
||||||
it('renders the unread count', () => {
|
it('renders the unread count', () => {
|
||||||
const count = 14;
|
const count = 14;
|
||||||
render(<ChatPaneHeader title='title' onToggle={jest.fn()} isOpen unreadCount={count} />);
|
render(<ChatPaneHeader title='title' onToggle={vi.fn()} isOpen unreadCount={count} />);
|
||||||
|
|
||||||
expect(screen.getByTestId('unread-count')).toHaveTextContent(String(count));
|
expect(screen.getByTestId('unread-count')).toHaveTextContent(String(count));
|
||||||
});
|
});
|
||||||
|
@ -48,7 +48,7 @@ describe('<ChatPaneHeader />', () => {
|
||||||
describe('when 0', () => {
|
describe('when 0', () => {
|
||||||
it('does not render the unread count', () => {
|
it('does not render the unread count', () => {
|
||||||
const count = 0;
|
const count = 0;
|
||||||
render(<ChatPaneHeader title='title' onToggle={jest.fn()} isOpen unreadCount={count} />);
|
render(<ChatPaneHeader title='title' onToggle={vi.fn()} isOpen unreadCount={count} />);
|
||||||
|
|
||||||
expect(screen.queryAllByTestId('unread-count')).toHaveLength(0);
|
expect(screen.queryAllByTestId('unread-count')).toHaveLength(0);
|
||||||
});
|
});
|
||||||
|
@ -56,7 +56,7 @@ describe('<ChatPaneHeader />', () => {
|
||||||
|
|
||||||
describe('when unprovided', () => {
|
describe('when unprovided', () => {
|
||||||
it('does not render the unread count', () => {
|
it('does not render the unread count', () => {
|
||||||
render(<ChatPaneHeader title='title' onToggle={jest.fn()} isOpen />);
|
render(<ChatPaneHeader title='title' onToggle={vi.fn()} isOpen />);
|
||||||
|
|
||||||
expect(screen.queryAllByTestId('unread-count')).toHaveLength(0);
|
expect(screen.queryAllByTestId('unread-count')).toHaveLength(0);
|
||||||
});
|
});
|
||||||
|
@ -65,11 +65,11 @@ describe('<ChatPaneHeader />', () => {
|
||||||
|
|
||||||
describe('secondaryAction prop', () => {
|
describe('secondaryAction prop', () => {
|
||||||
it('handles the secondaryAction callback', async () => {
|
it('handles the secondaryAction callback', async () => {
|
||||||
const mockFn = jest.fn();
|
const mockFn = vi.fn();
|
||||||
render(
|
render(
|
||||||
<ChatPaneHeader
|
<ChatPaneHeader
|
||||||
title='title'
|
title='title'
|
||||||
onToggle={jest.fn()}
|
onToggle={vi.fn()}
|
||||||
isOpen
|
isOpen
|
||||||
secondaryAction={mockFn}
|
secondaryAction={mockFn}
|
||||||
secondaryActionIcon='icon.svg'
|
secondaryActionIcon='icon.svg'
|
||||||
|
|
|
@ -6,7 +6,7 @@ import DurationSelector from '../duration-selector';
|
||||||
|
|
||||||
describe('<DurationSelector />', () => {
|
describe('<DurationSelector />', () => {
|
||||||
it('defaults to 2 days', () => {
|
it('defaults to 2 days', () => {
|
||||||
const handler = jest.fn();
|
const handler = vi.fn();
|
||||||
render(<DurationSelector onDurationChange={handler} />);
|
render(<DurationSelector onDurationChange={handler} />);
|
||||||
|
|
||||||
expect(screen.getByTestId('duration-selector-days')).toHaveValue('2');
|
expect(screen.getByTestId('duration-selector-days')).toHaveValue('2');
|
||||||
|
@ -16,7 +16,7 @@ describe('<DurationSelector />', () => {
|
||||||
|
|
||||||
describe('when changing the day', () => {
|
describe('when changing the day', () => {
|
||||||
it('calls the "onDurationChange" callback', async() => {
|
it('calls the "onDurationChange" callback', async() => {
|
||||||
const handler = jest.fn();
|
const handler = vi.fn();
|
||||||
render(<DurationSelector onDurationChange={handler} />);
|
render(<DurationSelector onDurationChange={handler} />);
|
||||||
|
|
||||||
await userEvent.selectOptions(
|
await userEvent.selectOptions(
|
||||||
|
@ -29,7 +29,7 @@ describe('<DurationSelector />', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should disable the hour/minute select if 7 days selected', async() => {
|
it('should disable the hour/minute select if 7 days selected', async() => {
|
||||||
const handler = jest.fn();
|
const handler = vi.fn();
|
||||||
render(<DurationSelector onDurationChange={handler} />);
|
render(<DurationSelector onDurationChange={handler} />);
|
||||||
|
|
||||||
expect(screen.getByTestId('duration-selector-hours')).not.toBeDisabled();
|
expect(screen.getByTestId('duration-selector-hours')).not.toBeDisabled();
|
||||||
|
@ -47,7 +47,7 @@ describe('<DurationSelector />', () => {
|
||||||
|
|
||||||
describe('when changing the hour', () => {
|
describe('when changing the hour', () => {
|
||||||
it('calls the "onDurationChange" callback', async() => {
|
it('calls the "onDurationChange" callback', async() => {
|
||||||
const handler = jest.fn();
|
const handler = vi.fn();
|
||||||
render(<DurationSelector onDurationChange={handler} />);
|
render(<DurationSelector onDurationChange={handler} />);
|
||||||
|
|
||||||
await userEvent.selectOptions(
|
await userEvent.selectOptions(
|
||||||
|
@ -62,7 +62,7 @@ describe('<DurationSelector />', () => {
|
||||||
|
|
||||||
describe('when changing the minute', () => {
|
describe('when changing the minute', () => {
|
||||||
it('calls the "onDurationChange" callback', async() => {
|
it('calls the "onDurationChange" callback', async() => {
|
||||||
const handler = jest.fn();
|
const handler = vi.fn();
|
||||||
render(<DurationSelector onDurationChange={handler} />);
|
render(<DurationSelector onDurationChange={handler} />);
|
||||||
|
|
||||||
await userEvent.selectOptions(
|
await userEvent.selectOptions(
|
||||||
|
|
|
@ -7,7 +7,7 @@ import { __stub } from 'soapbox/api';
|
||||||
import { render, screen, waitFor } from '../../../jest/test-helpers';
|
import { render, screen, waitFor } from '../../../jest/test-helpers';
|
||||||
import FeedCarousel from '../feed-carousel';
|
import FeedCarousel from '../feed-carousel';
|
||||||
|
|
||||||
jest.mock('../../../hooks/useDimensions', () => ({
|
vi.mock('../../../hooks/useDimensions', () => ({
|
||||||
useDimensions: () => [{ scrollWidth: 190 }, null, { width: 300 }],
|
useDimensions: () => [{ scrollWidth: 190 }, null, { width: 300 }],
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
@ -129,7 +129,7 @@ describe('<FeedCarousel />', () => {
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
Element.prototype.getBoundingClientRect = jest.fn(() => {
|
Element.prototype.getBoundingClientRect = vi.fn(() => {
|
||||||
return {
|
return {
|
||||||
width: 200,
|
width: 200,
|
||||||
height: 120,
|
height: 120,
|
||||||
|
|
|
@ -7,7 +7,7 @@ import { normalizeInstance } from 'soapbox/normalizers';
|
||||||
|
|
||||||
import Discover from '../discover';
|
import Discover from '../discover';
|
||||||
|
|
||||||
jest.mock('../../../hooks/useDimensions', () => ({
|
vi.mock('../../../hooks/useDimensions', () => ({
|
||||||
useDimensions: () => [{ scrollWidth: 190 }, null, { width: 300 }],
|
useDimensions: () => [{ scrollWidth: 190 }, null, { width: 300 }],
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ import LayoutButtons, { GroupLayout } from '../layout-buttons';
|
||||||
describe('<LayoutButtons', () => {
|
describe('<LayoutButtons', () => {
|
||||||
describe('when LIST view', () => {
|
describe('when LIST view', () => {
|
||||||
it('should render correctly', async () => {
|
it('should render correctly', async () => {
|
||||||
const onSelectFn = jest.fn();
|
const onSelectFn = vi.fn();
|
||||||
const user = userEvent.setup();
|
const user = userEvent.setup();
|
||||||
|
|
||||||
render(<LayoutButtons layout={GroupLayout.LIST} onSelect={onSelectFn} />);
|
render(<LayoutButtons layout={GroupLayout.LIST} onSelect={onSelectFn} />);
|
||||||
|
@ -23,7 +23,7 @@ describe('<LayoutButtons', () => {
|
||||||
|
|
||||||
describe('when GRID view', () => {
|
describe('when GRID view', () => {
|
||||||
it('should render correctly', async () => {
|
it('should render correctly', async () => {
|
||||||
const onSelectFn = jest.fn();
|
const onSelectFn = vi.fn();
|
||||||
const user = userEvent.setup();
|
const user = userEvent.setup();
|
||||||
|
|
||||||
render(<LayoutButtons layout={GroupLayout.GRID} onSelect={onSelectFn} />);
|
render(<LayoutButtons layout={GroupLayout.GRID} onSelect={onSelectFn} />);
|
||||||
|
|
|
@ -48,7 +48,7 @@ test.skip('skip', () => {});
|
||||||
// });
|
// });
|
||||||
|
|
||||||
// it('should render the recent searches', async () => {
|
// it('should render the recent searches', async () => {
|
||||||
// renderApp(<RecentSearches onSelect={jest.fn()} />);
|
// renderApp(<RecentSearches onSelect={vi.fn()} />);
|
||||||
|
|
||||||
// await waitFor(() => {
|
// await waitFor(() => {
|
||||||
// expect(screen.getByTestId('recent-search')).toBeInTheDocument();
|
// expect(screen.getByTestId('recent-search')).toBeInTheDocument();
|
||||||
|
@ -56,7 +56,7 @@ test.skip('skip', () => {});
|
||||||
// });
|
// });
|
||||||
|
|
||||||
// it('should support clearing recent searches', async () => {
|
// it('should support clearing recent searches', async () => {
|
||||||
// renderApp(<RecentSearches onSelect={jest.fn()} />);
|
// renderApp(<RecentSearches onSelect={vi.fn()} />);
|
||||||
|
|
||||||
// expect(groupSearchHistory.get(userId)).toHaveLength(1);
|
// expect(groupSearchHistory.get(userId)).toHaveLength(1);
|
||||||
// await userEvent.click(screen.getByTestId('clear-recent-searches'));
|
// await userEvent.click(screen.getByTestId('clear-recent-searches'));
|
||||||
|
@ -64,7 +64,7 @@ test.skip('skip', () => {});
|
||||||
// });
|
// });
|
||||||
|
|
||||||
// it('should support click events on the results', async () => {
|
// it('should support click events on the results', async () => {
|
||||||
// const handler = jest.fn();
|
// const handler = vi.fn();
|
||||||
// renderApp(<RecentSearches onSelect={handler} />);
|
// renderApp(<RecentSearches onSelect={handler} />);
|
||||||
// expect(handler.mock.calls.length).toEqual(0);
|
// expect(handler.mock.calls.length).toEqual(0);
|
||||||
// await userEvent.click(screen.getByTestId('recent-search-result'));
|
// await userEvent.click(screen.getByTestId('recent-search-result'));
|
||||||
|
@ -74,7 +74,7 @@ test.skip('skip', () => {});
|
||||||
|
|
||||||
// describe('without recent searches', () => {
|
// describe('without recent searches', () => {
|
||||||
// it('should render the blankslate', async () => {
|
// it('should render the blankslate', async () => {
|
||||||
// renderApp(<RecentSearches onSelect={jest.fn()} />);
|
// renderApp(<RecentSearches onSelect={vi.fn()} />);
|
||||||
|
|
||||||
// expect(screen.getByTestId('recent-searches-blankslate')).toBeInTheDocument();
|
// expect(screen.getByTestId('recent-searches-blankslate')).toBeInTheDocument();
|
||||||
// });
|
// });
|
||||||
|
|
|
@ -39,7 +39,7 @@ const groupSearchResult = {
|
||||||
groups: [buildGroup()],
|
groups: [buildGroup()],
|
||||||
hasNextPage: false,
|
hasNextPage: false,
|
||||||
isFetching: false,
|
isFetching: false,
|
||||||
fetchNextPage: jest.fn(),
|
fetchNextPage: vi.fn(),
|
||||||
} as any;
|
} as any;
|
||||||
|
|
||||||
describe('<Results />', () => {
|
describe('<Results />', () => {
|
||||||
|
|
|
@ -24,7 +24,7 @@ describe('<Search />', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should render the blankslate', async () => {
|
it('should render the blankslate', async () => {
|
||||||
renderApp(<Search searchValue={'some-search'} onSelect={jest.fn()} />);
|
renderApp(<Search searchValue={'some-search'} onSelect={vi.fn()} />);
|
||||||
|
|
||||||
await waitFor(() => {
|
await waitFor(() => {
|
||||||
expect(screen.getByTestId('no-results')).toBeInTheDocument();
|
expect(screen.getByTestId('no-results')).toBeInTheDocument();
|
||||||
|
@ -45,7 +45,7 @@ describe('<Search />', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should render the results', async () => {
|
it('should render the results', async () => {
|
||||||
renderApp(<Search searchValue={'some-search'} onSelect={jest.fn()} />);
|
renderApp(<Search searchValue={'some-search'} onSelect={vi.fn()} />);
|
||||||
|
|
||||||
await waitFor(() => {
|
await waitFor(() => {
|
||||||
expect(screen.getByTestId('results')).toBeInTheDocument();
|
expect(screen.getByTestId('results')).toBeInTheDocument();
|
||||||
|
@ -55,7 +55,7 @@ describe('<Search />', () => {
|
||||||
|
|
||||||
describe('before starting a search', () => {
|
describe('before starting a search', () => {
|
||||||
it('should render the RecentSearches component', () => {
|
it('should render the RecentSearches component', () => {
|
||||||
renderApp(<Search searchValue={''} onSelect={jest.fn()} />);
|
renderApp(<Search searchValue={''} onSelect={vi.fn()} />);
|
||||||
|
|
||||||
expect(screen.getByTestId('recent-searches')).toBeInTheDocument();
|
expect(screen.getByTestId('recent-searches')).toBeInTheDocument();
|
||||||
});
|
});
|
||||||
|
|
|
@ -7,25 +7,25 @@ import LandingPageModal from '../landing-page-modal';
|
||||||
|
|
||||||
describe('<LandingPageModal />', () => {
|
describe('<LandingPageModal />', () => {
|
||||||
it('successfully renders', () => {
|
it('successfully renders', () => {
|
||||||
render(<LandingPageModal onClose={jest.fn} />);
|
render(<LandingPageModal onClose={vi.fn} />);
|
||||||
expect(screen.getByTestId('modal')).toBeInTheDocument();
|
expect(screen.getByTestId('modal')).toBeInTheDocument();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('doesn\'t display the signup button by default', () => {
|
it('doesn\'t display the signup button by default', () => {
|
||||||
render(<LandingPageModal onClose={jest.fn} />);
|
render(<LandingPageModal onClose={vi.fn} />);
|
||||||
expect(screen.queryByText('Register')).not.toBeInTheDocument();
|
expect(screen.queryByText('Register')).not.toBeInTheDocument();
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('with registrations enabled', () => {
|
describe('with registrations enabled', () => {
|
||||||
it('displays the signup button', () => {
|
it('displays the signup button', () => {
|
||||||
render(<LandingPageModal onClose={jest.fn} />, undefined, storeOpen);
|
render(<LandingPageModal onClose={vi.fn} />, undefined, storeOpen);
|
||||||
expect(screen.getByText('Register')).toBeInTheDocument();
|
expect(screen.getByText('Register')).toBeInTheDocument();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('with registrations closed, Pepe enabled', () => {
|
describe('with registrations closed, Pepe enabled', () => {
|
||||||
it('displays the signup button', () => {
|
it('displays the signup button', () => {
|
||||||
render(<LandingPageModal onClose={jest.fn} />, undefined, storePepeOpen);
|
render(<LandingPageModal onClose={vi.fn} />, undefined, storePepeOpen);
|
||||||
expect(screen.getByText('Register')).toBeInTheDocument();
|
expect(screen.getByText('Register')).toBeInTheDocument();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -7,25 +7,25 @@ import UnauthorizedModal from '../unauthorized-modal';
|
||||||
|
|
||||||
describe('<UnauthorizedModal />', () => {
|
describe('<UnauthorizedModal />', () => {
|
||||||
it('successfully renders', () => {
|
it('successfully renders', () => {
|
||||||
render(<UnauthorizedModal onClose={jest.fn} action='FOLLOW' />);
|
render(<UnauthorizedModal onClose={vi.fn} action='FOLLOW' />);
|
||||||
expect(screen.getByTestId('modal')).toBeInTheDocument();
|
expect(screen.getByTestId('modal')).toBeInTheDocument();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('doesn\'t display the signup button by default', () => {
|
it('doesn\'t display the signup button by default', () => {
|
||||||
render(<UnauthorizedModal onClose={jest.fn} action='FOLLOW' />);
|
render(<UnauthorizedModal onClose={vi.fn} action='FOLLOW' />);
|
||||||
expect(screen.queryByText('Sign up')).not.toBeInTheDocument();
|
expect(screen.queryByText('Sign up')).not.toBeInTheDocument();
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('with registrations enabled', () => {
|
describe('with registrations enabled', () => {
|
||||||
it('displays the signup button', () => {
|
it('displays the signup button', () => {
|
||||||
render(<UnauthorizedModal onClose={jest.fn} action='FOLLOW' />, undefined, storeOpen);
|
render(<UnauthorizedModal onClose={vi.fn} action='FOLLOW' />, undefined, storeOpen);
|
||||||
expect(screen.getByText('Sign up')).toBeInTheDocument();
|
expect(screen.getByText('Sign up')).toBeInTheDocument();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('with registrations closed, Pepe enabled', () => {
|
describe('with registrations closed, Pepe enabled', () => {
|
||||||
it('displays the signup button', () => {
|
it('displays the signup button', () => {
|
||||||
render(<UnauthorizedModal onClose={jest.fn} action='FOLLOW' />, undefined, storePepeOpen);
|
render(<UnauthorizedModal onClose={vi.fn} action='FOLLOW' />, undefined, storePepeOpen);
|
||||||
expect(screen.getByText('Sign up')).toBeInTheDocument();
|
expect(screen.getByText('Sign up')).toBeInTheDocument();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -51,13 +51,13 @@ test.skip('skip', () => {});
|
||||||
// });
|
// });
|
||||||
|
|
||||||
// it('successfully renders the first step', () => {
|
// it('successfully renders the first step', () => {
|
||||||
// render(<ReportModal onClose={jest.fn} />, {}, store);
|
// render(<ReportModal onClose={vi.fn} />, {}, store);
|
||||||
// expect(screen.getByText('Reason for reporting')).toBeInTheDocument();
|
// expect(screen.getByText('Reason for reporting')).toBeInTheDocument();
|
||||||
// });
|
// });
|
||||||
|
|
||||||
// it('successfully moves to the second step', async() => {
|
// it('successfully moves to the second step', async() => {
|
||||||
// const user = userEvent.setup();
|
// const user = userEvent.setup();
|
||||||
// render(<ReportModal onClose={jest.fn} />, {}, store);
|
// render(<ReportModal onClose={vi.fn} />, {}, store);
|
||||||
// await user.click(screen.getByTestId('rule-1'));
|
// await user.click(screen.getByTestId('rule-1'));
|
||||||
// await user.click(screen.getByText('Next'));
|
// await user.click(screen.getByText('Next'));
|
||||||
// expect(screen.getByText(/Further actions:/)).toBeInTheDocument();
|
// expect(screen.getByText(/Further actions:/)).toBeInTheDocument();
|
||||||
|
@ -65,7 +65,7 @@ test.skip('skip', () => {});
|
||||||
|
|
||||||
// it('successfully moves to the third step', async() => {
|
// it('successfully moves to the third step', async() => {
|
||||||
// const user = userEvent.setup();
|
// const user = userEvent.setup();
|
||||||
// render(<ReportModal onClose={jest.fn} />, {}, store);
|
// render(<ReportModal onClose={vi.fn} />, {}, store);
|
||||||
// await user.click(screen.getByTestId('rule-1'));
|
// await user.click(screen.getByTestId('rule-1'));
|
||||||
// await user.click(screen.getByText(/Next/));
|
// await user.click(screen.getByText(/Next/));
|
||||||
// await user.click(screen.getByText(/Submit/));
|
// await user.click(screen.getByText(/Submit/));
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
let listener: ((rect: any) => void) | undefined = undefined;
|
let listener: ((rect: any) => void) | undefined = undefined;
|
||||||
const mockDisconnect = jest.fn();
|
const mockDisconnect = vi.fn();
|
||||||
|
|
||||||
class ResizeObserver {
|
class ResizeObserver {
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue