rsnext/test/unit/select-pages/select-pages.test.js
Joe Haddad 94b8bf75e2
Move build utils to their own file (#6990)
* Move build utils to their own file

* Tweak feature detection
2019-04-09 23:15:35 -04:00

31 lines
858 B
JavaScript

/* eslint-env jest */
import { getSpecifiedPages as _getSpecifiedPages } from 'next/dist/build/utils'
const getSpecifiedPages = async (...args) =>
(await _getSpecifiedPages(...args)).map(pg => pg.replace(/\\+/g, '/'))
describe('getSpecifiedPages', () => {
it('should only choose selected', async () => {
expect(await getSpecifiedPages(__dirname, 'a', ['js'])).toMatchSnapshot()
let err
try {
await getSpecifiedPages(__dirname, 'a,b', ['js'])
} catch (e) {
err = e
}
expect(err).toBeTruthy()
expect(
await getSpecifiedPages(__dirname, 'a,b', ['js', 'jsx'])
).toMatchSnapshot()
expect(
await getSpecifiedPages(__dirname, 'a,b', ['js', 'jsx', 'mdx'])
).toMatchSnapshot()
expect(
await getSpecifiedPages(__dirname, 'a,b,c', ['js', 'jsx', 'mdx'])
).toMatchSnapshot()
})
})