import { expect } from 'chai' ; import { SinonSandbox , createSandbox , SinonSpy , SinonStub } from 'sinon' ; import * as vscode from 'vscode' ; import { soqlOpenNew } from '../../../src/commands/soqlFileCreate' ; import { BUILDER_VIEW_TYPE , EDITOR_VIEW_TYPE } from '../../../src/constants' ; import { telemetryService } from '../../../src/telemetry' ; describe ( 'soqlOpenNew should' , ( ) => { let sb ; let telemetryStub ; let executeCommandSpy ; beforeEach ( ( ) => { sb = createSandbox ( ) ; telemetryStub = sb . stub ( telemetryService , 'sendCommandEvent' ) as SinonStub ; executeCommandSpy = ( sb . spy ( vscode . commands , 'executeCommand' ) as unknown ) as SinonSpy ; } ) ; afterEach ( async ( ) => { sb . restore ( ) ; } ) ; it ( 'sends telemetry and opens editor when invoked' , async ( ) => { await soqlOpenNew ( ) ; expect ( telemetryStub . called ) . is . true ; expect ( executeCommandSpy . getCall ( 0 ) . args [ 2 ] ) . contains ( BUILDER_VIEW_TYPE ) ; expect ( executeCommandSpy . getCall ( 0 ) . args [ 1 ] . scheme ) . contains ( 'untitled' ) ; } ) ; } ) ;