fix(content-blog): make RSS feed generation work with slugs with .html extension (#8158)

Co-authored-by: sebastienlorber <lorber.sebastien@gmail.com>
This commit is contained in:
Pranav Joglekar 2022-10-06 19:49:05 +05:30 committed by GitHub
parent c325f87fd8
commit efbd0cbd40
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 64 additions and 13 deletions

View file

@ -0,0 +1 @@
htmlFile.html

View file

@ -0,0 +1 @@
nestedHtmlFile.html

View file

@ -73,6 +73,38 @@ describe('readOutputHTMLFile', () => {
).then(String),
).resolves.toBe('file\n');
});
it('reads file ending in .html', async () => {
await expect(
readOutputHTMLFile(
'/htmlFile.html',
path.join(__dirname, '__fixtures__/build-snap'),
false,
).then(String),
).resolves.toBe('htmlFile.html\n');
await expect(
readOutputHTMLFile(
'/htmlFile.html',
path.join(__dirname, '__fixtures__/build-snap'),
undefined,
).then(String),
).resolves.toBe('htmlFile.html\n');
});
it('reads file ending in .html in folder containing .html', async () => {
await expect(
readOutputHTMLFile(
'/weird.html.folder/nestedHtmlFile.html',
path.join(__dirname, '__fixtures__/build-snap'),
undefined,
).then(String),
).resolves.toBe('nestedHtmlFile.html\n');
await expect(
readOutputHTMLFile(
'/weird.html.folder/nestedHtmlFile.html',
path.join(__dirname, '__fixtures__/build-snap'),
undefined,
).then(String),
).resolves.toBe('nestedHtmlFile.html\n');
});
// Can it ever happen?
it('throws if file does not exist', async () => {
await expect(
@ -82,7 +114,7 @@ describe('readOutputHTMLFile', () => {
undefined,
).then(String),
).rejects.toThrowErrorMatchingInlineSnapshot(
`"Expected output HTML file to be found at <PROJECT_ROOT>/packages/docusaurus-utils/src/__tests__/__fixtures__/build-snap/nonExistent/index.html."`,
`"Expected output HTML file to be found at <PROJECT_ROOT>/packages/docusaurus-utils/src/__tests__/__fixtures__/build-snap/nonExistent/index.html for permalink /nonExistent."`,
);
});
});