rsnext/test/unit/recursive-readdir.test.ts
JJ Kasper a92a5caec2
Update test set-up to leverage playwright when able to (#28634)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2021-09-13 14:36:25 +02:00

33 lines
870 B
TypeScript

/* 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, /\.js/)
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)
})
})