2022-04-04 15:53:47 +00:00
|
|
|
import React from 'react';
|
|
|
|
|
2022-08-12 03:31:53 +00:00
|
|
|
import { normalizeInstance } from 'soapbox/normalizers';
|
|
|
|
|
2022-04-04 19:58:23 +00:00
|
|
|
import { fireEvent, render, screen } from '../../../../jest/test-helpers';
|
2022-11-16 13:32:32 +00:00
|
|
|
import LoginForm from '../login-form';
|
2022-04-04 15:53:47 +00:00
|
|
|
|
|
|
|
describe('<LoginForm />', () => {
|
|
|
|
it('renders for Pleroma', () => {
|
2023-09-16 20:16:59 +00:00
|
|
|
const mockFn = vi.fn();
|
2022-04-04 15:53:47 +00:00
|
|
|
const store = {
|
2022-08-12 03:31:53 +00:00
|
|
|
instance: normalizeInstance({
|
2022-04-04 15:53:47 +00:00
|
|
|
version: '2.7.2 (compatible; Pleroma 2.3.0)',
|
|
|
|
}),
|
|
|
|
};
|
|
|
|
|
2022-07-06 17:31:11 +00:00
|
|
|
render(<LoginForm handleSubmit={mockFn} isLoading={false} />, undefined, store);
|
2022-04-04 15:53:47 +00:00
|
|
|
|
2022-04-04 19:58:23 +00:00
|
|
|
expect(screen.getByRole('heading')).toHaveTextContent(/sign in/i);
|
2022-04-04 15:53:47 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('renders for Mastodon', () => {
|
2023-09-16 20:16:59 +00:00
|
|
|
const mockFn = vi.fn();
|
2022-04-04 15:53:47 +00:00
|
|
|
const store = {
|
2022-08-12 03:31:53 +00:00
|
|
|
instance: normalizeInstance({
|
2022-04-04 15:53:47 +00:00
|
|
|
version: '3.0.0',
|
|
|
|
}),
|
|
|
|
};
|
|
|
|
|
2022-07-06 17:31:11 +00:00
|
|
|
render(<LoginForm handleSubmit={mockFn} isLoading={false} />, undefined, store);
|
2022-04-04 15:53:47 +00:00
|
|
|
|
2022-04-04 19:58:23 +00:00
|
|
|
expect(screen.getByRole('heading')).toHaveTextContent(/sign in/i);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('responds to the handleSubmit prop', () => {
|
2023-09-16 20:16:59 +00:00
|
|
|
const mockFn = vi.fn();
|
2022-04-04 19:58:23 +00:00
|
|
|
render(<LoginForm handleSubmit={mockFn} isLoading={false} />);
|
|
|
|
fireEvent.submit(screen.getByTestId(/button/i));
|
|
|
|
|
|
|
|
expect(mockFn).toHaveBeenCalledTimes(1);
|
2022-04-04 15:53:47 +00:00
|
|
|
});
|
|
|
|
});
|