Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
Simulate.focus(this.input.$root);
await when(() => assert(this.dropdown.isOpen, `\nexpected dropdown to be open\n`));
let suggestions = this.dropdown.suggestions();
if (!suggestions || suggestions.length === 0) {
throw new Error('\nthere are no suggestions!\n');
}
let suggestion = suggestions.find((suggestion) => {
return suggestion.text.includes(searchTerm);
});
// for some reason bigtest click doesn't work?
Simulate.click(suggestion.$root);
let tag = suggestion.languageTag;
await when(() =>
assert(
tag.includes(this.input.value),
`\nexpected selection of suggestion to set the input value to the suggestion's language tag.\n`
)
);
await when(() =>
assert(
this.input.valueFromProps === this.input.value,
`\nexpected the selected language tag to set the value on the calling component.
It is possible that the change event has not yet fired\n`
)
it('should unmount when click on the close button', () => {
open();
expect(document.querySelectorAll('.zent-dialog-r-anchor').length).toBe(1);
Simulate.click(document.querySelector('.zent-dialog-r-close'));
jest.runAllTimers();
expect(document.querySelectorAll('.zent-dialog-r-anchor').length).toBe(0);
});
onVisibleChange={v => {
visible = v;
}}
content={content()}
onConfirm={onConfirm}
>
<a>click</a>
);
wrapper.setProps({
visible: true,
});
jest.runAllTimers();
Simulate.click(document.querySelector('.zent-btn-primary'));
jest.runOnlyPendingTimers();
expect(a).toBe(2);
});
const { testApp, dropdownTriggerDomNode } = renderTestApp();
const id = 'test';
const className = 'test';
const dataTest = 'test';
const onClick = smock.stub();
testApp.setState({
id,
className,
'data-test': dataTest,
onClick
});
Simulate.click(dropdownTriggerDomNode);
t.ok(hasClass(dropdownTriggerDomNode, 'dropdown__trigger'), 'has class `dropdown`');
t.ok(hasClass(dropdownTriggerDomNode, 'test'), 'has class `test`');
t.equal(dropdownTriggerDomNode.getAttribute('id'), id, 'passes id prop as an attribute to base element');
t.equal(dropdownTriggerDomNode.getAttribute('data-test'), dataTest, 'passes arbitrary prop as an attribute to base element');
t.equal(onClick.callCount, 1, 'passes event handlers');
testApp.setState({
id: null,
className: null,
onClick: null
});
});
onMouseDown,
onMouseOver,
onMouseLeave,
onTouchStart,
onTouchEnd,
onTouchCancel,
onKeyUp,
onKeyDown,
};
const slider = renderIntoDocument(
);
const sliderNode = findDOMNode(slider);
Simulate.click(sliderNode);
expect(onClick).toBeCalled();
Simulate.mouseOver(sliderNode);
expect(onMouseOver).toBeCalled();
Simulate.mouseLeave(sliderNode);
expect(onMouseLeave).toBeCalled();
Simulate.mouseDown(sliderNode);
expect(onMouseDown).toBeCalled();
Simulate.mouseUp(sliderNode);
expect(onMouseUp).toBeCalled();
Simulate.touchStart(sliderNode);
expect(onTouchStart).toBeCalled();
t.plan(5);
const { testApp, dropdownContentDomNode } = renderTestApp();
const id = 'test';
const className = 'test';
const dataTest = 'test';
const onClick = smock.stub();
testApp.setState({
id,
className,
'data-test': dataTest,
onClick
});
Simulate.click(dropdownContentDomNode);
t.ok(hasClass(dropdownContentDomNode, 'dropdown__content'), 'has class `dropdown`');
t.ok(hasClass(dropdownContentDomNode, 'test'), 'has class `test`');
t.equal(dropdownContentDomNode.getAttribute('id'), id, 'passes id prop as an attribute to base element');
t.equal(dropdownContentDomNode.getAttribute('data-test'), dataTest, 'passes arbitrary prop as an attribute to base element');
t.equal(onClick.callCount, 1, 'passes event handlers');
testApp.setState({
id: null,
className: null,
onClick: null
});
});
onClick={onClick}
onMouseDown={onMouseDown}
onMouseUp={onMouseUp}
onMouseOver={onMouseOver}
onMouseLeave={onMouseLeave}
onTouchStart={onTouchStart}
onTouchEnd={onTouchEnd}
onTouchCancel={onTouchCancel}
>
c
);
const tableColumnNode = scryRenderedDOMComponentsWithTag(table, 'td')[0];
Simulate.click(tableColumnNode);
expect(onClick).toBeCalled();
Simulate.mouseOver(tableColumnNode);
expect(onMouseOver).toBeCalled();
Simulate.mouseLeave(tableColumnNode);
expect(onMouseLeave).toBeCalled();
Simulate.mouseDown(tableColumnNode);
expect(onMouseDown).toBeCalled();
Simulate.mouseUp(tableColumnNode);
expect(onMouseUp).toBeCalled();
Simulate.touchStart(tableColumnNode);
expect(onTouchStart).toBeCalled();
withElement(B, _ => {
t.is(_.querySelector('button')!.innerHTML, '1')
Simulate.click(_.querySelector('button')!)
t.is(_.querySelector('button')!.innerHTML, '2')
})
})
it('binds correct click callbacks', () => {
const onClick = jasmine.createSpy('onClick');
const onEdit = jasmine.createSpy('onEdit');
const item = makeItem('item 1', 0, {}, { onClick, onEdit });
Simulate.click(item);
expect(onClick.calls[0].args[1]).toEqual('item 1');
expect(onClick.calls[0].args[2]).toEqual(0);
Simulate.doubleClick(item);
expect(onEdit.calls[0].args[1]).toEqual('item 1');
expect(onEdit.calls[0].args[2]).toEqual(0);
});