license import test , { ExecutionContext } from "ava" ; import { NamedCase , UnnamedCase , _cases } from "../cases" ; import { Configuration , defaults } from "../configuration" ; import { Context } from "../context" ; import { fakeSchedulers as _fakeSchedulers } from "../fake" ; import { configure as _configure } from "../marbles" ; export * from "../configuration" ; export * from "../context" ; export * from "../expect" ; export * from "../fake" ; export interface CasesFunction { < T extends UnnamedCase > ( name , func , cases ) : void ; < T extends NamedCase > ( name , func , cases ) : void ; } export type MarblesFunction = ( func : ( m : Context , t : ExecutionContext ) => any ) => any ; export function configure ( configuration ) { const factory = ( t ) => ( { assert : t . truthy . bind ( t ) , assertDeepEqual : t . deepEqual . bind ( t ) , } ) ; const configured = _configure ( ( t ) => ( { ... defaults ( ) , ... factory ( t ) , ... configuration , } ) ) ; const marbles = configured . marbles ; function cases < T extends UnnamedCase > ( name , func , cases ) ; function cases < T extends NamedCase > ( name , func , cases ) ; function cases ( name , func , cases ) { _cases ( ( c ) => { const t = c . only ? test . only : c . skip ? test . skip : test ; t ( `${ name } / ${ c . name }` , marbles ( ( m , t ) => func ( m , c , t ) ) ) ; } , cases ) ; } return { cases , marbles } ; } const { cases , marbles } = configure ( { } ) ; export { cases , marbles } ; export function fakeSchedulers ( fakeTest ) { return _fakeSchedulers ( fakeTest ) ; }