composable-form-tests
Advanced tools
Comparing version 0.0.1 to 0.0.2
@@ -33,26 +33,26 @@ "use strict"; | ||
test(inputName + " calls onChanging followed by onChanged before initial mount", function () { | ||
test(inputName + " calls onChanging followed by onChange before initial mount", function () { | ||
var onChanging = jest.fn(); | ||
var onChanged = jest.fn(); | ||
var onChange = jest.fn(); | ||
mount(_react2.default.createElement(Input, _extends({ name: "test", onChanging: onChanging, onChanged: onChanged, options: options }, props))); | ||
mount(_react2.default.createElement(Input, _extends({ name: "test", onChanging: onChanging, onChange: onChange, options: options }, props))); | ||
expect(onChanging).toHaveBeenCalledTimes(1); | ||
expect(onChanged).toHaveBeenCalledTimes(1); | ||
expect(onChange).toHaveBeenCalledTimes(1); | ||
expect(onChanging).toHaveBeenLastCalledWith(defaultValue); | ||
expect(onChanged).toHaveBeenLastCalledWith(defaultValue); | ||
expect(onChange).toHaveBeenLastCalledWith(defaultValue); | ||
}); | ||
test(inputName + " calls onChanging and onChanged", function () { | ||
test(inputName + " calls onChanging and onChange", function () { | ||
var onChanging = jest.fn(); | ||
var onChanged = jest.fn(); | ||
var onChange = jest.fn(); | ||
var wrapper = mount(_react2.default.createElement(Input, _extends({ name: "test", onChanging: onChanging, onChanged: onChanged, options: options }, props))); | ||
var wrapper = mount(_react2.default.createElement(Input, _extends({ name: "test", onChanging: onChanging, onChange: onChange, options: options }, props))); | ||
onChanging.mockClear(); | ||
onChanged.mockClear(); | ||
onChange.mockClear(); | ||
// Inputs need not have a way of "changing" but must call only onChanging | ||
// and not onChanged if they do. | ||
// and not onChange if they do. | ||
if (typeof simulateChanging === 'function') { | ||
@@ -62,8 +62,8 @@ simulateChanging(wrapper, exampleValueOne); | ||
expect(onChanging).toHaveBeenLastCalledWith(exampleValueOne); | ||
expect(onChanged).toHaveBeenCalledTimes(0); | ||
expect(onChange).toHaveBeenCalledTimes(0); | ||
} | ||
simulateChanged(wrapper, exampleValueOne); | ||
expect(onChanged).toHaveBeenCalledTimes(1); | ||
expect(onChanged).toHaveBeenLastCalledWith(exampleValueOne); | ||
expect(onChange).toHaveBeenCalledTimes(1); | ||
expect(onChange).toHaveBeenLastCalledWith(exampleValueOne); | ||
}); | ||
@@ -82,7 +82,7 @@ | ||
test(inputName + " calls onChanging followed by onChanged when the value prop changes", function () { | ||
test(inputName + " calls onChanging followed by onChange when the value prop changes", function () { | ||
var onChanging = jest.fn(); | ||
var onChanged = jest.fn(); | ||
var onChange = jest.fn(); | ||
var wrapper = mount(_react2.default.createElement(Input, _extends({ name: "test", onChanging: onChanging, onChanged: onChanged, value: exampleValueOne, options: options }, props))); | ||
var wrapper = mount(_react2.default.createElement(Input, _extends({ name: "test", onChanging: onChanging, onChange: onChange, value: exampleValueOne, options: options }, props))); | ||
@@ -92,8 +92,8 @@ wrapper.setProps({ value: exampleValueTwo }); | ||
expect(onChanging).toHaveBeenCalledTimes(2); | ||
expect(onChanged).toHaveBeenCalledTimes(2); | ||
expect(onChange).toHaveBeenCalledTimes(2); | ||
expect(onChanging.mock.calls[0][0]).toEqual(exampleValueOne); | ||
expect(onChanged.mock.calls[0][0]).toEqual(exampleValueOne); | ||
expect(onChange.mock.calls[0][0]).toEqual(exampleValueOne); | ||
expect(onChanging.mock.calls[1][0]).toEqual(exampleValueTwo); | ||
expect(onChanged.mock.calls[1][0]).toEqual(exampleValueTwo); | ||
expect(onChange.mock.calls[1][0]).toEqual(exampleValueTwo); | ||
}); | ||
@@ -124,7 +124,7 @@ | ||
test(inputName + " resetValue works and calls onChanging and onChanged", function () { | ||
test(inputName + " resetValue works and calls onChanging and onChange", function () { | ||
var onChanging = jest.fn(); | ||
var onChanged = jest.fn(); | ||
var onChange = jest.fn(); | ||
var wrapper = mount(_react2.default.createElement(Input, _extends({ name: "test", onChanging: onChanging, onChanged: onChanged, value: exampleValueOne, options: options }, props))); | ||
var wrapper = mount(_react2.default.createElement(Input, _extends({ name: "test", onChanging: onChanging, onChange: onChange, value: exampleValueOne, options: options }, props))); | ||
expect(wrapper.instance().getValue()).toEqual(exampleValueOne); | ||
@@ -136,3 +136,3 @@ | ||
onChanging.mockClear(); | ||
onChanged.mockClear(); | ||
onChange.mockClear(); | ||
@@ -143,17 +143,17 @@ wrapper.instance().resetValue(); | ||
expect(onChanging).toHaveBeenCalledTimes(1); | ||
expect(onChanged).toHaveBeenCalledTimes(1); | ||
expect(onChange).toHaveBeenCalledTimes(1); | ||
expect(onChanging).toHaveBeenLastCalledWith(exampleValueOne); | ||
expect(onChanged).toHaveBeenLastCalledWith(exampleValueOne); | ||
expect(onChange).toHaveBeenLastCalledWith(exampleValueOne); | ||
}); | ||
test(inputName + " setValue works and calls onChanging and onChanged", function () { | ||
test(inputName + " setValue works and calls onChanging and onChange", function () { | ||
var onChanging = jest.fn(); | ||
var onChanged = jest.fn(); | ||
var onChange = jest.fn(); | ||
var wrapper = mount(_react2.default.createElement(Input, _extends({ name: "test", onChanging: onChanging, onChanged: onChanged, value: exampleValueOne, options: options }, props))); | ||
var wrapper = mount(_react2.default.createElement(Input, _extends({ name: "test", onChanging: onChanging, onChange: onChange, value: exampleValueOne, options: options }, props))); | ||
expect(wrapper.instance().getValue()).toEqual(exampleValueOne); | ||
onChanging.mockClear(); | ||
onChanged.mockClear(); | ||
onChange.mockClear(); | ||
@@ -165,7 +165,7 @@ wrapper.instance().setValue(exampleValueTwo); | ||
expect(onChanging).toHaveBeenCalledTimes(1); | ||
expect(onChanged).toHaveBeenCalledTimes(1); | ||
expect(onChange).toHaveBeenCalledTimes(1); | ||
expect(onChanging).toHaveBeenLastCalledWith(exampleValueTwo); | ||
expect(onChanged).toHaveBeenLastCalledWith(exampleValueTwo); | ||
expect(onChange).toHaveBeenLastCalledWith(exampleValueTwo); | ||
}); | ||
} |
{ | ||
"name": "composable-form-tests", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "Tests for Composable Form Spec components written in React", | ||
@@ -5,0 +5,0 @@ "author": "Dairy State Designs (http://dairystatedesigns.com/)", |
@@ -39,3 +39,3 @@ # Composable Form Tests | ||
| simulateChanging | OPTIONAL. If your input ever calls `onChanging`, use this function to simulate one user action that will cause it to happen. | | ||
| simulateChanged | REQUIRED. Use this function to simulate one user action that will cause `onChanged` to be called. | | ||
| simulateChanged | REQUIRED. Use this function to simulate one user action that will cause `onChange` to be called. | | ||
| simulateSubmit | OPTIONAL. If your input ever calls `onSubmit`, use this function to simulate one user action that will cause it to happen. | | ||
@@ -42,0 +42,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
13780