From 8d49edac6af9dd08f1bb7b1727aee36af413a4a2 Mon Sep 17 00:00:00 2001 From: Anike Arni Date: Tue, 28 Mar 2017 18:59:33 -0300 Subject: [#932] Moves form componentes to separate directories with @deniscostadsc --- .../admin_recovery_code_form.js | 54 ++++++++++++++++++++++ .../admin_recovery_code_form.scss | 22 +++++++++ .../admin_recovery_code_form.spec.js | 38 +++++++++++++++ 3 files changed, 114 insertions(+) create mode 100644 web-ui/src/account_recovery/admin_recovery_code_form/admin_recovery_code_form.js create mode 100644 web-ui/src/account_recovery/admin_recovery_code_form/admin_recovery_code_form.scss create mode 100644 web-ui/src/account_recovery/admin_recovery_code_form/admin_recovery_code_form.spec.js (limited to 'web-ui/src/account_recovery/admin_recovery_code_form') diff --git a/web-ui/src/account_recovery/admin_recovery_code_form/admin_recovery_code_form.js b/web-ui/src/account_recovery/admin_recovery_code_form/admin_recovery_code_form.js new file mode 100644 index 00000000..7a82a5d7 --- /dev/null +++ b/web-ui/src/account_recovery/admin_recovery_code_form/admin_recovery_code_form.js @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2017 ThoughtWorks, Inc. + * + * Pixelated is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Pixelated is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Pixelated. If not, see . + */ + +import React from 'react'; +import { translate } from 'react-i18next'; + +import InputField from 'src/common/input_field/input_field'; +import SubmitButton from 'src/common/submit_button/submit_button'; + +import './admin_recovery_code_form.scss'; + +export const AdminRecoveryCodeForm = ({ t, next }) => ( +
+ {t('account-recovery.admin-form.image-description')} +

{t('account-recovery.admin-form.title')}

+ +
    +
  • {t('account-recovery.admin-form.tip1')}
  • +
  • {t('account-recovery.admin-form.tip2')}
  • +
  • {t('account-recovery.admin-form.tip3')}
  • +
+ + + +); + +AdminRecoveryCodeForm.propTypes = { + t: React.PropTypes.func.isRequired, + next: React.PropTypes.func.isRequired +}; + +export default translate('', { wait: true })(AdminRecoveryCodeForm); diff --git a/web-ui/src/account_recovery/admin_recovery_code_form/admin_recovery_code_form.scss b/web-ui/src/account_recovery/admin_recovery_code_form/admin_recovery_code_form.scss new file mode 100644 index 00000000..6dcbcc67 --- /dev/null +++ b/web-ui/src/account_recovery/admin_recovery_code_form/admin_recovery_code_form.scss @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2017 ThoughtWorks, Inc. + * + * Pixelated is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Pixelated is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Pixelated. If not, see . + */ + +.admin-code-image { + margin: 1em 0; + align-self: center; + height: 2.7em; +} diff --git a/web-ui/src/account_recovery/admin_recovery_code_form/admin_recovery_code_form.spec.js b/web-ui/src/account_recovery/admin_recovery_code_form/admin_recovery_code_form.spec.js new file mode 100644 index 00000000..85b75652 --- /dev/null +++ b/web-ui/src/account_recovery/admin_recovery_code_form/admin_recovery_code_form.spec.js @@ -0,0 +1,38 @@ +import { shallow } from 'enzyme'; +import expect from 'expect'; +import React from 'react'; +import { AdminRecoveryCodeForm } from './admin_recovery_code_form'; + +describe('AdminRecoveryCodeForm', () => { + let adminRecoveryCodeForm; + let mockNext; + + beforeEach(() => { + const mockTranslations = key => key; + mockNext = expect.createSpy(); + adminRecoveryCodeForm = shallow( + + ); + }); + + it('renders title for admin recovery code', () => { + expect(adminRecoveryCodeForm.find('h1').text()).toEqual('account-recovery.admin-form.title'); + }); + + it('renders tips for retrieving recovery code', () => { + expect(adminRecoveryCodeForm.find('li').length).toEqual(3); + }); + + it('renders input field for admin code', () => { + expect(adminRecoveryCodeForm.find('InputField').props().name).toEqual('admin-code'); + }); + + it('renders button for next step', () => { + expect(adminRecoveryCodeForm.find('SubmitButton').props().buttonText).toEqual('account-recovery.admin-form.button'); + }); + + it('submits form to next step', () => { + adminRecoveryCodeForm.find('form').simulate('submit'); + expect(mockNext).toHaveBeenCalled(); + }); +}); -- cgit v1.2.3