import { resolve , basename , relative , dirname } from "path" ; import klawSync from "klaw-sync" ; import { map , forEach , filter } from "lodash" ; import { existsSync } from "fs" ; import { snapshotTestLSPDiagnostic , toSourcesTestDir , INPUT_FILE_NAME , LSPDiagnosticOptions , } from "./snapshots-utils" ; describe ( `The language server diagnostics capability` , ( ) => { const snapshotTestsDir = toSourcesTestDir ( __dirname ) ; const klawItems = klawSync ( snapshotTestsDir , { nodir : true } ) ; const inputFiles = filter ( klawItems , ( item ) => { return item . path . endsWith ( INPUT_FILE_NAME ) ; } ) ; const testDirs = map ( inputFiles , ( _ ) => dirname ( _ . path ) ) ; forEach ( testDirs , ( dirPath ) => { const dirName = basename ( dirPath ) ; const optionsPath = resolve ( dirPath , "options.js" ) ; let options ; if ( existsSync ( optionsPath ) ) { options = require ( optionsPath ) ; } else { options = { flexEnabled : false } ; } it ( `Can create diagnostic for ${ dirName . replace ( /-/g , " " ) } (${ relative ( snapshotTestsDir , dirPath ) })` , async ( ) => { await snapshotTestLSPDiagnostic ( dirPath , options ) ; } ) ; } ) ; } ) ;