mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-10 15:47:23 +02:00
chore: prepare for docs sidebar
This commit is contained in:
parent
2141e6ea90
commit
b477863a30
9 changed files with 350 additions and 2 deletions
46
test/load/docs/sidebars.test.js
Normal file
46
test/load/docs/sidebars.test.js
Normal file
|
@ -0,0 +1,46 @@
|
|||
import path from 'path';
|
||||
import loadSidebars from '@lib/load/docs/sidebars';
|
||||
|
||||
describe('loadSidebars', () => {
|
||||
const fixtures = path.join(__dirname, '..', '__fixtures__');
|
||||
test('normal site with sidebars', () => {
|
||||
const env = {};
|
||||
const siteDir = path.join(fixtures, 'simple-site');
|
||||
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', () => {
|
||||
const env = {
|
||||
versioning: {
|
||||
enabled: true,
|
||||
versions: ['1.0.1', '1.0.0']
|
||||
}
|
||||
};
|
||||
const siteDir = path.join(fixtures, 'versioned-site');
|
||||
const result = loadSidebars({siteDir, env});
|
||||
expect(result).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test('site with missing versioned sidebars', () => {
|
||||
const env = {
|
||||
versioning: {
|
||||
enabled: true,
|
||||
versions: ['2.0.0']
|
||||
}
|
||||
};
|
||||
const siteDir = path.join(fixtures, 'versioned-site');
|
||||
expect(() => {
|
||||
loadSidebars({siteDir, env});
|
||||
}).toThrowErrorMatchingInlineSnapshot(
|
||||
`"Failed to load versioned_sidebars/version-2.0.0-sidebars.json. It does not exist."`
|
||||
);
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue