test: load pages

This commit is contained in:
endiliey 2018-08-11 01:03:46 +08:00
parent cfd11fbb6d
commit 8f493605ad
6 changed files with 43 additions and 0 deletions

17
test/load/pages.test.js Normal file
View file

@ -0,0 +1,17 @@
import loadPages from '@lib/load/pages.js';
import path from 'path';
describe('loadPages', () => {
test('valid pages', async () => {
const pagesDir = path.join(__dirname, '__fixtures__', 'simple-pages');
const pagesData = await loadPages(pagesDir);
expect(pagesData).toMatchSnapshot();
expect(pagesData).not.toBeNull();
});
test('invalid pages', async () => {
const nonExistingDir = path.join(__dirname, '__fixtures__', 'nonExisting');
const pagesData = await loadPages(nonExistingDir);
expect(pagesData).toEqual([]);
});
});