rsnext/test/unit/recursive-readdir.test.js
Connor Davis 5514949df0 Remove glob package (#6415)
We don't use a lot of the features of `glob`, so let's remove it in favor of a leaner approach using regex.

It's failing on windows and I have no idea why and don't own a windows machine 🤦🏼‍♂️

(Ignore some of the commits in here, I forgot to create the new branch before I started working)
2019-02-24 22:08:35 +01:00

22 lines
800 B
JavaScript

/* 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)
})
})