forked from vercel/next.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrecursive-readdir.test.ts
More file actions
35 lines (31 loc) · 916 Bytes
/
recursive-readdir.test.ts
File metadata and controls
35 lines (31 loc) · 916 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
/* eslint-env jest */
import { recursiveReadDir } from 'next/dist/lib/recursive-readdir'
import { join } from 'path'
const resolveDataDir = join(__dirname, 'isolated', '_resolvedata')
const dirWithPages = join(resolveDataDir, 'readdir', 'pages')
describe('recursiveReadDir', () => {
it('should work', async () => {
const result = await recursiveReadDir(dirWithPages, {
pathnameFilter: (f) => /\.js/.test(f),
})
const pages = [
/^[\\/]index\.js/,
/^[\\/]prefered\.js/,
/^[\\/]nav[\\/]about\.js/,
/^[\\/]nav[\\/]index\.js/,
/^[\\/]nested[\\/]index\.js/,
/^[\\/]prefered[\\/]index\.js/,
/^[\\/]nav[\\/]products[\\/]product\.js/,
]
expect(
result.filter((item) => {
for (const page of pages) {
if (page.test(item)) {
return false
}
}
return true
}).length
).toBe(0)
})
})