import * as assert from "assert" ; import * as vscode from "vscode" ; import PreviewManager from "../../src/PreviewManager" ; import vscodeUtils from "../../src/vscodeUtilities" ; import { EOL } from "os" ; /**
 * this suite tests both PreviewManager and pythonPanelPreview
 * by activating funcs in PreviewManager and looking at html rendered by pythonPanelPreview
 */ suite ( "PreviewManager and pythonPanelPreview Tests" , ( ) => { const arepl = vscode . extensions . getExtension ( "almenon.arepl" ) ! ; let editor ; let panel ; let previewManager ; const mockContext = { asAbsolutePath : ( file ) => { return __dirname + "/" + file ; } , extensionPath : arepl . extensionPath , } ; suiteSetup ( function ( done ) { vscodeUtils . newUnsavedPythonDoc ( "" ) . then ( ( newEditor ) => { editor = newEditor ; previewManager = new PreviewManager ( mockContext ) ; previewManager . startArepl ( editor ) . then ( ( promiseResults ) => { panel = promiseResults [ 0 ] ; console . log ( "preview panel started" ) ; done ( ) ; } ) . catch ( ( err ) => done ( err ) ) ; } ) ; } ) ; test ( "default imports should be inserted" , function ( ) { assert . equal ( editor . document . getText ( ) , "from arepl_dump import dump" + EOL ) ; } ) ; test ( "webview should be displayed" , function ( ) { assert . equal ( panel . visible , true ) ; } ) ; suiteTeardown ( function ( done ) { previewManager . dispose ( ) ; setTimeout ( ( ) => { vscode . commands . executeCommand ( "workbench.action.closeActiveEditor" ) . then ( ( ) => { done ( ) ; } ) ; } , 250 ) ; } ) ; } ) ;