How to use the test-drive.expect function in test-drive

To help you get started, we’ve selected a few test-drive 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 / private-state.spec.ts View on Github external
it('returns state of own class if exists', () => {
            const instance = {};
            pState0(instance); // init private state
            expect(pState0.unsafe(instance)).to.equal(pState0(instance))
        });
        it('throws if no state exists', () => {
github wix / wix-react-tools / test / core / class-private-state.spec.ts View on Github external
it('returns true if exists in own class', () => {
                class F {
                }

                pState0(F); // init private state
                expect(pState0.inherited.hasState(F)).to.eql(true);
            });
            it('returns false if no state exists', () => {
github wix / wix-react-tools / test / function-decor / example.spec.ts View on Github external
console.log('called on method with ' + methodArguments[0]);
            const result: string = next(['goodbye']);
            console.log(result);
            return 'wrapped=> ' + result
        }

        const enhanceWithLogMW = functionDecor.middleware(logMW);
        const enhanced = enhanceWithLogMW(original);

        const result: string = enhanced('hello');
        expectLog(
            `called on method with hello`,
            `goodbye`,
            `message printed: goodbye`
        );
        expect(result).to.eql('wrapped=> message printed: goodbye');
    });
github wix / wix-react-tools / test / function-decor / order.spec.ts View on Github external
it('before and after wraps middleware between features', () => {
        const wrapped = ffs1.feature(ffs2.feature(noop));
        wrapped();
        ffs1.expectToHaveBeenCalledOnce();
        ffs2.expectToHaveBeenCalledOnce();

        expect(ffs1.beforeSpy.firstCall.calledBefore(ffs2.middlewareBeforeSpy.firstCall), 'ffs1.beforeSpy -> ffs2.middlewareBeforeSpy').to.equal(true);
        expect(ffs2.beforeSpy.firstCall.calledBefore(ffs1.middlewareBeforeSpy.firstCall), 'ffs2.beforeSpy -> ffs1.middlewareBeforeSpy').to.equal(true);
        expect(ffs1.middlewareAfterSpy.firstCall.calledBefore(ffs2.afterSpy.firstCall), 'ffs1.middlewareAfterSpy -> ffs2.afterSpy').to.equal(true);
        expect(ffs2.middlewareAfterSpy.firstCall.calledBefore(ffs1.afterSpy.firstCall), 'ffs2.middlewareAfterSpy -> ffs1.afterSpy').to.equal(true);
    });
github wix / wix-react-tools / test / core / dev-mode.spec.ts View on Github external
it("devMode.OFF un-sets global config to dev-mode", () => {
            const globalDevMode: boolean | undefined = runInContext(devMode.OFF, () => getGlobalConfig().devMode);
            expect(globalDevMode).to.not.be.ok
        });
    });
github wix / wix-react-tools / test / function-decor / example.spec.ts View on Github external
it('copies fields of the function', () => {
            const func: any = function () {
            };
            func.foo = 'bar';

            const wrapped: any = functionDecor.makeFeature({})(func);

            expect(wrapped.foo).to.eql(func.foo);
        });
    });
github wix / wix-react-tools / test / class-decor / example.spec.ts View on Github external
lines.forEach((val: string, idx: number) => {
            expect(console.log.getCall(idx).args, `call #${idx} argument`).eql([val]);
        });
    }
github wix / wix-react-tools / test / core / class-private-state.spec.ts View on Github external
it('throws if no state exists', () => {
                class F {
                }

                class G extends F {
                }

                expect(() => pState0.inherited.unsafe(G)).to.throw();
            });
            it('returns state of super class if exists', () => {
github wix / wix-react-tools / test / function-decor / function-feature-stub.ts View on Github external
expectToHaveBeenCalledOnce(msg = '') {
        expect(this.beforeSpy, `${msg} : ${this.name}.beforeSpy`).to.have.callCount(1);
        expect(this.middlewareBeforeSpy, `${msg} : ${this.name}.middlewareBeforeSpy`).to.have.callCount(1);
        expect(this.middlewareAfterSpy, `${msg} : ${this.name}.middlewareAfterSpy`).to.have.callCount(1);
        expect(this.afterSpy, `${msg} : ${this.name}.afterSpy`).to.have.callCount(1);
    }
github wix / wix-react-tools / test / core / private-state.spec.ts View on Github external
runInContext(devMode.ON, () => {
                const instance = {};
                pState0(instance).foo = "Hi";

                const desc = Object.getOwnPropertyDescriptor(instance, STATE_DEV_MODE_KEY);
                expect(desc).to.containSubset({writable: false, configurable: false});
            });
        });

test-drive

Opinionated library for writing web component tests

MIT
Latest version published 6 months ago

Package Health Score

63 / 100
Full package analysis

Popular test-drive functions