test: add easy setup for test cases

This commit is contained in:
endiliey 2018-09-07 18:00:50 +08:00
parent b477863a30
commit 31d333b82f
69 changed files with 3387 additions and 24 deletions

View file

@ -3,11 +3,7 @@ import path from 'path';
describe('loadPages', () => {
test('valid pages', async () => {
const pagesDir = path.join(
__dirname,
'__fixtures__',
'simple-pages'
);
const pagesDir = path.join(__dirname, '__fixtures__', 'simple-pages');
const pagesData = await loadPages(pagesDir);
expect(pagesData).toMatchSnapshot();
expect(pagesData).not.toBeNull();

View file

@ -65,6 +65,7 @@ describe('load utils', () => {
versions: []
}
};
const test = {arr: [1, 2, 3]};
const variable = 'enabledLanguages';
expect(idx(a, [('b', 'c')])).toBeUndefined();
expect(idx(b, ['hello'])).toEqual('world');
@ -79,6 +80,7 @@ describe('load utils', () => {
'en',
'ja'
]);
expect(idx(test, ['arr', 0])).toEqual(1);
expect(idx(undefined)).toBeUndefined();
expect(idx(null)).toBeNull();
});