import * as assert from 'assert' ; import * as path from 'path' ; import * as vscode from 'vscode' ; import { waitForSonarLintDiagnostics , dumpLogOutput } from '../common/util' ; const sampleFolderLocation = '../../../samples/' ; suite ( 'Extension Test Suite' , ( ) => { vscode . window . showInformationMessage ( 'Start all tests.' ) ; test ( 'Extension should be present' , ( ) => { assert . ok ( vscode . extensions . getExtension ( 'sonarsource.sonarlint-vscode' ) ) ; } ) ; test ( 'should report issue on single js file' , async function ( ) { const ext = vscode . extensions . getExtension ( 'sonarsource.sonarlint-vscode' ) ! ; await ext . activate ( ) ; vscode . commands . executeCommand ( 'SonarLint.ShowSonarLintOutput' ) ; const fileUri = vscode . Uri . file ( path . join ( __dirname , sampleFolderLocation , 'sample-js' , 'main.js' ) ) ; const document = await vscode . workspace . openTextDocument ( fileUri ) ; await vscode . window . showTextDocument ( document ) ; const diags = await waitForSonarLintDiagnostics ( fileUri ) ; dumpLogOutput ( ) ; assert . deepEqual ( diags . length , 1 ) ; assert . equal ( diags [ 0 ] . message , "Remove the declaration of the unused 'i' variable." ) ; vscode . commands . executeCommand ( 'workbench.action.closeActiveEditor' ) ; } ) . timeout ( 60 * 1000 ) ; } ) ;