mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-22 21:47:01 +02:00
fix: reload siteConfig.js automatically when locally served page is refreshed (#1509)
* fix: livereload siteConfig * fix test * nits
This commit is contained in:
parent
aa157969cf
commit
166816af40
11 changed files with 53 additions and 42 deletions
|
@ -10,9 +10,9 @@ const blog = require('../blog');
|
|||
const metadataUtils = require('../metadataUtils');
|
||||
const {replaceAssetsLink} = require('../utils.js');
|
||||
|
||||
jest.mock(`${process.cwd()}/siteConfig.js`, () => ({baseUrl: '/'}), {
|
||||
virtual: true,
|
||||
});
|
||||
const siteConfig = {
|
||||
baseUrl: '/',
|
||||
};
|
||||
|
||||
const testFile = path.join(
|
||||
__dirname,
|
||||
|
@ -25,16 +25,18 @@ fs.existsSync = jest.fn().mockReturnValue(true);
|
|||
describe('getMetadata', () => {
|
||||
test('file does not exist', () => {
|
||||
fs.existsSync.mockReturnValueOnce(null);
|
||||
expect(blog.getMetadata('/this/path/does-not-exist/')).toBeNull();
|
||||
expect(
|
||||
blog.getMetadata('/this/path/does-not-exist/', siteConfig),
|
||||
).toBeNull();
|
||||
});
|
||||
|
||||
test('null/undefined', () => {
|
||||
expect(blog.getMetadata(null)).toBeNull();
|
||||
expect(blog.getMetadata(undefined)).toBeNull();
|
||||
expect(blog.getMetadata(null, siteConfig)).toBeNull();
|
||||
expect(blog.getMetadata(undefined, siteConfig)).toBeNull();
|
||||
});
|
||||
|
||||
test('blog file', () => {
|
||||
const metadata = blog.getMetadata(testFile);
|
||||
const metadata = blog.getMetadata(testFile, siteConfig);
|
||||
expect(metadata).toMatchSnapshot();
|
||||
expect(metadata).not.toBeNull();
|
||||
expect(metadata).toHaveProperty('id');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue