react-unit-test-generator
Version:
react-unit-test-generator is a helper for writing unit tests for React apps. Its main goal is to automatically generate a suite of the most common test cases for a given component.
22 lines (18 loc) • 682 B
JavaScript
import testPropMethod from './buttons/testPropMethod';
import testInstanceMethod from './buttons/testInstanceMethod';
import { noIdentifierSpecified, noInlineMethods, noMethodSpecified } from './warnings';
export default function onClickHandlers(
element,
boundedMethod,
testProps,
action = 'click',
hasPositiveAssertion = true,
) {
if (!element.identifier) {
return noIdentifierSpecified(element);
}
if (testProps && testProps[boundedMethod]) {
return testPropMethod(element, boundedMethod, testProps, action, hasPositiveAssertion);
}
return testInstanceMethod(testProps, element, boundedMethod, action, hasPositiveAssertion);
}