Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('should trigger select', function() {
var input = TestUtils.findRenderedDOMComponentWithTag(
search, 'input'
);
var ratio = {name: 'Patanjali', id: 7, url: '/ramdev/'};
api.setResponse('/api/ratios/search/?q=Patanjali',
JSON.stringify([ratio]));
input.value = 'Patanjali';
TestUtils.Simulate.change(input, {target: {value: 'Patanjali'}});
jest.runAllTimers(); // debounce;
return search.req.then(() => {
TestUtils.Simulate.keyDown(input, {key: "Enter", keyCode: 13, which: 13});
expect(dummy).toBeCalledWith(ratio);
})
});
});
assert(getStyleValue(greenTip, 'visibility') === 'hidden');
// Mouseover to red origin
const red = firstComponent(tree, Origin.WrappedComponent, { name: 'red' }).refs.wrapper;
TestUtils.Simulate.mouseEnter(red);
const redTip = firstComponent(tree, Tooltip.WrappedComponent, { name: 'red' }).refs.tooltip;
assert(getStyleValue(redTip, 'visibility') === 'visible');
assert(redTip.innerText === 'This is a Red tooltip.');
TestUtils.Simulate.mouseLeave(red);
assert(getStyleValue(redTip, 'visibility') === 'hidden');
// Mouseover to both origin
const both = firstComponent(tree, Origin.WrappedComponent, { name: ['green', 'red'] }).refs.wrapper;
TestUtils.Simulate.mouseEnter(both);
assert(getStyleValue(greenTip, 'visibility') === 'visible');
assert(greenTip.innerText === 'This is a Green tooltip.');
assert(getStyleValue(redTip, 'visibility') === 'visible');
assert(redTip.innerText === 'This is a Red tooltip.');
TestUtils.Simulate.mouseLeave(both);
assert(getStyleValue(greenTip, 'visibility') === 'hidden');
assert(getStyleValue(redTip, 'visibility') === 'hidden');
});
});
it('should call the callback if a list element is clicked', function () {
var stub = sinon.stub();
this.component = this.renderComponent({ clickCallback: stub });
var firstListItem = this.component.refs.list.childNodes[0];
TestUtils.Simulate.click(firstListItem);
assert.isTrue(stub.calledOnce);
});
});
it('onBeforeSelect返回false的时候,checkbox不应该被选中', () => {
let component = ReactTestUtils.renderIntoDocument(
rowObj.enable,
onSelect: () => {},
onSelectAll: () => {}
}}
/>
);
let row0checkbox = getTableCell(component, 0, 0).querySelector('input');
let row1checkbox = getTableCell(component, 1, 0).querySelector('input');
ReactTestUtils.Simulate.change(row0checkbox, {target: {checked: true}});
ReactTestUtils.Simulate.change(row1checkbox, {target: {checked: true}});
assert.equal(component.state.selectedRowsObj[0].selected, false);
assert.equal(component.state.selectedRowsObj[1].selected, true);
assert.equal(row0checkbox.checked, false);
assert.equal(row1checkbox.checked, true);
});
it('responds to change', function () {
T.Simulate.change(textarea, {
target: {
value: 'new_value'
}
})
})
})
$.fn.simulate = function(eventName, value) {
if (value) {
this.val(value);
}
TestUtils.Simulate[eventName](this[0]);
};
label="Test"
onClick={onClick}
onMouseOver={onMouseOver}
onMouseLeave={onMouseLeave}
onTouchStart={onTouchStart}
onTouchEnd={onTouchEnd}
/>
);
const buttonNode = findDOMNode(button);
TestUtils.Simulate.click(buttonNode);
expect(onClick).toBeCalled();
TestUtils.Simulate.mouseOver(buttonNode);
TestUtils.Simulate.mouseLeave(buttonNode);
expect(onMouseOver).toBeCalled();
expect(onMouseLeave).toBeCalled();
TestUtils.Simulate.touchStart(buttonNode, { changedTouches: [{}] });
TestUtils.Simulate.touchEnd(buttonNode, { changedTouches: [{}] });
expect(onTouchStart).toBeCalled();
expect(onTouchEnd).toBeCalled();
});
beforeEach(() => {
renderedTest = TestUtils.renderIntoDocument();
checkbox = ReactDOM.findDOMNode(renderedTest.refs.checkbox);
TestUtils.Simulate.change(checkbox, { target: { checked: true } });
});
onTouchStart={onTouchStart}
onTouchEnd={onTouchEnd}
/>
);
const buttonNode = findDOMNode(button);
TestUtils.Simulate.click(buttonNode);
expect(onClick).toBeCalled();
TestUtils.Simulate.mouseOver(buttonNode);
TestUtils.Simulate.mouseLeave(buttonNode);
expect(onMouseOver).toBeCalled();
expect(onMouseLeave).toBeCalled();
TestUtils.Simulate.touchStart(buttonNode, { changedTouches: [{}] });
TestUtils.Simulate.touchEnd(buttonNode, { changedTouches: [{}] });
expect(onTouchStart).toBeCalled();
expect(onTouchEnd).toBeCalled();
});
it("goes to next week on click", () => {
const nextBtn = this.weekView.refs.headerControls.refs.onNextAction
expect(this.weekView.state.startMoment.unix()).toBe(NOW_BUFFER_START.unix());
expect(this.weekView._scrollTime).toBe(NOW_WEEK_START.unix())
ReactTestUtils.Simulate.click(nextBtn);
expect((this.weekView.state.startMoment).unix())
.toBe(moment(NOW_BUFFER_START).add(1, 'week').unix());
expect(this.weekView._scrollTime)
.toBe(moment(NOW_WEEK_START).add(1, 'week').unix());
});