import Test from "../test" ; import { constants } from "../suite" ; import createInterface from "./common" ; const { EVENT_FILE_PRE_REQUIRE } = constants ; param { Suite } suite export function styleInterface ( suite ) { const suites = [ suite ] ; suite . on ( EVENT_FILE_PRE_REQUIRE , function ( context , file , mocha ) { const common = createInterface ( suites , context , mocha ) ; context . before = common . before ; context . after = common . after ; context . beforeEach = common . beforeEach ; context . afterEach = common . afterEach ; context . run = mocha . options . delay && common . runWithSuite ( suite ) ; /**
         * Describe a "suite" with the given `title`.
         */ context . suite = ( options ) => { if ( suites . length > 1 ) { suites . shift ( ) ; } return common . suite . create ( { file , fn : false , ... options , } ) ; } ; /**
         * Exclusive Suite.
         */ context . suite . only = ( title ) => { if ( suites . length > 1 ) { suites . shift ( ) ; } return common . suite . only ( { title : title , file : file , fn : false , } ) ; } ; type TestFunction = ( ) => void | Promise < void > ; /**
         * Describe a specification or test-case
         * with the given `title` and callback `fn`
         * acting as a thunk.
         */ context . test = ( title , description , fn ) => { const test = new Test ( title , description , fn ) ; test . file = file ; suites [ 0 ] . addTest ( test ) ; return test ; } ; /**
         * Exclusive test-case.
         */ context . test . only = ( title , fn ) => common . test . only ( mocha , context . test ( title , fn ) ) ; context . test . skip = common . test . skip ; } ) ; } export const description = "QUnit style" ;