These are partial typings for the unexpected.js library and some of its dependencies and plugins.
No effort has been made to attempt to type the dynamic nature of the assertions, only the static interfaces have been attempted here
///<reference types="node"/> | |
declare module "httpception" { | |
import * as http from "http"; | |
type Json = | |
| null | |
| boolean | |
| number | |
| string | |
| Json[] | |
| { [prop: string]: Json }; | |
interface Request { | |
method?: string; | |
url?: string; | |
headers?: Record<string, string | number>; | |
body?: Json; | |
} | |
interface Response { | |
statusCode?: number; | |
headers?: Record<string, string | number>; | |
body?: Json; | |
} | |
interface HttpConversation { | |
request?: Request | string; | |
response?: Response; | |
} | |
export default function httpception( | |
conversations: HttpConversation | HttpConversation[] | |
): void; | |
} |
declare module "magicpen" { | |
function magicpen(): magicpen.MagicPen; | |
namespace magicpen { | |
interface MagicPen { | |
/** | |
* @see https://github.com/sunesimonsen/magicpen#textcontent-stylestring | |
*/ | |
text(content: string, ...style: Array<string>): this; | |
/** | |
* @see https://github.com/sunesimonsen/magicpen#appendpen-appendfunction | |
*/ | |
append(pen: this): this; | |
append(fn: (this: this) => void): this; | |
/** | |
* @see https://github.com/sunesimonsen/magicpen#cloneformat | |
*/ | |
clone(): this; | |
/** | |
* @see https://github.com/sunesimonsen/magicpen#aliases | |
*/ | |
space(count: number): this; | |
bold(content: string): this; | |
dim(content: string): this; | |
italic(content: string): this; | |
underline(content: string): this; | |
inverse(content: string): this; | |
hidden(content: string): this; | |
strikeThrough(content: string): this; | |
black(content: string): this; | |
red(content: string): this; | |
green(content: string): this; | |
yellow(content: string): this; | |
blue(content: string): this; | |
magenta(content: string): this; | |
cyan(content: string): this; | |
white(content: string): this; | |
gray(content: string): this; | |
bgBlack(content: string): this; | |
bgRed(content: string): this; | |
bgGreen(content: string): this; | |
bgYellow(content: string): this; | |
bgBlue(content: string): this; | |
bgMagenta(content: string): this; | |
bgCyan(content: string): this; | |
bgWhite(content: string): this; | |
} | |
interface MagicPenConstructor { | |
new (): MagicPen; | |
prototype: MagicPen; | |
} | |
} | |
export = magicpen; | |
} |
These are partial typings for the unexpected.js library and some of its dependencies and plugins.
No effort has been made to attempt to type the dynamic nature of the assertions, only the static interfaces have been attempted here
declare module "unexpected-express" { | |
import { Expect } from "unexpected"; | |
namespace unexpectedExpress { | |
interface UnexpectedExpress { | |
name?: string; | |
version?: string; | |
dependencies?: Array<string>; | |
installInto(expect: Expect): void; | |
} | |
} | |
const unexpectedExpress: unexpectedExpress.UnexpectedExpress; | |
export = unexpectedExpress; | |
} |
declare module "unexpected-sinon"; |
declare module "unexpected" { | |
import * as magicpen from "magicpen"; | |
namespace unexpected { | |
interface Expect { | |
/** | |
* @see http://unexpected.js.org/api/expect/ | |
*/ | |
<A extends Array<unknown> = []>( | |
subject: unknown, | |
assertionName: string, | |
...args: A | |
): Promise<void>; | |
/** | |
* @see http://unexpected.js.org/api/clone/ | |
*/ | |
clone(): this; | |
/** | |
* @see http://unexpected.js.org/api/addAssertion/ | |
*/ | |
addAssertion<T, A extends Array<unknown> = []>( | |
pattern: string, | |
handler: (expect: Expect, subject: T, ...args: A) => void, | |
): this; | |
/** | |
* @see http://unexpected.js.org/api/addType/ | |
*/ | |
addType<T>(typeDefinition: unexpected.TypeDefinition<T>): this; | |
/** | |
* @see http://unexpected.js.org/api/fail/ | |
*/ | |
fail<A extends Array<unknown> = []>(format: string, ...args: A): void; | |
fail<E extends Error>(error: E): void; | |
/** | |
* @see http://unexpected.js.org/api/freeze/ | |
*/ | |
freeze(): this; | |
/** | |
* @see http://unexpected.js.org/api/use/ | |
*/ | |
use(plugin: unexpected.PluginDefinition): this; | |
it(...args: any[]): void; | |
} | |
interface PluginDefinition { | |
name?: string; | |
version?: string; | |
dependencies?: Array<string>; | |
installInto(expect: Expect): void; | |
} | |
interface TypeDefinition<T> { | |
name: string; | |
identify(value: unknown): value is T; | |
base?: string; | |
equal?(a: T, b: T, equal: (a: unknown, b: unknown) => boolean): boolean; | |
inspect?( | |
value: T, | |
depth: number, | |
output: magicpen.MagicPen, | |
inspect: (value: unknown, depth: number) => magicpen.MagicPen, | |
): void; | |
} | |
} | |
const unexpected: unexpected.Expect; | |
export = unexpected; | |
} |