Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
composable-form-tests
Advanced tools
Exposes functions that test your React components to ensure they correctly implement the Composable Form Spec. Assumes a Jest test environment and requires a peer dev dependency of enzyme
.
$ npm i --save-dev composable-form-tests jest-cli babel-jest enzyme
In your input tests file, which will be run by Jest:
import React from 'react';
import { mount } from 'enzyme';
import { testInput } from 'composable-form-tests';
import MyInputComponent from './MyInputComponent';
testInput({
component: MyInputComponent,
mount,
...<other options>
});
component | REQUIRED. The component class that you are testing, which you intend to conform to the Composable Form "Input" Specification |
---|---|
defaultValue | REQUIRED. The value that your component has when neither the user nor the containing Form passes in a value prop |
exampleValueOne | REQUIRED. A value that would make sense for your input. Must be different from the defaultValue and from exampleValueTwo |
exampleValueTwo | REQUIRED. A value that would make sense for your input. Must be different from exampleValueTwo . |
mount | REQUIRED. The mount function imported from enzyme package |
options | OPTIONAL. If your input takes options, the options array. |
props | OPTIONAL. A props object that should be used as props on the input for all 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. |
simulateSubmit | OPTIONAL. If your input ever calls onSubmit , use this function to simulate one user action that will cause it to happen. |
import React from 'react';
import { mount } from 'enzyme';
import { testInput } from 'composable-form-tests';
import Input from './Input';
testInput({
component: Input,
defaultValue: null,
exampleValueOne: 'ONE',
exampleValueTwo: 'TWO',
mount,
simulateChanging(wrapper, value) {
// Refer to Enzyme documentation
wrapper.find('input').simulate('change', { target: { value } });
},
simulateChanged(wrapper, value) {
// Refer to Enzyme documentation
wrapper.find('input').simulate('blur', { target: { value } });
},
simulateSubmit(wrapper) {
// Refer to Enzyme documentation
wrapper.find('input').simulate('keypress', { which: 13 });
},
});
import React from 'react';
import { mount } from 'enzyme';
import { testInput } from 'composable-form-tests';
import SelectInput from './SelectInput';
testInput({
component: SelectInput,
defaultValue: null,
exampleValueOne: 'a',
exampleValueTwo: 'b',
mount,
options: [
{ label: 'A', value: 'a' },
{ label: 'B', value: 'b' },
{ label: 'C', value: 'c' },
],
simulateChanged(wrapper, value) {
// Refer to Enzyme documentation
wrapper.find('select').simulate('change', { target: { value } });
},
});
0.0.1
Initial release
FAQs
Tests for Composable Form Spec components written in React
The npm package composable-form-tests receives a total of 1 weekly downloads. As such, composable-form-tests popularity was classified as not popular.
We found that composable-form-tests demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.