How to use the test-drive-react.trigger.change function in test-drive-react

To help you get started, we’ve selected a few test-drive-react examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github wix-playground / stylable-components / test / components / auto-complete.spec.tsx View on Github external
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');
            });
        });
    });
github wix-playground / stylable-components / test / components / date-picker.spec.tsx View on Github external
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);
    });
github wix-playground / stylable-components / test / components / auto-complete.spec.tsx View on Github external
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});
        });
    });
});
github wix-playground / stylable-components / test / components / date-picker.spec.tsx View on Github external
'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'));
        });
github wix-playground / stylable-components / test-kit / components / date-picker-driver.ts View on Github external
public changeDate(value: string): void {
        trigger.change(this.input, value);
        simulate.blur(this.input);
    }