import * as vscode from 'vscode' ; import * as path from 'path' ; import * as assert from 'assert' ; export let doc ; export let editor ; export let documentEol ; export let platformEol ; /**
 * Activates the extension
 */ export async function activate ( docUri ) { const ext = vscode . extensions . getExtension ( 'standard.vscode-standard' ) ; await ext ?. activate ( ) ; try { doc = await vscode . workspace . openTextDocument ( docUri ) ; editor = await vscode . window . showTextDocument ( doc ) ; await sleep ( 5000 ) ; } catch ( error ) { console . error ( error ) ; } } export async function sleep ( ms ) { return await new Promise ( ( resolve ) => setTimeout ( resolve , ms ) ) ; } export const getDocUri = ( folder , file ) : vscode . Uri => { return vscode . Uri . file ( path . resolve ( __dirname , '..' , '..' , 'testFixture' , folder , file ) ) ; } ; export async function testDiagnostics ( docUri , expectedDiagnostics ) { await activate ( docUri ) ; const actualDiagnostics = vscode . languages . getDiagnostics ( docUri ) ; assert . strictEqual ( actualDiagnostics . length , expectedDiagnostics . length ) ; expectedDiagnostics . forEach ( ( expectedDiagnostic , index ) => { const actualDiagnostic = actualDiagnostics [ index ] ; assert . strictEqual ( actualDiagnostic . message , expectedDiagnostic . message ) ; assert . deepEqual ( actualDiagnostic . range , expectedDiagnostic . range ) ; assert . strictEqual ( actualDiagnostic . severity , expectedDiagnostic . severity ) ; } ) ; }