How to use the test-drive-react.sinon.spy 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 / wix-react-tools / test / core / functional.spec.ts View on Github external
it('calls the two handlers with the arguments provided', () => {
        const spy1 = sinon.spy();
        const spy2 = sinon.spy();
        const merged = serialize(spy1, spy2);

        // not call handlers in merging phase
        expect(spy1).to.have.callCount(0);
        expect(spy2).to.have.callCount(0);

        merged(...ARGS);
        // call handlers when calling merged function
        expect(spy1).to.have.callCount(1);
        expect(spy1).to.have.calledWithExactly(...ARGS);
        expect(spy2).to.have.callCount(1);
        expect(spy2).to.have.calledWithExactly(...ARGS);
    });
github wix / wix-react-tools / test / function-decor / warnings.spec.ts View on Github external
beforeEach("replace console.warn with spy", () => {
        console.warn = sinon.spy();
    });
github wix-playground / stylable-components / test / components / global-event.spec.tsx View on Github external
it('should call all appropriate handlers', () => {
            const onMouseDown = sinon.spy();
            const onMouseMove = sinon.spy();
            const onMouseUp = sinon.spy();

            clientRenderer.render(
                
            );

            windowStub.simulate('mousedown');
            windowStub.simulate('mousemove');
            windowStub.simulate('mouseup');

            expect(onMouseDown).to.have.been.calledBefore(onMouseMove);
            expect(onMouseMove).to.have.been.calledBefore(onMouseUp);
        });
github wix-playground / stylable-components / test / components / global-event.spec.tsx View on Github external
it('should call new handler but not the old one', () => {
            const originalListener = sinon.spy();
            const newListener = sinon.spy();

            const fixture = clientRenderer.render(
                
            ).result as Fixture;
            fixture.setState({listener: newListener});

            windowStub.simulate('click');

            expect(originalListener).not.to.have.been.called;
            expect(newListener).to.have.been.calledOnce;
        });
github wix / wix-react-tools / test / react-component-features / disposable-feature.spec.tsx View on Github external
it('called on unmount', () => {
        const spy = sinon.spy();
        const {container} = clientRenderer.render(<div>);

        clientRenderer.render(<div></div>, container);
        expect(spy).to.have.callCount(0);

        clientRenderer.render(<div>, container);
        expect(spy).to.have.callCount(1);
    });
});</div></div>
github wix-playground / stylable-components / test / components / drop-down.spec.tsx View on Github external
it('invokes the onClick when dropdown label is clicked', () =&gt; {
        const onClick = sinon.spy();
        const {select} = clientRenderer.render();
        simulate.click(select(dropDown, input));

        return waitFor(() =&gt; expect(onClick).to.have.been.calledOnce);
    });
github wix-playground / stylable-components / test / components / toggle.spec.tsx View on Github external
beforeEach(() =&gt; {
            onChange = sinon.spy();
            renderer = clientRenderer.render();
        });
        it('should not have input underhood', function() {
github wix / wix-react-tools / test / react-decor / react-decor-function.spec.tsx View on Github external
beforeEach("replace console.warn with spy", () => {
            _console.warn = sinon.spy();
        });
github wix-playground / stylable-components / test / components / slider.spec.tsx View on Github external
beforeEach(() =&gt; {
            onChange = sinon.spy();
            const rendered = clientRenderer.render(
                
            );
            select = rendered.select;
            waitForDom = rendered.waitForDom;
        });
github wix / wix-react-tools / test / class-decor / inheritance.spec.ts View on Github external
beforeEach('init Base class', () => {
            first = sinon.spy();
            last = sinon.spy();
            userConstructorSpy = sinon.spy();
        });