mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-23 05:57:05 +02:00
test: improve test coverage (#6857)
This commit is contained in:
parent
edb4d00096
commit
f763ac13a9
22 changed files with 435 additions and 220 deletions
|
@ -22,6 +22,47 @@ Array [
|
|||
]
|
||||
`;
|
||||
|
||||
exports[`translateContent should fallback when translation is incomplete 1`] = `
|
||||
Object {
|
||||
"blogListPaginated": Array [
|
||||
Object {
|
||||
"items": Array [
|
||||
"hello",
|
||||
],
|
||||
"metadata": Object {
|
||||
"blogDescription": "Someone's random blog",
|
||||
"blogTitle": "My blog",
|
||||
"nextPage": null,
|
||||
"page": 1,
|
||||
"permalink": "/",
|
||||
"postsPerPage": 10,
|
||||
"previousPage": null,
|
||||
"totalCount": 1,
|
||||
"totalPages": 1,
|
||||
},
|
||||
},
|
||||
],
|
||||
"blogPosts": Array [
|
||||
Object {
|
||||
"id": "hello",
|
||||
"metadata": Object {
|
||||
"date": 2021-07-19T00:00:00.000Z,
|
||||
"description": "/blog/2021/06/19/hello",
|
||||
"formattedDate": "June 19, 2021",
|
||||
"permalink": "/blog/2021/06/19/hello",
|
||||
"source": "/blog/2021/06/19/hello",
|
||||
"tags": Array [],
|
||||
"title": "Hello",
|
||||
"truncated": true,
|
||||
},
|
||||
},
|
||||
],
|
||||
"blogSidebarTitle": "All my posts",
|
||||
"blogTags": Object {},
|
||||
"blogTagsListPath": "/tags",
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`translateContent should return translated loaded content matching snapshot 1`] = `
|
||||
Object {
|
||||
"blogListPaginated": Array [
|
||||
|
|
|
@ -77,6 +77,12 @@ describe('getContentTranslationFiles', () => {
|
|||
});
|
||||
|
||||
describe('translateContent', () => {
|
||||
test('should fallback when translation is incomplete', () => {
|
||||
expect(
|
||||
translateContent(sampleBlogContent, [{path: 'foo', content: {}}]),
|
||||
).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test('should not translate anything if translation files are untranslated', () => {
|
||||
const translationFiles = getSampleTranslationFiles();
|
||||
expect(translateContent(sampleBlogContent, translationFiles)).toEqual(
|
||||
|
|
|
@ -53,9 +53,6 @@ export function translateContent(
|
|||
content: BlogContent,
|
||||
translationFiles: TranslationFiles,
|
||||
): BlogContent {
|
||||
if (translationFiles.length === 0) {
|
||||
return content;
|
||||
}
|
||||
const {content: optionsTranslations} = translationFiles[0]!;
|
||||
return {
|
||||
...content,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue