@@ -462,19 +462,20 @@ describe('workspaceUtils', () => {
462462 } )
463463
464464 describe ( 'collectFilesForIndex' , function ( ) {
465- it ( 'returns all files in the workspace not excluded by gitignore and is a supported programming language' , async function ( ) {
466- // these variables are a manual selection of settings for the test in order to test the collectFiles function
467- const fileAmount = 3
468- const fileNamePrefix = 'file'
469- const fileContent = 'test content'
465+ let workspaceFolder : vscode . WorkspaceFolder
470466
471- const workspaceFolder = await createTestWorkspace ( fileAmount , { fileNamePrefix, fileContent } )
472-
473- const writeFile = ( pathParts : string [ ] , fileContent : string ) => {
474- return toFile ( fileContent , path . join ( workspaceFolder . uri . fsPath , ...pathParts ) )
475- }
467+ const writeFile = ( pathParts : string [ ] , fileContent : string ) => {
468+ return toFile ( fileContent , path . join ( workspaceFolder . uri . fsPath , ...pathParts ) )
469+ }
476470
471+ beforeEach ( async function ( ) {
472+ workspaceFolder = await createTestWorkspaceFolder ( )
477473 sandbox . stub ( vscode . workspace , 'workspaceFolders' ) . value ( [ workspaceFolder ] )
474+ } )
475+
476+ it ( 'returns all files in the workspace not excluded by gitignore and is a supported programming language' , async function ( ) {
477+ const fileContent = 'test content'
478+
478479 const gitignoreContent = `file2
479480 # different formats of prefixes
480481 /build
@@ -535,19 +536,8 @@ describe('workspaceUtils', () => {
535536 } )
536537
537538 it ( 'does not include build related files' , async function ( ) {
538- // these variables are a manual selection of settings for the test in order to test the collectFiles function
539- const fileAmount = 3
540- const fileNamePrefix = 'file'
541539 const fileContent = 'this is a file'
542540
543- const workspaceFolder = await createTestWorkspace ( fileAmount , { fileNamePrefix, fileContent } )
544-
545- const writeFile = ( pathParts : string [ ] , fileContent : string ) => {
546- return toFile ( fileContent , path . join ( workspaceFolder . uri . fsPath , ...pathParts ) )
547- }
548-
549- sandbox . stub ( vscode . workspace , 'workspaceFolders' ) . value ( [ workspaceFolder ] )
550-
551541 await writeFile ( [ 'bin' , `ignored1` ] , fileContent )
552542 await writeFile ( [ 'bin' , `ignored2` ] , fileContent )
553543
@@ -581,19 +571,8 @@ describe('workspaceUtils', () => {
581571 } )
582572
583573 it ( 'returns top level files when max size is reached' , async function ( ) {
584- // these variables are a manual selection of settings for the test in order to test the collectFiles function
585- const fileAmount = 3
586- const fileNamePrefix = 'file'
587574 const fileContent = 'this is a file'
588575
589- const workspaceFolder = await createTestWorkspace ( fileAmount , { fileNamePrefix, fileContent } )
590-
591- const writeFile = ( pathParts : string [ ] , fileContent : string ) => {
592- return toFile ( fileContent , path . join ( workspaceFolder . uri . fsPath , ...pathParts ) )
593- }
594-
595- sandbox . stub ( vscode . workspace , 'workspaceFolders' ) . value ( [ workspaceFolder ] )
596-
597576 await writeFile ( [ 'path' , 'to' , 'file' , 'a2.js' ] , fileContent )
598577 await writeFile ( [ 'path' , 'to' , 'file' , `b2.java` ] , fileContent )
599578
0 commit comments