diff options
Diffstat (limited to 'vnext')
4 files changed, 24 insertions, 27 deletions
diff --git a/vnext/src/components/LoginButton.js b/vnext/src/components/LoginButton.js index 92be22b8..cd26252e 100644 --- a/vnext/src/components/LoginButton.js +++ b/vnext/src/components/LoginButton.js @@ -9,7 +9,6 @@ import { useFormState } from 'react-use-form-state'; import { me, facebookLink, vkLink } from '../api'; function LoginButton({ onAuth, title }) { - const [open, setOpen] = useState(false); const [formState, { text, password }] = useFormState(); @@ -18,7 +17,7 @@ function LoginButton({ onAuth, title }) { event.preventDefault(); } setOpen(!open); - } + }; let onSubmit = (event) => { event.preventDefault(); me(formState.values.username, formState.values.password) @@ -29,7 +28,7 @@ function LoginButton({ onAuth, title }) { ).catch(ex => { console.log(ex); }); - } + }; return ( <> <a onClick={onToggle}> @@ -88,4 +87,4 @@ const vkButtonStyle = { background: '#4c75a3' }; -export default LoginButton;
\ No newline at end of file +export default LoginButton; diff --git a/vnext/src/components/__tests__/LoginButton.test.js b/vnext/src/components/__tests__/LoginButton.test.js index be083c22..da80abb0 100644 --- a/vnext/src/components/__tests__/LoginButton.test.js +++ b/vnext/src/components/__tests__/LoginButton.test.js @@ -1,16 +1,21 @@ import React from 'react'; import LoginButton from '../LoginButton'; -import renderer from 'react-test-renderer'; +import { create, act } from 'react-test-renderer'; test('Login button and form are renders correctly', () => { - const button = renderer.create( - <LoginButton title="Log in" onAuth={() => {}} /> - ); + var button = null; + act(() => { + button = create( + <LoginButton title="Log in" onAuth={() => { }} /> + ); + }); let link = button.toJSON(); expect(link).toMatchSnapshot(); - button.root.instance.toggleModal(); + act(() => { + button.root.findByType('a').props.onClick(); + }); let modal = button.toJSON(); expect(modal).toMatchSnapshot(); }); diff --git a/vnext/src/components/__tests__/__snapshots__/LoginButton.test.js.snap b/vnext/src/components/__tests__/__snapshots__/LoginButton.test.js.snap index e5c4ebe5..e2e36e24 100644 --- a/vnext/src/components/__tests__/__snapshots__/LoginButton.test.js.snap +++ b/vnext/src/components/__tests__/__snapshots__/LoginButton.test.js.snap @@ -49,17 +49,6 @@ Array [ </a>, <div id="dialogt" - style={ - Object { - "backgroundColor": "rgba(0, 0, 0, 0.3)", - "bottom": 0, - "left": 0, - "padding": 50, - "position": "fixed", - "right": 0, - "top": 0, - } - } > <div id="dialogw" @@ -156,8 +145,9 @@ Array [ onSubmit={[Function]} > <input - className="signinput" + class="input" name="username" + onBlur={[Function]} onChange={[Function]} placeholder="Username..." type="text" @@ -165,19 +155,21 @@ Array [ /> <br /> <input - className="signinput" + class="input" name="password" + onBlur={[Function]} onChange={[Function]} placeholder="Password..." type="password" value="" /> <br /> - <input - className="signsubmit" - type="submit" - value="OK" - /> + <button + className="Button" + onClick={[Function]} + > + OK + </button> </form> </div> </div> diff --git a/vnext/src/components/__tests__/__snapshots__/UserLink.test.js.snap b/vnext/src/components/__tests__/__snapshots__/UserLink.test.js.snap index 996e592a..15e25367 100644 --- a/vnext/src/components/__tests__/__snapshots__/UserLink.test.js.snap +++ b/vnext/src/components/__tests__/__snapshots__/UserLink.test.js.snap @@ -23,6 +23,7 @@ Array [ ugnich </a>, <a + className="info-avatar" href="https://example.com/u/test" > <img /> |