import { Rule } from "@siteimprove/alfa-act" ; import { Asserter , Handler } from "@siteimprove/alfa-assert" ; import { Future } from "@siteimprove/alfa-future" ; import { Mapper } from "@siteimprove/alfa-mapper" ; declare global { namespace jest { interface Matchers < R , T > { toBeAccessible ( ) : Promise < void > ; } } } public export namespace Jest { export function createPlugin < I , J , T = unknown , Q = never , S = T > ( transform , rules , handlers = [ ] , options = { } ) { const asserter = Asserter . of ( rules , handlers , options ) ; expect . extend ( { async toBeAccessible ( value ) { const input = await transform ( value ) ; const result = await asserter . expect ( input ) . to . be . accessible ( ) ; const message = result . isOk ( ) ? result . get ( ) : result . getErr ( ) ; return { pass : result . isOk ( ) , message : ( ) => this . utils . matcherHint ( "toBeAccessible" , "received" , "" , { isNot : this . isNot , } ) + " but " + message , } ; } , } ) ; } }