-
-
Notifications
You must be signed in to change notification settings - Fork 8.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(content-docs): allow omitting enclosing array consistently for c…
…ategory shorthand (#6602) * feat(content-docs): allow omitting enclosing array consistently for category shorthand * update snapshot * fix doc
- Loading branch information
Showing
6 changed files
with
301 additions
and
79 deletions.
There are no files selected for viewing
96 changes: 96 additions & 0 deletions
96
...aurus-plugin-content-docs/src/sidebars/__tests__/__snapshots__/normalization.test.ts.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`normalization normalizes shorthands 1`] = ` | ||
Object { | ||
"sidebar": Array [ | ||
Object { | ||
"items": Array [ | ||
Object { | ||
"id": "doc1", | ||
"type": "doc", | ||
}, | ||
Object { | ||
"id": "doc2", | ||
"type": "doc", | ||
}, | ||
], | ||
"label": "Category", | ||
"type": "category", | ||
}, | ||
Object { | ||
"items": Array [ | ||
Object { | ||
"items": Array [ | ||
Object { | ||
"id": "doc3", | ||
"type": "doc", | ||
}, | ||
Object { | ||
"id": "doc4", | ||
"type": "doc", | ||
}, | ||
], | ||
"label": "Subcategory 1", | ||
"type": "category", | ||
}, | ||
Object { | ||
"items": Array [ | ||
Object { | ||
"id": "doc5", | ||
"type": "doc", | ||
}, | ||
Object { | ||
"id": "doc6", | ||
"type": "doc", | ||
}, | ||
], | ||
"label": "Subcategory 2", | ||
"type": "category", | ||
}, | ||
], | ||
"label": "Category 2", | ||
"type": "category", | ||
}, | ||
], | ||
} | ||
`; | ||
|
||
exports[`normalization normalizes shorthands 2`] = ` | ||
Object { | ||
"sidebar": Array [ | ||
Object { | ||
"href": "https://google.com", | ||
"label": "Google", | ||
"type": "link", | ||
}, | ||
Object { | ||
"items": Array [ | ||
Object { | ||
"id": "doc1", | ||
"type": "doc", | ||
}, | ||
Object { | ||
"id": "doc2", | ||
"type": "doc", | ||
}, | ||
], | ||
"label": "Category 1", | ||
"type": "category", | ||
}, | ||
Object { | ||
"items": Array [ | ||
Object { | ||
"id": "doc3", | ||
"type": "doc", | ||
}, | ||
Object { | ||
"id": "doc4", | ||
"type": "doc", | ||
}, | ||
], | ||
"label": "Category 2", | ||
"type": "category", | ||
}, | ||
], | ||
} | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
packages/docusaurus-plugin-content-docs/src/sidebars/__tests__/normalization.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
import {normalizeSidebars} from '../normalization'; | ||
|
||
describe('normalization', () => { | ||
test('normalizes shorthands', () => { | ||
expect( | ||
normalizeSidebars({ | ||
sidebar: { | ||
Category: ['doc1', 'doc2'], | ||
'Category 2': { | ||
'Subcategory 1': ['doc3', 'doc4'], | ||
'Subcategory 2': ['doc5', 'doc6'], | ||
}, | ||
}, | ||
}), | ||
).toMatchSnapshot(); | ||
|
||
expect( | ||
normalizeSidebars({ | ||
sidebar: [ | ||
{ | ||
type: 'link', | ||
label: 'Google', | ||
href: 'https://google.com', | ||
}, | ||
{ | ||
'Category 1': ['doc1', 'doc2'], | ||
'Category 2': ['doc3', 'doc4'], | ||
}, | ||
], | ||
}), | ||
).toMatchSnapshot(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.