-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreaddirRecursive.spec.ts
More file actions
37 lines (33 loc) · 921 Bytes
/
readdirRecursive.spec.ts
File metadata and controls
37 lines (33 loc) · 921 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import { readdirRecursive } from '.'
import { writeFile, rmdir, mkdir } from 'fs/promises'
describe('readdirRecursive', () => {
beforeAll(async () => {
await mkdir('./parent-dir')
await writeFile('./parent-dir/first-file', '')
await writeFile('./parent-dir/second-file', '')
await mkdir('./parent-dir/child-dir')
await writeFile('./parent-dir/child-dir/third-file', '')
})
afterAll(async () => {
await rmdir('./parent-dir', { recursive: true })
})
it('get filenames in target dir', async () => {
/**
* Given
*/
const targetDir = './parent-dir'
const expectedPaths = [
'parent-dir/first-file',
'parent-dir/second-file',
'parent-dir/child-dir/third-file',
]
/**
* When
*/
const paths = await readdirRecursive(targetDir)
/**
* Then
*/
paths.forEach((path) => expect(expectedPaths).toContain(path))
})
})