Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
lab.test('it handles a submit event', (done) => {
stub.Actions.createNew = function () {
done();
};
const FormEl = React.createElement(Form, defaultProps);
const form = ReactTestUtils.renderIntoDocument(FormEl);
const formTag = ReactTestUtils.findRenderedDOMComponentWithTag(form, 'form');
ReactTestUtils.Simulate.submit(formTag);
});
it('should update style and className on mouseLeave', function () {
const span = ReactTestUtils.findRenderedDOMComponentWithTag(component, 'span');
ReactTestUtils.Simulate.mouseLeave(span);
expect(ReactDom.findDOMNode(span).classList.contains('hover')).to.be.equal(false);
expect(ReactDom.findDOMNode(span).style.color).to.be.equal('red');
});
});
it('should render children', () => {
const instance = ReactTestUtils.renderIntoDocument(
<strong>Content</strong>
);
assert.ok(
ReactTestUtils.findRenderedDOMComponentWithTag(instance, 'strong')
);
});
});
lab.test('it renders with loading state', (done) => {
const FormEl = React.createElement(Form, {});
const form = ReactTestUtils.renderIntoDocument(FormEl);
Store.dispatch({
type: Constants.SEND_MESSAGE
});
const button = ReactTestUtils.findRenderedDOMComponentWithTag(form, 'button');
Code.expect(button.disabled).to.be.true();
done();
});
[Form, Fieldset].forEach((Container) => {
const TestControl = Control[controlType];
const app = testRender(
, store);
const input = TestUtils.findRenderedDOMComponentWithTag(app,
controlType === 'textarea' ? 'textarea' : 'input');
it(`(${controlType}) should resolve a partial model ${label}`, () => {
assert.equal(input.value, expected);
});
});
});
it('renders dropdown toggle button', () => {
const instance = ReactTestUtils.renderIntoDocument(simpleDropdown);
const buttonNode = ReactTestUtils.findRenderedDOMComponentWithTag(
instance,
'BUTTON'
);
buttonNode.tagName.should.equal('BUTTON');
buttonNode.className.should.match(/\bbtn[ $]/);
buttonNode.className.should.match(/\bbtn-default\b/);
buttonNode.className.should.match(/\bdropdown-toggle\b/);
buttonNode.getAttribute('type').should.equal('button');
buttonNode.getAttribute('aria-expanded').should.equal('false');
buttonNode.getAttribute('id').should.be.ok;
});
lab.test('it handles a submit event', (done) => {
const props = Object.assign({}, defaultProps, {
saveAction: function () {
done();
}
});
const FormEl = React.createElement(Form, props);
const form = ReactTestUtils.renderIntoDocument(FormEl);
const formTag = ReactTestUtils.findRenderedDOMComponentWithTag(form, 'form');
ReactTestUtils.Simulate.submit(formTag);
});
it('should support a boolean and show if truthy', () => {
const form = renderErrorsWithShow(true);
const input = TestUtils.findRenderedDOMComponentWithTag(form, 'input');
assert.lengthOf(TestUtils.scryRenderedDOMComponentsWithTag(form, 'span'), 1);
});
it('should have an empty `aria-label` when the `alt` attribute does not exist', () => {
const superImage = TestUtils.renderIntoDocument();
const node = TestUtils.findRenderedDOMComponentWithTag(superImage, 'div');
assert(node.hasAttribute('aria-label'));
});
test: modelReducer('test', initialState),
});
const field = TestUtils.renderIntoDocument(
val.length > 8 && 'too long',
valid: (val) => val !== 'valid' && 'not valid',
}}
/>
);
const control = TestUtils.findRenderedDOMComponentWithTag(field, 'input');
control.value = 'valid';
TestUtils.Simulate.change(control);
assert.deepEqual(
store.getState().testForm.foo.errors,
{
length: false,
valid: false,
});
control.value = 'invalid string';
TestUtils.Simulate.change(control);