chore: prepare for docs sidebar

This commit is contained in:
endiliey 2018-09-07 13:59:17 +08:00
parent 2141e6ea90
commit b477863a30
9 changed files with 350 additions and 2 deletions

View file

@ -0,0 +1,35 @@
import createOrder from '@lib/load/docs/order';
describe('createOrder', () => {
test('should populate docs index from multiple sidebars', () => {
const result = createOrder({
docs: {
Category1: ['doc1', 'doc2'],
Category2: ['doc3', 'doc4']
},
otherDocs: {
Category1: ['doc5']
}
});
expect(result).toMatchSnapshot();
});
test('should resolve docs from older versions', () => {
const result = createOrder({
docs: {
Category1: ['doc1']
},
'version-1.2.3-docs': {
Category1: ['version-1.2.3-doc2'],
Category2: ['version-1.2.3-doc1']
}
});
expect(result).toMatchSnapshot();
});
test('edge cases', () => {
expect(createOrder({})).toEqual({});
expect(createOrder(null)).toEqual({});
expect(createOrder(undefined)).toEqual({});
});
});