Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

composable-form-tests

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

composable-form-tests - npm Package Compare versions

Comparing version 1.0.1 to 1.1.0

12

CHANGELOG.md
# Composable Form Tests CHANGELOG
## 0.0.1
## 1.1.0
Initial release
Support React 16 or 17 for the peer dependency
## 1.0.1
Move "react" to a peer dependency
## 1.0.0

@@ -11,4 +15,4 @@

## 1.0.1
## 0.0.1
Move "react" to a peer dependency
Initial release

@@ -1,2 +0,2 @@

'use strict';
"use strict";

@@ -6,12 +6,11 @@ Object.defineProperty(exports, "__esModule", {

});
var _testInput = require('./testInput');
Object.defineProperty(exports, 'testInput', {
Object.defineProperty(exports, "testInput", {
enumerable: true,
get: function get() {
return _interopRequireDefault(_testInput).default;
return _testInput.default;
}
});
var _testInput = _interopRequireDefault(require("./testInput"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -6,13 +6,10 @@ "use strict";

});
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
exports.default = testInput;
var _react = require("react");
var _react = _interopRequireDefault(require("react"));
var _react2 = _interopRequireDefault(_react);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
// This function takes some config info allowing you to customize to the input being tested

@@ -35,41 +32,39 @@ // and then runs tests for it to be sure that it matches the Composable Forms Input Spec

testSetValue = _ref.testSetValue;
var inputName = Input.name;
test(inputName + " has isFormInput static property", function () {
test("".concat(inputName, " has isFormInput static property"), function () {
expect(Input.isFormInput).toBe(true);
});
test(inputName + " must not set a default value for \"value\" prop", function () {
test("".concat(inputName, " must not set a default value for \"value\" prop"), function () {
expect(Input.defaultProps && Input.defaultProps.value).toBe(undefined);
});
test(inputName + " must not set a default value for \"errors\" prop", function () {
test("".concat(inputName, " must not set a default value for \"errors\" prop"), function () {
expect(Input.defaultProps && Input.defaultProps.errors).toBe(undefined);
});
test(inputName + " calls onChanging followed by onChange before initial mount", function () {
test("".concat(inputName, " calls onChanging followed by onChange before initial mount"), function () {
var onChanging = jest.fn();
var onChange = jest.fn();
mount(_react2.default.createElement(Input, _extends({ name: "test", onChanging: onChanging, onChange: onChange, options: options }, props)));
mount( /*#__PURE__*/_react.default.createElement(Input, _extends({
name: "test",
onChanging: onChanging,
onChange: onChange,
options: options
}, props)));
expect(onChanging).toHaveBeenCalledTimes(1);
expect(onChange).toHaveBeenCalledTimes(1);
expect(onChanging).toHaveBeenLastCalledWith(defaultValue);
expect(onChange).toHaveBeenLastCalledWith(defaultValue);
});
test(inputName + " calls onChanging and onChange", function () {
test("".concat(inputName, " calls onChanging and onChange"), function () {
var onChanging = jest.fn();
var onChange = jest.fn();
var wrapper = mount(_react2.default.createElement(Input, _extends({ name: "test", onChanging: onChanging, onChange: onChange, options: options }, props)));
var wrapper = mount( /*#__PURE__*/_react.default.createElement(Input, _extends({
name: "test",
onChanging: onChanging,
onChange: onChange,
options: options
}, props)));
onChanging.mockClear();
onChange.mockClear();
onChange.mockClear(); // Inputs need not have a way of "changing" but must call only onChanging
// and not onChange if they do.
// Inputs need not have a way of "changing" but must call only onChanging
// and not onChange if they do.
if (typeof simulateChanging === 'function') {

@@ -86,14 +81,17 @@ simulateChanging(wrapper, exampleValueOne);

});
test(inputName + " calls onChanging followed by onChange when the value prop changes", function () {
test("".concat(inputName, " calls onChanging followed by onChange when the value prop changes"), function () {
var onChanging = jest.fn();
var onChange = jest.fn();
var wrapper = mount(_react2.default.createElement(Input, _extends({ name: "test", onChanging: onChanging, onChange: onChange, value: exampleValueOne, options: options }, props)));
wrapper.setProps({ value: exampleValueTwo });
var wrapper = mount( /*#__PURE__*/_react.default.createElement(Input, _extends({
name: "test",
onChanging: onChanging,
onChange: onChange,
value: exampleValueOne,
options: options
}, props)));
wrapper.setProps({
value: exampleValueTwo
});
expect(onChanging).toHaveBeenCalledTimes(2);
expect(onChange).toHaveBeenCalledTimes(2);
expect(onChanging.mock.calls[0][0]).toEqual(exampleValueOne);

@@ -106,8 +104,10 @@ expect(onChange.mock.calls[0][0]).toEqual(exampleValueOne);

if (typeof simulateSubmit === 'function') {
test(inputName + " calls onSubmit", function () {
test("".concat(inputName, " calls onSubmit"), function () {
var onSubmit = jest.fn();
var wrapper = mount(_react2.default.createElement(Input, _extends({ name: "test", onSubmit: onSubmit, options: options }, props)));
var wrapper = mount( /*#__PURE__*/_react.default.createElement(Input, _extends({
name: "test",
onSubmit: onSubmit,
options: options
}, props)));
simulateSubmit(wrapper);
expect(onSubmit).toHaveBeenCalledTimes(1);

@@ -118,6 +118,9 @@ });

if (testGetValue === true) {
test(inputName + " getValue", function () {
var wrapper = mount(_react2.default.createElement(Input, _extends({ name: "test", value: exampleValueOne, options: options }, props)));
test("".concat(inputName, " getValue"), function () {
var wrapper = mount( /*#__PURE__*/_react.default.createElement(Input, _extends({
name: "test",
value: exampleValueOne,
options: options
}, props))); // Inputs can optionally have an getValue method
// Inputs can optionally have an getValue method
if (typeof wrapper.instance().getValue !== 'function') {

@@ -129,6 +132,6 @@ expect(true).toBe(true);

expect(wrapper.instance().getValue()).toEqual(exampleValueOne);
wrapper.setProps({ value: exampleValueTwo });
wrapper.setProps({
value: exampleValueTwo
});
expect(wrapper.instance().getValue()).toEqual(exampleValueTwo);
simulateChanged(wrapper, exampleValueOne);

@@ -140,6 +143,9 @@ expect(wrapper.instance().getValue()).toEqual(exampleValueOne);

if (testIsDirty === true) {
test(inputName + " isDirty", function () {
var wrapper = mount(_react2.default.createElement(Input, _extends({ name: "test", value: exampleValueOne, options: options }, props)));
test("".concat(inputName, " isDirty"), function () {
var wrapper = mount( /*#__PURE__*/_react.default.createElement(Input, _extends({
name: "test",
value: exampleValueOne,
options: options
}, props))); // Inputs can optionally have an isDirty method
// Inputs can optionally have an isDirty method
if (typeof wrapper.instance().isDirty !== 'function') {

@@ -150,8 +156,8 @@ expect(true).toBe(true);

expect(wrapper.instance().isDirty()).toBe(false);
expect(wrapper.instance().isDirty()).toBe(false); // Should only be true if changed by user rather than by prop
// Should only be true if changed by user rather than by prop
wrapper.setProps({ value: exampleValueTwo });
wrapper.setProps({
value: exampleValueTwo
});
expect(wrapper.instance().isDirty()).toBe(false);
simulateChanged(wrapper, exampleValueOne);

@@ -163,9 +169,13 @@ expect(wrapper.instance().isDirty()).toBe(true);

if (testResetValue === true) {
test(inputName + " resetValue works and calls onChanging and onChange", function () {
test("".concat(inputName, " resetValue works and calls onChanging and onChange"), function () {
var onChanging = jest.fn();
var onChange = jest.fn();
var wrapper = mount( /*#__PURE__*/_react.default.createElement(Input, _extends({
name: "test",
onChanging: onChanging,
onChange: onChange,
value: exampleValueOne,
options: options
}, props))); // Inputs can optionally have an getValue and resetValue methods
var wrapper = mount(_react2.default.createElement(Input, _extends({ name: "test", onChanging: onChanging, onChange: onChange, value: exampleValueOne, options: options }, props)));
// Inputs can optionally have an getValue and resetValue methods
if (typeof wrapper.instance().getValue !== 'function' || typeof wrapper.instance().resetValue !== 'function') {

@@ -177,15 +187,10 @@ expect(true).toBe(true);

expect(wrapper.instance().getValue()).toEqual(exampleValueOne);
simulateChanged(wrapper, exampleValueTwo);
expect(wrapper.instance().getValue()).toEqual(exampleValueTwo);
onChanging.mockClear();
onChange.mockClear();
wrapper.instance().resetValue();
expect(wrapper.instance().getValue()).toEqual(exampleValueOne);
expect(onChanging).toHaveBeenCalledTimes(1);
expect(onChange).toHaveBeenCalledTimes(1);
expect(onChanging).toHaveBeenLastCalledWith(exampleValueOne);

@@ -197,9 +202,13 @@ expect(onChange).toHaveBeenLastCalledWith(exampleValueOne);

if (testSetValue === true) {
test(inputName + " setValue works and calls onChanging and onChange", function () {
test("".concat(inputName, " setValue works and calls onChanging and onChange"), function () {
var onChanging = jest.fn();
var onChange = jest.fn();
var wrapper = mount( /*#__PURE__*/_react.default.createElement(Input, _extends({
name: "test",
onChanging: onChanging,
onChange: onChange,
value: exampleValueOne,
options: options
}, props))); // Inputs can optionally have getValue and setValue methods
var wrapper = mount(_react2.default.createElement(Input, _extends({ name: "test", onChanging: onChanging, onChange: onChange, value: exampleValueOne, options: options }, props)));
// Inputs can optionally have getValue and setValue methods
if (typeof wrapper.instance().getValue !== 'function' || typeof wrapper.instance().setValue !== 'function') {

@@ -211,10 +220,7 @@ expect(true).toBe(true);

expect(wrapper.instance().getValue()).toEqual(exampleValueOne);
onChanging.mockClear();
onChange.mockClear();
wrapper.instance().setValue(exampleValueTwo);
expect(wrapper.instance().getValue()).toEqual(exampleValueTwo);
expect(wrapper.instance().getValue()).toEqual(exampleValueTwo); // Inputs can optionally have an isDirty method
// Inputs can optionally have an isDirty method
if (typeof wrapper.instance().isDirty === 'function') {

@@ -226,3 +232,2 @@ expect(wrapper.instance().isDirty()).toBe(true);

expect(onChange).toHaveBeenCalledTimes(1);
expect(onChanging).toHaveBeenLastCalledWith(exampleValueTwo);

@@ -229,0 +234,0 @@ expect(onChange).toHaveBeenLastCalledWith(exampleValueTwo);

{
"name": "composable-form-tests",
"version": "1.0.1",
"version": "1.1.0",
"description": "Tests for Composable Form Spec components written in React",

@@ -25,14 +25,22 @@ "author": "Dairy State Designs (http://dairystatedesigns.com/)",

"lint": "eslint .",
"prepare": "npm run lint"
"prepublishOnly": "npm run lint"
},
"babel": {
"presets": [
"es2015",
"stage-0",
"react"
[
"@babel/preset-env",
{
"targets": "defaults"
}
],
"@babel/preset-react"
]
},
"eslintConfig": {
"extends": "airbnb",
"parser": "babel-eslint",
"extends": [
"airbnb-base",
"plugin:jsx-a11y/recommended",
"plugin:react/recommended"
],
"parser": "@babel/eslint-parser",
"env": {

@@ -42,2 +50,7 @@ "browser": true,

},
"settings": {
"react": {
"version": "detect"
}
},
"rules": {

@@ -70,18 +83,22 @@ "arrow-body-style": 0,

"devDependencies": {
"babel-cli": "^6.24.1",
"babel-eslint": "^7.2.3",
"babel-jest": "^21.2.0",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",
"babel-preset-stage-0": "^6.24.1",
"babel-register": "^6.24.1",
"eslint": "^4.4.1",
"eslint-config-airbnb": "^15.1.0",
"eslint-plugin-import": "^2.7.0",
"eslint-plugin-jsx-a11y": "^5.1.1",
"eslint-plugin-react": "^7.2.0"
"@babel/cli": "^7.13.14",
"@babel/core": "^7.16.0",
"@babel/eslint-parser": "^7.16.3",
"@babel/plugin-proposal-class-properties": "^7.16.0",
"@babel/plugin-proposal-object-rest-spread": "^7.16.0",
"@babel/polyfill": "^7.12.1",
"@babel/preset-env": "^7.16.0",
"@babel/preset-react": "^7.16.0",
"@babel/register": "^7.16.0",
"babel-core": "7.0.0-bridge.0",
"babel-plugin-add-module-exports": "^1.0.4",
"eslint": "^8.2.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-plugin-import": "^2.25.3",
"eslint-plugin-jsx-a11y": "^6.5.1",
"eslint-plugin-react": "^7.27.0"
},
"peerDependencies": {
"react": "^16.0.0"
"react": "^16.0.0 || ^17.0.0"
}
}

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc