Skip to content

Commit

Permalink
tests
Browse files Browse the repository at this point in the history
  • Loading branch information
glena committed Jan 23, 2017
1 parent c65d474 commit 1a96c2b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/__tests__/field/__snapshots__/login_pane.test.jsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ exports[`LoginPane shows email pane when user usernameStyle === email 1`] = `
<div>
<div
data-__type="email_pane"
data-forceInvalidVisibility={false}
data-i18n={Object {}}
data-lock={Object {}}
data-placeholder="emailInputPlaceholder" />
Expand Down
8 changes: 8 additions & 0 deletions src/__tests__/field/email_pane.test.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from 'react';
import Immutable from 'immutable';
import { mount } from 'enzyme';

import { expectComponent, extractPropsFromWrapper, mockComponent } from 'testUtils';
Expand All @@ -20,8 +21,12 @@ describe('EmailPane', () => {
jest.resetModules();

const mockEmail = '[email protected]';
const mockEmailField = Immutable.fromJS({
value: mockEmail
});
jest.mock('field/index', () => ({
email: () => mockEmail,
getField: () => mockEmailField,
getFieldValue: () => mockEmail,
isFieldVisiblyInvalid: () => true
}));
Expand Down Expand Up @@ -60,6 +65,9 @@ describe('EmailPane', () => {
const fieldIndexMock = require('field/index');
fieldIndexMock.username = () => undefined;
fieldIndexMock.getFieldValue = () => undefined;
fieldIndexMock.getField = () => Immutable.fromJS({
value: undefined
});
const EmailPane = getComponent();

expectComponent(
Expand Down
4 changes: 2 additions & 2 deletions src/field/email/email_pane.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ export default class EmailPane extends React.Component {
const field = c.getField(lock, "email");
const value = field.get('value', "");
const valid = field.get('valid', true);
const invalidHint = field.get('invalidHint', i18n.str(value ? "invalidErrorHint": "blankErrorHint"));i18n.str(value ? "invalidErrorHint": "blankErrorHint")

const invalidHint = field.get('invalidHint', i18n.str(value ? "invalidErrorHint": "blankErrorHint"));
console.log(value, invalidHint);
const isValid = (!forceInvalidVisibility || valid) && !c.isFieldVisiblyInvalid(lock, "email");

return (
Expand Down

0 comments on commit 1a96c2b

Please sign in to comment.