docusaurus/v2/test/load/docs/sidebars.test.js
Endilie Yacop Sucipto 85336649d3
feat(v2): headerlinks (#1074)
* feat(v2): headerlinks

* fix test

* nits

* remove tictactoe:

* headerIcon

* nits

* remove lang dropdown

* fix failing test

* search box

* algolia search

* use babel-eslint to resolve dynamic import

* nits

* favicon and title

* Update .eslintignore
2018-10-28 16:32:19 +08:00

47 lines
1.4 KiB
JavaScript

/**
* Copyright (c) 2017-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import path from 'path';
import loadSidebars from '@lib/load/docs/sidebars';
import loadSetup from '../../loadSetup';
describe('loadSidebars', async () => {
const fixtures = path.join(__dirname, '..', '__fixtures__');
test('normal site with sidebars', async () => {
const {env, siteDir} = await loadSetup('simple');
const result = loadSidebars({siteDir, env});
expect(result).toMatchSnapshot();
});
test('site without sidebars', () => {
const env = {};
const siteDir = path.join(fixtures, 'bad-site');
const result = loadSidebars({siteDir, env});
expect(result).toMatchSnapshot();
});
test('site with sidebars & versioned sidebars', async () => {
const {env, siteDir} = await loadSetup('versioned');
const result = loadSidebars({siteDir, env});
expect(result).toMatchSnapshot();
});
test('site with missing versioned sidebars', async () => {
const env = {
versioning: {
enabled: true,
versions: ['2.0.0'],
},
};
const {siteDir} = await loadSetup('versioned');
expect(() => {
loadSidebars({siteDir, env});
}).toThrowErrorMatchingInlineSnapshot(
`"Failed to load versioned_sidebars/version-2.0.0-sidebars.json. It does not exist."`,
);
});
});