Fix LoginPage & LoginForm tests
This commit is contained in:
parent
f2384ef178
commit
2c2300cda4
4 changed files with 86 additions and 79 deletions
|
@ -1,6 +1,66 @@
|
|||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`<LoginForm /> renders correctly 1`] = `
|
||||
exports[`<LoginForm /> renders for Mastodon 1`] = `
|
||||
<form
|
||||
className="simple_form new_user"
|
||||
method="post"
|
||||
>
|
||||
<fieldset>
|
||||
<div
|
||||
className="fields-group"
|
||||
>
|
||||
<div
|
||||
className="input email user_email"
|
||||
>
|
||||
<input
|
||||
aria-label="Username"
|
||||
autoComplete="off"
|
||||
className="string email"
|
||||
name="username"
|
||||
placeholder="Username"
|
||||
required={true}
|
||||
type="text"
|
||||
/>
|
||||
</div>
|
||||
<div
|
||||
className="input password user_password"
|
||||
>
|
||||
<input
|
||||
aria-label="Password"
|
||||
autoComplete="off"
|
||||
className="password"
|
||||
name="password"
|
||||
placeholder="Password"
|
||||
required={true}
|
||||
type="password"
|
||||
/>
|
||||
</div>
|
||||
<p
|
||||
className="hint subtle-hint"
|
||||
>
|
||||
<a
|
||||
href="/auth/password/new"
|
||||
>
|
||||
Trouble logging in?
|
||||
</a>
|
||||
</p>
|
||||
</div>
|
||||
</fieldset>
|
||||
<div
|
||||
className="actions"
|
||||
>
|
||||
<button
|
||||
className="btn button button-primary"
|
||||
name="button"
|
||||
type="submit"
|
||||
>
|
||||
Log in
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
`;
|
||||
|
||||
exports[`<LoginForm /> renders for Pleroma 1`] = `
|
||||
<form
|
||||
className="simple_form new_user"
|
||||
method="post"
|
||||
|
|
|
@ -63,67 +63,3 @@ exports[`<LoginPage /> renders correctly on load 1`] = `
|
|||
</div>
|
||||
</form>
|
||||
`;
|
||||
|
||||
exports[`<LoginPage /> renders correctly on load 2`] = `
|
||||
<form
|
||||
className="simple_form new_user"
|
||||
method="post"
|
||||
onSubmit={[Function]}
|
||||
>
|
||||
<fieldset
|
||||
disabled={false}
|
||||
>
|
||||
<div
|
||||
className="fields-group"
|
||||
>
|
||||
<div
|
||||
className="input email user_email"
|
||||
>
|
||||
<input
|
||||
aria-label="Username"
|
||||
autoComplete="off"
|
||||
className="string email"
|
||||
name="username"
|
||||
placeholder="Username"
|
||||
required={true}
|
||||
type="text"
|
||||
/>
|
||||
</div>
|
||||
<div
|
||||
className="input password user_password"
|
||||
>
|
||||
<input
|
||||
aria-label="Password"
|
||||
autoComplete="off"
|
||||
className="password"
|
||||
name="password"
|
||||
placeholder="Password"
|
||||
required={true}
|
||||
type="password"
|
||||
/>
|
||||
</div>
|
||||
<p
|
||||
className="hint subtle-hint"
|
||||
>
|
||||
<a
|
||||
href="/auth/reset_password"
|
||||
onClick={[Function]}
|
||||
>
|
||||
Trouble logging in?
|
||||
</a>
|
||||
</p>
|
||||
</div>
|
||||
</fieldset>
|
||||
<div
|
||||
className="actions"
|
||||
>
|
||||
<button
|
||||
className="btn button button-primary"
|
||||
name="button"
|
||||
type="submit"
|
||||
>
|
||||
Log in
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
`;
|
||||
|
|
|
@ -1,11 +1,29 @@
|
|||
import React from 'react';
|
||||
import LoginForm from '../login_form';
|
||||
import { createComponent } from 'soapbox/test_helpers';
|
||||
import { createComponent, mockStore } from 'soapbox/test_helpers';
|
||||
import rootReducer from 'soapbox/reducers';
|
||||
|
||||
describe('<LoginForm />', () => {
|
||||
it('renders correctly', () => {
|
||||
|
||||
it('renders for Pleroma', () => {
|
||||
const state = rootReducer(undefined, {})
|
||||
.update('instance', instance => instance.set('version', '2.7.2 (compatible; Pleroma 2.3.0)'));
|
||||
const store = mockStore(state);
|
||||
|
||||
expect(createComponent(
|
||||
<LoginForm />,
|
||||
{ store },
|
||||
).toJSON()).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('renders for Mastodon', () => {
|
||||
const state = rootReducer(undefined, {})
|
||||
.update('instance', instance => instance.set('version', '3.0.0'));
|
||||
const store = mockStore(state);
|
||||
|
||||
expect(createComponent(
|
||||
<LoginForm />,
|
||||
{ store },
|
||||
).toJSON()).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,22 +1,15 @@
|
|||
import React from 'react';
|
||||
import LoginPage from '../login_page';
|
||||
import { createComponent, mockStore } from 'soapbox/test_helpers';
|
||||
import { Map as ImmutableMap } from 'immutable';
|
||||
// import { __stub as stubApi } from 'soapbox/api';
|
||||
// import { logIn } from 'soapbox/actions/auth';
|
||||
import rootReducer from 'soapbox/reducers';
|
||||
|
||||
describe('<LoginPage />', () => {
|
||||
beforeEach(() => {
|
||||
const store = mockStore(ImmutableMap({}));
|
||||
return store;
|
||||
});
|
||||
|
||||
it('renders correctly on load', () => {
|
||||
expect(createComponent(
|
||||
<LoginPage />,
|
||||
).toJSON()).toMatchSnapshot();
|
||||
const state = rootReducer(undefined, {})
|
||||
.set('me', '1234')
|
||||
.update('instance', instance => instance.set('version', '2.7.2 (compatible; Pleroma 2.3.0)'));
|
||||
const store = mockStore(state);
|
||||
|
||||
const store = mockStore(ImmutableMap({ me: '1234' }));
|
||||
expect(createComponent(
|
||||
<LoginPage />,
|
||||
{ store },
|
||||
|
|
Loading…
Reference in a new issue