import { expect } from 'chai' ; import { EditorView , TextEditor , Workbench } from 'vscode-extension-tester' ; describe ( 'Text Editor sample tests' , ( ) => { let editor ; before ( async ( ) => { await new Workbench ( ) . executeCommand ( 'create new file' ) ; editor = await new EditorView ( ) . openEditor ( 'Untitled-1' ) as TextEditor ; } ) ; after ( async ( ) => { await editor . clearText ( ) ; await new EditorView ( ) . closeAllEditors ( ) ; } ) ; it ( 'Text manipulation' , async ( ) => { await editor . typeTextAt ( 1 , 1 , 'hello' ) ; const text = await editor . getText ( ) ; expect ( text ) . equals ( 'hello' ) ; await editor . setText ( `line1\nline2\nline3` ) ; expect ( await editor . getNumberOfLines ( ) ) . equals ( 3 ) ; const line = await editor . getTextAtLine ( 2 ) ; expect ( line ) . equals ( 'line2' ) ; const lineNum = await editor . getLineOfText ( '3' ) ; expect ( lineNum ) . equals ( 3 ) ; expect ( await editor . isDirty ( ) ) . is . true ; } ) . timeout ( 15000 ) ; it ( 'Content Assist' , async ( ) => { const assist = await editor . toggleContentAssist ( true ) ; if ( assist ) { const items = await assist . getItems ( ) ; expect ( items ) . not . empty ; } await editor . toggleContentAssist ( false ) ; } ) ; } ) ;