1
- import { expect } from 'chai' ;
2
1
import fs from 'fs' ;
3
2
import path from 'path' ;
4
- import { fileURLToPath } from 'url' ;
5
3
import { execSync } from 'child_process' ;
6
- import { describe , beforeEach , afterEach , it } from 'mocha' ;
7
-
8
- const __filename = fileURLToPath ( import . meta. url ) ;
9
- const __dirname = path . dirname ( __filename ) ;
4
+ import { describe , beforeEach , afterEach , expect , test } from "bun:test" ;
10
5
11
6
describe ( 'files-to-prompt.ts' , ( ) => {
12
7
const testDir = path . join ( __dirname , 'test-data' ) ;
@@ -19,40 +14,40 @@ describe('files-to-prompt.ts', () => {
19
14
fs . rmSync ( testDir , { recursive : true , force : true } ) ;
20
15
} ) ;
21
16
22
- it ( 'should include single file passed on the command line' , ( ) => {
17
+ test ( 'should include single file passed on the command line' , ( ) => {
23
18
const filePath = path . join ( testDir , 'file1.txt' ) ;
24
19
fs . writeFileSync ( filePath , 'File 1 contents' ) ;
25
20
26
21
const output = execSync ( `bun ./files-to-prompt.ts ${ filePath } ` ) . toString ( ) ;
27
- expect ( output ) . to . include ( filePath ) ;
28
- expect ( output ) . to . include ( 'File 1 contents' ) ;
22
+ expect ( output ) . toContain ( filePath ) ;
23
+ expect ( output ) . toContain ( 'File 1 contents' ) ;
29
24
} ) ;
30
25
31
- it ( 'should include multiple files passed on the command line' , ( ) => {
26
+ test ( 'should include multiple files passed on the command line' , ( ) => {
32
27
const file1Path = path . join ( testDir , 'file1.txt' ) ;
33
28
const file2Path = path . join ( testDir , 'file2.txt' ) ;
34
29
fs . writeFileSync ( file1Path , 'File 1 contents' ) ;
35
30
fs . writeFileSync ( file2Path , 'File 2 contents' ) ;
36
31
37
32
const output = execSync ( `bun ./files-to-prompt.ts ${ file1Path } ${ file2Path } ` ) . toString ( ) ;
38
- expect ( output ) . to . include ( file1Path ) ;
39
- expect ( output ) . to . include ( 'File 1 contents' ) ;
40
- expect ( output ) . to . include ( file2Path ) ;
41
- expect ( output ) . to . include ( 'File 2 contents' ) ;
33
+ expect ( output ) . toContain ( file1Path ) ;
34
+ expect ( output ) . toContain ( 'File 1 contents' ) ;
35
+ expect ( output ) . toContain ( file2Path ) ;
36
+ expect ( output ) . toContain ( 'File 2 contents' ) ;
42
37
} ) ;
43
38
44
- it ( 'should include files in directories passed on the command line' , ( ) => {
39
+ test ( 'should include files in directories passed on the command line' , ( ) => {
45
40
const dirPath = path . join ( testDir , 'dir' ) ;
46
41
fs . mkdirSync ( dirPath ) ;
47
42
const filePath = path . join ( dirPath , 'file.txt' ) ;
48
43
fs . writeFileSync ( filePath , 'File contents' ) ;
49
44
50
45
const output = execSync ( `bun ./files-to-prompt.ts ${ dirPath } ` ) . toString ( ) ;
51
- expect ( output ) . to . include ( filePath ) ;
52
- expect ( output ) . to . include ( 'File contents' ) ;
46
+ expect ( output ) . toContain ( filePath ) ;
47
+ expect ( output ) . toContain ( 'File contents' ) ;
53
48
} ) ;
54
49
55
- it ( 'should include files a few levels deep in a directory structure' , ( ) => {
50
+ test ( 'should include files a few levels deep in a directory structure' , ( ) => {
56
51
const dir1Path = path . join ( testDir , 'dir1' ) ;
57
52
const dir2Path = path . join ( dir1Path , 'dir2' ) ;
58
53
fs . mkdirSync ( dir1Path ) ;
@@ -61,34 +56,34 @@ describe('files-to-prompt.ts', () => {
61
56
fs . writeFileSync ( filePath , 'File contents' ) ;
62
57
63
58
const output = execSync ( `bun ./files-to-prompt.ts ${ testDir } ` ) . toString ( ) ;
64
- expect ( output ) . to . include ( filePath ) ;
65
- expect ( output ) . to . include ( 'File contents' ) ;
59
+ expect ( output ) . toContain ( filePath ) ;
60
+ expect ( output ) . toContain ( 'File contents' ) ;
66
61
} ) ;
67
62
68
- it ( 'should exclude files matching patterns passed via --ignore' , ( ) => {
63
+ test ( 'should exclude files matching patterns passed via --ignore' , ( ) => {
69
64
const file1Path = path . join ( testDir , 'file1.txt' ) ;
70
65
const file2Path = path . join ( testDir , 'file2.txt' ) ;
71
66
fs . writeFileSync ( file1Path , 'File 1 contents' ) ;
72
67
fs . writeFileSync ( file2Path , 'File 2 contents' ) ;
73
68
74
69
const output = execSync ( `bun ./files-to-prompt.ts ${ testDir } --ignore "file1.txt"` ) . toString ( ) ;
75
- expect ( output ) . to . not . include ( file1Path ) ;
76
- expect ( output ) . to . include ( file2Path ) ;
70
+ expect ( output ) . not . toContain ( file1Path ) ;
71
+ expect ( output ) . toContain ( file2Path ) ;
77
72
} ) ;
78
73
79
- it ( 'should exclude files matching patterns in .gitignore' , ( ) => {
74
+ test ( 'should exclude files matching patterns in .gitignore' , ( ) => {
80
75
const file1Path = path . join ( testDir , 'file1.txt' ) ;
81
76
const file2Path = path . join ( testDir , 'file2.txt' ) ;
82
77
fs . writeFileSync ( file1Path , 'File 1 contents' ) ;
83
78
fs . writeFileSync ( file2Path , 'File 2 contents' ) ;
84
79
fs . writeFileSync ( path . join ( testDir , '.gitignore' ) , 'file1.txt' ) ;
85
80
86
81
const output = execSync ( `bun ./files-to-prompt.ts ${ testDir } ` ) . toString ( ) ;
87
- expect ( output ) . to . not . include ( file1Path ) ;
88
- expect ( output ) . to . include ( file2Path ) ;
82
+ expect ( output ) . not . toContain ( file1Path ) ;
83
+ expect ( output ) . toContain ( file2Path ) ;
89
84
} ) ;
90
85
91
- it ( 'should include hidden files and directories when --include-hidden is passed' , ( ) => {
86
+ test ( 'should include hidden files and directories when --include-hidden is passed' , ( ) => {
92
87
const hiddenFilePath = path . join ( testDir , '.hidden-file.txt' ) ;
93
88
const hiddenDirPath = path . join ( testDir , '.hidden-dir' ) ;
94
89
const hiddenDirFilePath = path . join ( hiddenDirPath , 'file.txt' ) ;
@@ -97,19 +92,19 @@ describe('files-to-prompt.ts', () => {
97
92
fs . writeFileSync ( hiddenDirFilePath , 'Hidden dir file contents' ) ;
98
93
99
94
const output = execSync ( `bun ./files-to-prompt.ts ${ testDir } --include-hidden` ) . toString ( ) ;
100
- expect ( output ) . to . include ( hiddenFilePath ) ;
101
- expect ( output ) . to . include ( 'Hidden file contents' ) ;
102
- expect ( output ) . to . include ( hiddenDirFilePath ) ;
103
- expect ( output ) . to . include ( 'Hidden dir file contents' ) ;
95
+ expect ( output ) . toContain ( hiddenFilePath ) ;
96
+ expect ( output ) . toContain ( 'Hidden file contents' ) ;
97
+ expect ( output ) . toContain ( hiddenDirFilePath ) ;
98
+ expect ( output ) . toContain ( 'Hidden dir file contents' ) ;
104
99
} ) ;
105
100
106
- it ( 'should ignore .gitignore files when --ignore-gitignore is passed' , ( ) => {
101
+ test ( 'should ignore .gitignore files when --ignore-gitignore is passed' , ( ) => {
107
102
const file1Path = path . join ( testDir , 'file1.txt' ) ;
108
103
fs . writeFileSync ( file1Path , 'File 1 contents' ) ;
109
104
fs . writeFileSync ( path . join ( testDir , '.gitignore' ) , 'file1.txt' ) ;
110
105
111
106
const output = execSync ( `bun ./files-to-prompt.ts ${ testDir } --ignore-gitignore` ) . toString ( ) ;
112
- expect ( output ) . to . include ( file1Path ) ;
113
- expect ( output ) . to . include ( 'File 1 contents' ) ;
107
+ expect ( output ) . toContain ( file1Path ) ;
108
+ expect ( output ) . toContain ( 'File 1 contents' ) ;
114
109
} ) ;
115
110
} ) ;
0 commit comments