Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('types in the input and selects a value', async () => {
const {select, waitForDom} = clientRenderer.render();
const prefix = 'P';
const filteredItems = items.filter(item => item.startsWith(prefix)).join('');
simulate.click(select(autoComp + '_CARET'));
const itemList = bodySelect('LIST')!;
await bodyWaitForDom(() => {
expect(itemList).to.be.present();
expect(itemList.textContent).to.equal(items.join(''));
});
trigger.change(bodySelect(autoCompInput), prefix);
await bodyWaitForDom(() => expect(itemList.textContent).to.equal(filteredItems));
simulate.click(bodySelect('LIST')!.children[0]);
await waitForDom(() => {
expect(select(autoCompDemo + '_TEXT')).to.have.text('You picked: Pancakes');
});
});
});
it('should not call onChange with an invalid date', async () => {
const onChange = sinon.spy();
const {select, waitForDom} = clientRenderer.render();
const datePickerInput = select(datePickerInputId);
trigger.change(datePickerInput!, '2sgsdfsdfw223');
simulate.blur(datePickerInput);
await waitForDom(() => expect(onChange).to.have.not.been.calledOnce);
});
it('calls the onOpenStateChange event when first entering a value', async () => {
const onOpenStateChange = sinon.spy();
const {select, waitForDom} = clientRenderer.render();
await waitForDom(() => expect(select(autoComp)).to.be.present());
trigger.change(bodySelect(autoCompInput), 'M');
await bodyWaitForDom(() => {
expect(onOpenStateChange).to.have.been.calledOnce;
expect(onOpenStateChange).to.have.been.calledWithMatch({value: true});
});
});
});
'and expects the date picker input to have the proper value', async () => {
const {select, waitForDom} = clientRenderer.render();
const datePickerInput = select(datePickerInputId);
trigger.change(datePickerInput!, '2017/02/01');
simulate.keyDown(datePickerInput, {keyCode: keycode('enter')});
await waitForDom(() => expect(select(currentDate)).to.have.text('Wed Feb 01 2017'));
});
public changeDate(value: string): void {
trigger.change(this.input, value);
simulate.blur(this.input);
}