import { AxeReportParameters , ReporterFactory } from 'accessibility-insights-report' ; import { AxeResults } from 'axe-core' ; import { inject , injectable } from 'inversify' ; import { ReportFormat } from 'storage-documents' ; import { iocTypeNames } from '../ioc-types' ; import { AxeResultConverter , AxeResultConverterOptions } from './axe-result-converter' ; import { htmlReportStrings } from './html-report-strings' ; @ injectable ( ) export class AxeResultToHtmlConverter implements AxeResultConverter { public readonly targetReportFormat : ReportFormat = 'html' ; constructor ( @ inject ( iocTypeNames . ReporterFactory ) private readonly reporterFactoryFunc ) { } public convert ( results , options ) { const reporter = this . reporterFactoryFunc ( ) ; const htmlReportParams = { results : results , description : this . createDescription ( results ) , serviceName : htmlReportStrings . serviceName , scanContext : { pageTitle : options . pageTitle , } , } ; return reporter . fromAxeResult ( htmlReportParams ) . asHTML ( ) ; } private createDescription ( results ) { const reportGenerationTime = new Date ( ) ; return `Automated report for accessibility scan of url ${ results . url } completed at ${ reportGenerationTime . toUTCString ( ) }.` ; } }