2016-03-22 00:25:23 +01:00
|
|
|
jest.unmock('react');
|
|
|
|
jest.unmock('react-addons-test-utils');
|
|
|
|
jest.unmock('../');
|
|
|
|
|
|
|
|
import React from 'react';
|
|
|
|
import ReactTestUtils from 'react-addons-test-utils';
|
|
|
|
import TextFieldComponent from '../';
|
|
|
|
|
|
|
|
describe('TextFieldComponent', function() {
|
|
|
|
|
2016-03-30 23:45:54 +02:00
|
|
|
var props;
|
2016-03-22 00:25:23 +01:00
|
|
|
|
2016-03-30 23:45:54 +02:00
|
|
|
beforeEach(function () {
|
|
|
|
props = {
|
|
|
|
label: '',
|
|
|
|
name: '',
|
|
|
|
value: '',
|
|
|
|
onChange: jest.genMockFunction()
|
|
|
|
};
|
|
|
|
});
|
2016-03-22 00:25:23 +01:00
|
|
|
|
2016-03-30 23:45:54 +02:00
|
|
|
describe('handleChange()', function () {
|
|
|
|
var textField;
|
2016-03-22 00:25:23 +01:00
|
|
|
|
2016-03-30 23:45:54 +02:00
|
|
|
beforeEach(function () {
|
|
|
|
textField = ReactTestUtils.renderIntoDocument(
|
|
|
|
<TextFieldComponent {...props} />
|
|
|
|
);
|
|
|
|
});
|
2016-03-22 00:25:23 +01:00
|
|
|
|
2016-03-30 23:45:54 +02:00
|
|
|
it('should call the onChange function on props', function () {
|
|
|
|
textField.handleChange();
|
2016-03-22 00:25:23 +01:00
|
|
|
|
2016-03-30 23:45:54 +02:00
|
|
|
expect(textField.props.onChange.mock.calls.length).toBe(1);
|
2016-03-22 00:25:23 +01:00
|
|
|
});
|
2016-03-30 23:45:54 +02:00
|
|
|
});
|
2016-03-22 00:25:23 +01:00
|
|
|
});
|