'use strict' ; import * as vscode from 'vscode' ; import * as sinon from 'sinon' ; import * as chai from 'chai' ; import * as sinonChai from 'sinon-chai' ; import { ReactView } from '../../extension/webview/ReactView' ; import { View } from '../../extension/webview/View' ; import { TestUtil } from '../TestUtil' ; import { GlobalState } from '../../extension/util/GlobalState' ; chai . use ( sinonChai ) ; class TestView extends ReactView { protected openPanelInner ( ) { return ; } protected loadComponent ( ) { return ; } } describe ( 'ReactView' , ( ) => { const mySandBox = sinon . createSandbox ( ) ; let context ; let createWebviewPanelStub ; let executeCommandStub ; before ( async ( ) => { await TestUtil . setupTests ( mySandBox ) ; } ) ; beforeEach ( async ( ) => { context = GlobalState . getExtensionContext ( ) ; executeCommandStub = mySandBox . stub ( vscode . commands , 'executeCommand' ) ; executeCommandStub . callThrough ( ) ; createWebviewPanelStub = mySandBox . stub ( vscode . window , 'createWebviewPanel' ) ; View [ 'openPanels' ] . splice ( 0 , View [ 'openPanels' ] . length ) ; createWebviewPanelStub . returns ( { title : 'Transaction Page' , webview : { postMessage : mySandBox . stub ( ) , onDidReceiveMessage : mySandBox . stub ( ) , asWebviewUri : mySandBox . stub ( ) } , reveal : mySandBox . stub ( ) , dispose : mySandBox . stub ( ) , onDidDispose : mySandBox . stub ( ) , onDidChangeViewState : mySandBox . stub ( ) } ) ; } ) ; afterEach ( ( ) => { mySandBox . restore ( ) ; } ) ; it ( 'getHTMLString' , async ( ) => { const testView = new TestView ( context , 'reactView' , 'React View' ) ; const webview = { asWebviewUri : mySandBox . stub ( ) } ; const html = await testView . getHTMLString ( webview ) ; html . should . contain ( `<div id="root"></div>` ) ; } ) ; } ) ;