import * as assert from "assert" ; import { join } from "path" ; import { commands , extensions , languages , StatusBarItem , Uri , window , workspace , Extension , } from "vscode" ; suite ( "code-coverage" , function ( ) { this . timeout ( 10000 ) ; const exampleWorkspace = join ( __dirname , "../../../" , "example" ) ; const exampleWorkspaceUri = Uri . file ( exampleWorkspace ) ; const exampleIndexUri = Uri . file ( join ( exampleWorkspace , "index.ts" ) ) ; let extension ; let onCommand ; setup ( async ( ) => { await commands . executeCommand ( "vscode.openFolder" , exampleWorkspaceUri ) ; const doc = await workspace . openTextDocument ( exampleIndexUri ) ; await window . showTextDocument ( doc ) ; extension = extensions . getExtension ( "markis.code-coverage" ) ; onCommand = extension ?. exports . onCommand ; } ) ; teardown ( async ( ) => { commands . executeCommand ( "workbench.action.closeActiveEditor" ) ; } ) ; test ( "check diagnostics exist" , async ( ) => { const diagnostics = languages . getDiagnostics ( exampleIndexUri ) ; assert . strictEqual ( diagnostics . length , 1 ) ; assert . strictEqual ( diagnostics [ 0 ] . range . start . line , 5 ) ; } ) ; test ( "check status bar" , async ( ) => { const statusBar = extension ?. exports . statusBar ; assert . ok ( statusBar . text ) ; assert . ok ( statusBar . text . includes ( "3/4" ) ) ; } ) ; test ( "test commands hide coverage" , async ( ) => { assert . strictEqual ( languages . getDiagnostics ( exampleIndexUri ) . length , 1 ) ; await onCommand ( "code-coverage.hide" ) ; assert . strictEqual ( languages . getDiagnostics ( exampleIndexUri ) . length , 0 ) ; } ) ; test ( "test commands show coverage" , async ( ) => { await onCommand ( "code-coverage.show" ) ; assert . strictEqual ( languages . getDiagnostics ( exampleIndexUri ) . length , 1 ) ; } ) ; } ) ;