UNPKG

soda-test

Version:

Package for Unit and API tests

73 lines (72 loc) 3.87 kB
/// <reference types="chai" /> import "reflect-metadata"; import { extraInfo } from "./testInfo"; import { targetType, anyFunction } from "./executables"; export { Rewire, createAggregation } from "./rewire"; import { SuperTest, Test } from './supertest'; import { SinonStub as SinonSinonStub, SinonSpy as SinonSinonSpy, SinonFakeTimers as SinonSinonFakeTimers } from 'sinon'; import { FakeTimerInstallOpts } from "@sinonjs/fake-timers"; export { FakeTimerInstallOpts } from '@sinonjs/fake-timers'; export { mapLibraries } from './rewire'; export declare const environment: { [key: string]: string; }; export {} from 'chai-as-promised'; export {} from 'sinon-chai'; export declare const request: (app: any) => SuperTest<Test>; type constractorType = Function; type methodDecorator = (target: targetType, propertyKey: string, descriptor?: PropertyDescriptor) => void; type classDecorator = (constructor: constractorType) => void; export type argumentDecorator = (target: targetType, propertyKey: string | symbol, parameterIndex?: number) => void; type memberDecorator = (prototype: targetType, propName: string) => void; export declare function context(text?: string, extraData?: extraInfo): methodDecorator; export declare function it(text?: string, extraData?: extraInfo): methodDecorator; export declare function comment(text: string, extraData?: extraInfo): methodDecorator; export declare function pending(): methodDecorator; export declare function before(): methodDecorator; export declare function after(): methodDecorator; export declare function beforeEach(): methodDecorator; export declare function afterEach(): methodDecorator; export declare function describe(text: string, extraData?: extraInfo): classDecorator; export declare namespace describe { var mapLibraries: typeof import("./rewire").mapLibraries; } export declare function global(value?: boolean): argumentDecorator; export declare function spy(spyTarget: string | targetType, methodName?: string, memberName?: string): argumentDecorator; interface StubSetterBase<T> { calls: (fakeMethod: anyFunction) => T; returns: (value: unknown) => T; resolves: (value?: unknown) => T; rejects: (err: Error | string) => T; access: (getter?: (() => unknown) | unknown, setter?: (value: unknown) => void) => T; construct: (description: { [method: string]: string; }) => T; } export interface StubDecorator { (target: targetType, propertyKey: string | symbol, parameterIndex?: number): void; } export interface StubSetter extends StubSetterBase<StubDecorator>, StubDecorator { } export type StubCreateSetter = StubSetterBase<SinonStub>; export declare function createStub(stubTarget: string | targetType, methodName: string): StubCreateSetter; export declare function stub(stubTarget?: string | targetType, methodName?: string, memberName?: string): StubSetter; export declare function rewire(libName: string, reload?: boolean): argumentDecorator; export declare function importPrivate(libName: string, methodName?: string): argumentDecorator; export declare function useFakeTimers(config?: number | Date | Partial<FakeTimerInstallOpts>): argumentDecorator; export type SinonFakeTimers = SinonSinonFakeTimers & { atick(ms: number | string): Promise<number>; }; export declare let expect: Chai.ExpectStatic; export type SinonSpy = SinonSinonSpy<unknown[], {}>; export interface SinonStub extends SinonSinonStub<unknown[], {}> { callsFake(stubMethod: anyFunction): SinonStub; } export type SinonSandbox = sinon.SinonSandbox; export declare function sandbox(): memberDecorator; export type Done = (err?: Error) => void; export type TR = void; export type PTR = Promise<TR>; export interface CreatableClass<T1 = void, T2 = void, T3 = void> { new (Arg1: T1, Arg2: T2, Arg3: T3): any; }