Skip to content

Commit

Permalink
fix: fix brittle types (#385)
Browse files Browse the repository at this point in the history
  • Loading branch information
gmaclennan authored Nov 23, 2023
1 parent 90bcb82 commit 82d1d05
Showing 1 changed file with 27 additions and 30 deletions.
57 changes: 27 additions & 30 deletions types/brittle.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,43 +47,40 @@ declare module 'brittle' {
timeout(ms: number): void
comment(message: string): void
end(): void
test(
test: TestFn
}

type TestCallback = (t: TestInstance) => void | Promise<void>

interface TestFn {
// The brittle docs suggest the return value is `Promise<boolean>` but this is not the case.
(
name: string,
options: TestOptions,
callback: (t: TestInstance) => void | Promise<void>
): Promise<boolean>
test(
): Promise<void>
(
name: string,
callback: (t: TestInstance) => void | Promise<void>
): Promise<boolean>
test(name: string, options: TestOptions): TestInstance
test(options: TestOptions): TestInstance
): Promise<void>
(callback: (t: TestInstance) => void | Promise<void>): Promise<void>
(name: string, options: TestOptions): TestInstance
(name: string): TestInstance
(): TestInstance
// The docs suggest the below is possible, but it isn't
// (options: TestOptions): TestInstance
}

type TestCallback = (t: TestInstance) => void | Promise<void>
interface Test extends TestFn {
test: Test
solo: TestFn
skip: TestFn
}

function test(
name: string,
options: TestOptions,
callback: TestCallback
): Promise<boolean>
function test(name: string, callback: TestCallback): Promise<boolean>
function test(name: string, options: TestOptions): TestInstance
function test(options: TestOptions): TestInstance
function solo(
name: string,
options: TestOptions,
callback: TestCallback
): Promise<boolean>
function solo(name: string, callback: TestCallback): Promise<boolean>
function solo(options: TestOptions): TestInstance
function skip(
name: string,
options: TestOptions,
callback: TestCallback
): Promise<boolean>
function skip(name: string, callback: TestCallback): void
function configure(options: TestOptions): void
export const solo: TestFn
export const skip: TestFn
export const test: Test
export function configure(options: TestOptions): void

export { test, solo, skip, configure }
export default test
}

0 comments on commit 82d1d05

Please sign in to comment.