Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const errors = ReactTestUtils.scryRenderedDOMComponentsWithClass(form, 'usa-input-error-message');
expect(errors.find(input => input.id.includes('root_veteranSocialSecurityNumber'))).to.be.ok;
// Check no-SSN box
const noSSNBox = ReactTestUtils.scryRenderedDOMComponentsWithTag(form, 'input')
.find(input => input.id === 'root_view:noSSN');
ReactTestUtils.Simulate.change(noSSNBox,
{
target: {
checked: true
}
});
// No error is shown for empty SSN input; error is shown for empty file number input
const newErrors = ReactTestUtils.scryRenderedDOMComponentsWithClass(form, 'usa-input-error-message');
expect(newErrors.find(input => input.id.includes('root_veteranSocialSecurityNumber'))).not.to.be.ok;
expect(newErrors.find(input => input.id.includes('root_vaFileNumber'))).to.be.ok;
});
it('should submit with no errors with all required fields filled in', () => {
lab.test('it renders with success state', (done) => {
const props = ObjectAssign({}, defaultProps, {
showSaveSuccess: true
});
const FormEl = React.createElement(Form, props);
const form = ReactTestUtils.renderIntoDocument(FormEl);
const alerts = ReactTestUtils.scryRenderedDOMComponentsWithClass(form, 'alert-success');
Code.expect(alerts).to.have.length(1);
done();
});
it('can cancel 500 callbacks by unmounting why not', (done) => {
const container = document.createElement('div')
const newRendering = render(, container)
const b = scryRenderedDOMComponentsWithClass(newRendering, 'test5')[0]
let i = 0
for (i = 0; i < 500; i++) {
Simulate.click(b)
}
setTimeout(() => unmountComponentAtNode(container), 10)
setTimeout(() => {
expect(window.uglyMutableLeakyVariableTest5).to.equal(0)
setTimeout(done)
}, 500)
})
it('eventually mutates leaky variable', (done) => {
const b = scryRenderedDOMComponentsWithClass(rendering, 'test3')[0]
Simulate.click(b)
expect(window.uglyMutableLeakyVariableTest3).to.equal('none')
setTimeout(() => {
expect(window.uglyMutableLeakyVariableTest3).to.equal('test3')
setTimeout(done)
}, 500)
})
it('accepts an optional crossClassName', () => {
component = TestUtils.renderIntoDocument(<menu>);
const bars = TestUtils.scryRenderedDOMComponentsWithClass(component, 'bm-cross');
expect(bars[0].classList.toString()).to.contain('custom-class');
});
});</menu>
it('doesnt show inner labels if not specified', function() {
var piechart = TestUtils.renderIntoDocument(
);
var labels = TestUtils.scryRenderedDOMComponentsWithClass(piechart, 'rd3-piechart-value');
expect(labels.length).to.equal(0);
});
lab.test('it renders with error state', (done) => {
const root = ReactTestUtils.renderIntoDocument(RootEl);
Store.dispatch({
type: Constants.LOGIN_RESPONSE,
err: new Error('sorry pal'),
response: {
message: 'major fail'
}
});
const alerts = ReactTestUtils.scryRenderedDOMComponentsWithClass(root, 'alert-danger');
Code.expect(alerts).to.have.length(1);
done();
});
});
expect(rdTabBefore[0].className).contain('mySpecialTabBefore');
expect(rdTabBefore[1].className).not.contain('mySpecialTabBefore');
let rdTabAfter = ReactTestUtils.scryRenderedDOMComponentsWithClass(component, 'rdTabAfter');
expect(rdTabAfter[0].className).contain('mySpecialTabAfter');
expect(rdTabAfter[1].className).not.contain('mySpecialTabAfter');
let rdTabTitle = ReactTestUtils.scryRenderedDOMComponentsWithClass(component, 'rdTabTitle');
expect(rdTabTitle[0].className).contain('mySpecialTabTitle');
expect(rdTabTitle[1].className).not.contain('mySpecialTabTitle');
let rdTabBeforeTitle = ReactTestUtils.scryRenderedDOMComponentsWithClass(component, 'rdTabBeforeTitle');
expect(rdTabBeforeTitle[0].className).contain('mySpecialTabBeforeTitle');
expect(rdTabBeforeTitle[1].className).not.contain('mySpecialTabBeforeTitle');
let rdTabAfterTitle = ReactTestUtils.scryRenderedDOMComponentsWithClass(component, 'rdTabAfterTitle');
expect(rdTabAfterTitle[0].className).contain('mySpecialTabAfterTitle');
expect(rdTabAfterTitle[1].className).not.contain('mySpecialTabAfterTitle');
let rdTabActive = ReactTestUtils.findRenderedDOMComponentWithClass(component, 'rdTabActive');
expect(rdTabActive.className).contain('mySpecialTabActive');
let rdTabCloseIcon = ReactTestUtils.scryRenderedDOMComponentsWithClass(component, 'rdTabCloseIcon');
expect(rdTabCloseIcon[0].className).contain('mySpecialTabCloseIcon');
expect(rdTabCloseIcon[1].className).not.contain('mySpecialTabCloseIcon');
});
expect(getLogLength()).toEqual(1);
const experimentComponent2 = TestUtils.renderIntoDocument(
);
expect(TestUtils.scryRenderedDOMComponentsWithClass(
experimentComponent2,
'Variation B'
).length).toBe(0);
//renders the correct variation
expect(TestUtils.scryRenderedDOMComponentsWithClass(
experimentComponent2,
'default'
).length).toBe(1);
expect(getLogLength()).toEqual(1);
});
waitsFor(() => {
return (
ReactTestUtils.scryRenderedDOMComponentsWithClass(this.component, 'emoji-option').length >
0
);
});
runs(() => {