Merge branch 'add-login-tests' into 'next'
Add tests for LoginForm See merge request soapbox-pub/soapbox-fe!1177
This commit is contained in:
commit
424ad5edfa
3 changed files with 17 additions and 5 deletions
|
@ -1,31 +1,41 @@
|
|||
import { Map as ImmutableMap } from 'immutable';
|
||||
import React from 'react';
|
||||
|
||||
import { render, screen } from '../../../../jest/test-helpers';
|
||||
import { fireEvent, render, screen } from '../../../../jest/test-helpers';
|
||||
import LoginForm from '../login_form';
|
||||
|
||||
describe('<LoginForm />', () => {
|
||||
it('renders for Pleroma', () => {
|
||||
const mockFn = jest.fn();
|
||||
const store = {
|
||||
instance: ImmutableMap({
|
||||
version: '2.7.2 (compatible; Pleroma 2.3.0)',
|
||||
}),
|
||||
};
|
||||
|
||||
render(<LoginForm />, null, store);
|
||||
render(<LoginForm handleSubmit={mockFn} isLoading={false} />, null, store);
|
||||
|
||||
expect(screen.getByRole('heading')).toHaveTextContent('Sign In');
|
||||
expect(screen.getByRole('heading')).toHaveTextContent(/sign in/i);
|
||||
});
|
||||
|
||||
it('renders for Mastodon', () => {
|
||||
const mockFn = jest.fn();
|
||||
const store = {
|
||||
instance: ImmutableMap({
|
||||
version: '3.0.0',
|
||||
}),
|
||||
};
|
||||
|
||||
render(<LoginForm />, null, store);
|
||||
render(<LoginForm handleSubmit={mockFn} isLoading={false} />, null, store);
|
||||
|
||||
expect(screen.getByRole('heading')).toHaveTextContent('Sign In');
|
||||
expect(screen.getByRole('heading')).toHaveTextContent(/sign in/i);
|
||||
});
|
||||
|
||||
it('responds to the handleSubmit prop', () => {
|
||||
const mockFn = jest.fn();
|
||||
render(<LoginForm handleSubmit={mockFn} isLoading={false} />);
|
||||
fireEvent.submit(screen.getByTestId(/button/i));
|
||||
|
||||
expect(mockFn).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -66,6 +66,7 @@ const LoginForm = ({ isLoading, handleSubmit }) => {
|
|||
required
|
||||
/>
|
||||
</FormGroup>
|
||||
|
||||
<FormActions>
|
||||
<Button
|
||||
theme='primary'
|
||||
|
|
|
@ -29,6 +29,7 @@ module.exports = {
|
|||
'<rootDir>/node_modules',
|
||||
'<rootDir>/app',
|
||||
],
|
||||
'testMatch': ['**/*/__tests__/**/?(*.|*-)+(test).(ts|js)?(x)'],
|
||||
'testEnvironment': 'jsdom',
|
||||
'moduleNameMapper': {
|
||||
'^.+.(css|styl|less|sass|scss|png|jpg|svg|ttf|woff|woff2)$': 'jest-transform-stub',
|
||||
|
|
Loading…
Reference in a new issue