Add basic types decleration file
This commit is contained in:
parent
a67479f4bc
commit
d1dbd2d5c0
2 changed files with 65 additions and 1 deletions
63
eltro.d.ts
vendored
Normal file
63
eltro.d.ts
vendored
Normal file
|
@ -0,0 +1,63 @@
|
|||
import NodeAssert from 'assert';
|
||||
|
||||
type ExtendedAssert = {
|
||||
notOk(value: unknown, message?: string | Error): void,
|
||||
match(value: string, test: RegExp, message?: string | Error): void,
|
||||
notMatch(value: string, test: RegExp, message?: string | Error): void,
|
||||
throwsAndCatch(fn: () => unknown, message?: string | Error): Error,
|
||||
equalWithMargin(value: number, test: number, margin?: number, message?: string | Error): void,
|
||||
isFulfilled<T>(promise: Promise<T>, message?: string | Error): Promise<T>,
|
||||
isRejected(promise: Promise<unknown>, message?: string | Error): Promise<unknown>,
|
||||
}
|
||||
|
||||
export const assert: typeof NodeAssert & ExtendedAssert
|
||||
|
||||
type Spy = {
|
||||
(): unknown
|
||||
lastCall: null | Array<unknown>
|
||||
called: boolean
|
||||
callCount: number
|
||||
calls: Array<Array<unknown>>
|
||||
findCall(fn: (args: Array<unknown>) => boolean): null | Array<unknown>
|
||||
getCall(index: number): null | Array<unknown>
|
||||
getCallN(index: number): null | Array<unknown>
|
||||
onCall(index: number): Spy
|
||||
onCallN(index: number): Spy
|
||||
reset(): Spy
|
||||
returns(data: unknown): Spy
|
||||
throws(data: unknown): Spy
|
||||
resolves(data: unknown): Spy
|
||||
rejects(data: unknown): Spy
|
||||
returnWith(fn: (...args: unknown[]) => unknown): Spy
|
||||
}
|
||||
|
||||
export function spy(): Spy
|
||||
export function stub(fun?: (...args: unknown[]) => unknown): Spy
|
||||
|
||||
type Test = {
|
||||
timeout(timeout: number): void
|
||||
skip(): void
|
||||
only(): void
|
||||
}
|
||||
|
||||
type TestResult = void | Promise<unknown>
|
||||
|
||||
type Callback = {
|
||||
(): void
|
||||
wrap(fn: () => unknown): void
|
||||
finish(fn: () => unknown): void
|
||||
}
|
||||
|
||||
type Eltro = {
|
||||
before(fn: () => TestResult): Test
|
||||
after(fn: () => TestResult): Test
|
||||
beforeEach(fn: () => TestResult): Test
|
||||
afterEachEach(fn: () => TestResult): Test
|
||||
describe(name: string, fn: () => void)
|
||||
timeout(timeout: number): Eltro
|
||||
skip(): Eltro
|
||||
only(): Eltro
|
||||
test(name: string, func: (cb?: Callback) => TestResult): Test
|
||||
}
|
||||
|
||||
export const Eltro: Eltro
|
|
@ -1,8 +1,9 @@
|
|||
{
|
||||
"name": "eltro",
|
||||
"version": "1.5.0",
|
||||
"version": "1.6.0",
|
||||
"description": "Eltro is a tiny no-dependancy test framework for node",
|
||||
"main": "index.mjs",
|
||||
"types": "eltro.d.ts",
|
||||
"scripts": {
|
||||
"echo": "echo helloworld",
|
||||
"echo:watch": "node cli.mjs --watch test --npm echo",
|
||||
|
|
Loading…
Reference in a new issue