|
|
@@ -2,15 +2,17 @@ import React from 'react';
|
|
|
import Form from '../components/Form/Form.js';
|
|
|
import { mount, shallow } from 'enzyme';
|
|
|
|
|
|
+import { Input, Warning } from '../components/Form/style';
|
|
|
+
|
|
|
describe('Place holder', () => {
|
|
|
const colorTest = (inputWindow, color) => {
|
|
|
- const inputField = inputWindow.find('input').at(0).prop('style');
|
|
|
+ const inputField = inputWindow.find(Input).at(0).prop('style');
|
|
|
expect(inputField).toHaveProperty('color', color);
|
|
|
};
|
|
|
|
|
|
it('Placeholder shows on loading and color is grey', () => {
|
|
|
const inputWindow = shallow(<Form />);
|
|
|
- expect(inputWindow.find('input').at(0).prop('value')).toBeTruthy();
|
|
|
+ expect(inputWindow.find(Input).at(0).prop('value')).toBeTruthy();
|
|
|
colorTest(inputWindow, 'grey');
|
|
|
});
|
|
|
|
|
|
@@ -60,12 +62,12 @@ describe('Validation', () => {
|
|
|
target: { name: name, value: newValue }
|
|
|
});
|
|
|
inputField.simulate('blur');
|
|
|
- expect(formWindow.find('.warning').at(0).length).toBe(1);
|
|
|
+ expect(formWindow.find(Warning).at(0).length).toBe(1);
|
|
|
});
|
|
|
|
|
|
it('Unmatched password shows a warning on blur', () => {
|
|
|
const formWindow = mount(<Form />);
|
|
|
- const inputField = formWindow.find('input').at(1);
|
|
|
+ const inputField = formWindow.find(Input).at(1);
|
|
|
expect(inputField.prop('type')).toBe('password');
|
|
|
const name = inputField.prop('name');
|
|
|
const newValue = 'test';
|
|
|
@@ -73,13 +75,13 @@ describe('Validation', () => {
|
|
|
target: { name: name, value: newValue }
|
|
|
});
|
|
|
inputField.simulate('blur');
|
|
|
- expect(formWindow.find('.warning').length).toBeTruthy();
|
|
|
+ expect(formWindow.find(Warning).length).toBeTruthy();
|
|
|
});
|
|
|
|
|
|
it('Submitting an empty form shows all warnings', () => {
|
|
|
const formWindow = mount(<Form />);
|
|
|
formWindow.simulate('submit');
|
|
|
// two warnings on two pwd input fields
|
|
|
- expect(formWindow.find('.warning').length).toBeTruthy();
|
|
|
+ expect(formWindow.find(Warning).length).toBeTruthy();
|
|
|
});
|
|
|
});
|