license import { Spec } from './spec.js' ; import { Reporter , ReporterEvent } from './reporter.js' ; import { Fixturable } from './mixins/fixturable.js' ; import { spy } from './helpers/spy.js' ; import '../../../chai/chai.js' ; const spec = new ( Fixturable ( Spec ) ) ( ) ; const { expect } = ( self as any ) . chai ; const { describe , it , before } = spec ; describe ( 'Reporter' , ( ) => { describe ( 'when extended' , ( ) => { before ( ( context ) => { class TestReporter extends Reporter { events : { event : ReporterEvent ; args : any [ ] ; } [ ] = [ ] ; reporter ( event , ... args ) { this . events . push ( { event , args } ) ; super . report ( event , ... args ) ; } } Object . keys ( ReporterEvent ) . forEach ( ( key ) => { const event = ( ReporterEvent as any ) [ key ] ; spy ( TestReporter . prototype , `on${ event }` ) ; } ) ; return { ... context , TestReporter } ; } ) ; describe ( 'when reporting an event' , ( ) => { it ( 'invokes the corresponding callback' , ( { TestReporter } ) => { const reporter = new TestReporter ( ) ; reporter . report ( ReporterEvent . testStart ) ; expect ( reporter . onTestStart . callCount ) . to . be . equal ( 1 ) ; } ) ; it ( 'forwards arguments to the callback' , ( { TestReporter } ) => { const reporter = new TestReporter ( ) ; reporter . report ( ReporterEvent . specStart , 'foo' ) ; expect ( reporter . onSpecStart . args ) . to . be . eql ( [ [ 'foo' ] ] ) ; } ) ; } ) ; } ) ; } ) ; export const reporterSpec = spec ;