summaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/components/Login.spec.js45
1 files changed, 18 insertions, 27 deletions
diff --git a/test/components/Login.spec.js b/test/components/Login.spec.js
index b97a46d24b..f34d9ea405 100644
--- a/test/components/Login.spec.js
+++ b/test/components/Login.spec.js
@@ -4,59 +4,48 @@ import { expect } from 'chai';
import React from 'react';
import { shallow } from 'enzyme';
import sinon from 'sinon';
-import { mockState } from './../mocks/redux';
import Login from '../../app/components/Login';
import AccountInput from '../../app/components/AccountInput';
-import type { ShallowWrapper } from 'enzyme';
-
describe('components/Login', () => {
it('notifies on the first change after failure', () => {
-
- let callback = sinon.spy();
+ let onFirstChange = sinon.spy();
const props = {
account: Object.assign({}, defaultAccount, {
status: 'failed'
}),
- onFirstChangeAfterFailure: callback,
+ onFirstChangeAfterFailure: onFirstChange,
};
const component = renderWithProps( props );
const accountInput = component.find(AccountInput);
- // Write something in the input field
- setInputText(accountInput, 'foo');
- expect(callback.calledOnce).to.be.true;
-
+ accountInput.simulate('change', 'foo');
+ expect(onFirstChange.calledOnce).to.be.true;
- // Reset the test state
- callback.reset();
+ onFirstChange.reset();
- // Write some other thing in the input field
- setInputText(accountInput, 'bar');
- expect(callback.calledOnce).to.be.false;
+ accountInput.simulate('change', 'bar');
+ expect(onFirstChange.calledOnce).to.be.false;
});
- it('doesn\'t show the footer when logging in', () => {
+ it('does not show the footer when logging in', () => {
const component = renderLoggingIn();
-
const footer = component.find('.login-footer');
expect(footer.hasClass('login-footer--invisible')).to.be.true;
});
it('shows the footer and account input when not logged in', () => {
const component = renderNotLoggedIn();
-
const footer = component.find('.login-footer');
expect(footer.hasClass('login-footer--invisible')).to.be.false;
expect(component.find(AccountInput).exists()).to.be.true;
});
- it('doesn\'t show the footer nor account input when logged in', () => {
+ it('does not show the footer nor account input when logged in', () => {
const component = renderLoggedIn();
-
const footer = component.find('.login-footer');
expect(footer.hasClass('login-footer--invisible')).to.be.true;
expect(component.find('.login-form__fields')).to.have.length(0);
@@ -65,7 +54,7 @@ describe('components/Login', () => {
it('logs in with the entered account number when clicking the login icon', (done) => {
const component = renderNotLoggedIn();
component.setProps({
- account: Object.assign(mockState().account, {
+ account: Object.assign({}, defaultAccount, {
accountToken: '12345'
}),
onLogin: (an) => {
@@ -82,7 +71,13 @@ describe('components/Login', () => {
});
});
-const defaultAccount = mockState().account;
+const defaultAccount = {
+ accountToken: null,
+ accountHistory: [],
+ expiry: null,
+ status: 'none',
+ error: null
+};
const defaultProps = {
account: defaultAccount,
@@ -119,11 +114,7 @@ function renderNotLoggedIn() {
});
}
-function renderWithProps(customProps): ShallowWrapper {
+function renderWithProps(customProps) {
const props = Object.assign({}, defaultProps, customProps);
return shallow( <Login { ...props } /> );
}
-
-function setInputText(input: ShallowWrapper, text: string) {
- input.simulate('change', text);
-}