@@ -4,7 +4,7 @@ import sinon from 'sinon';
44// You can import and use all API from the 'vscode' module
55// as well as import your extension to test it
66import * as vscode from 'vscode' ;
7- import { importedRegex , splitImportRegex , createTest } from '../actions/initTest' ;
7+ import { importedRegex , splitImportRegex , generateCode , writeTest } from '../actions/initTest' ;
88
99suite ( 'Extension Test Suite' , ( ) => {
1010 vscode . window . showInformationMessage ( 'Start all tests.' ) ;
@@ -37,7 +37,23 @@ suite('Extension Test Suite', () => {
3737 } ) ;
3838 } ) ;
3939
40- suite ( 'createTest' , ( ) => {
40+ suite ( 'generateCode' , ( ) => {
41+ const fakePath = 'utils' ;
42+ test ( 'import default' , ( ) => {
43+ const [ createdCode ] = generateCode ( fakePath ) ( 'import cheers from \'./utils.ts\';' ) ! ;
44+ assert . equal ( createdCode . replace ( '\\' , '/' ) , "'../utils.ts': { default: mock.fn()}" ) ;
45+ } ) ;
46+ test ( 'import with destructuring' , ( ) => {
47+ const [ createdCode ] = generateCode ( fakePath ) ( "import { goodbye, greeter, Person } from './utils.ts';" ) ! ;
48+ assert . equal ( createdCode . replace ( '\\' , '/' ) , "'../utils.ts': { goodbye: mock.fn(), greeter: mock.fn(), Person : mock.fn()}" ) ;
49+ } ) ;
50+ test ( 'import with default and destructuring' , ( ) => {
51+ const [ createdCode ] = generateCode ( fakePath ) ( "import cheers, { hello, goodbye, greeter, Person } from './utils.ts';" ) ! ;
52+ assert . equal ( createdCode . replace ( '\\' , '/' ) , "'../utils.ts': { default: mock.fn(), hello: mock.fn(), goodbye: mock.fn(), greeter: mock.fn(), Person : mock.fn()}" ) ;
53+ } ) ;
54+ } ) ;
55+
56+ suite ( 'writeTest' , ( ) => {
4157 const fakeInsert = sinon . stub ( ) ;
4258 const fakeEditBuilder = {
4359 insert : fakeInsert
@@ -53,7 +69,7 @@ suite('Extension Test Suite', () => {
5369 } as unknown as vscode . TextEditor ;
5470
5571 test ( 'check inserted code' , ( ) => {
56- createTest ( { editor : fakeEditor as any , pathTo : '' , mockedImports : [ ] } ) ( fakeEditBuilder ) ;
72+ writeTest ( { editor : fakeEditor as any , pathTo : '' , mockedImports : [ ] } ) ( fakeEditBuilder ) ;
5773 sinon . assert . callCount ( fakeInsert , 4 ) ;
5874 } ) ;
5975
0 commit comments