We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
Setting up your legit tests to always use certain middleware is easy:
import TestUtils from 'legit-tests/no-dom'; import {TestMethod} from '../custom/middleware'; function Test(component, options={}){ return TestUtils(component, options) .mixin({ TestMethod }); } export default Test; export { Test };
###TestMethod Call and test React methods
.testMethod(ComponentThing, 'myMethod', function(myMethod){ ... })
.testMethod(ComponentThing, 'getInitialState', function(getInitialState){ ... })
The method is passed to the callback already bound to the component instance.
// ComponentThing is a React class .testMethod(ComponentThing, 'myMethod', function(myMethod){ expect( myMethod() ).to.be('returned value'); })
src:
import _ from 'lodash'; function testMethod(component, methodName, fn){ var method = methodName; var componentName = component.displayName.toLowerCase(); this.find(component); var componentInstance = this.elements[componentName]; var bound = _.bind(component.prototype[methodName], componentInstance); fn(bound); }