mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-11 16:17:25 +02:00
* fix: #1114 static files in `blog/assets` is not working * lint fix
This commit is contained in:
parent
db6017903b
commit
a1e7af7e0e
6 changed files with 114 additions and 23 deletions
|
@ -7,6 +7,8 @@
|
|||
const path = require('path');
|
||||
const fs = require('fs-extra');
|
||||
const blog = require('../blog');
|
||||
const metadataUtils = require('../metadataUtils');
|
||||
const {replaceAssetsLink} = require('../utils.js');
|
||||
|
||||
const testFile = path.join(
|
||||
__dirname,
|
||||
|
@ -66,3 +68,38 @@ describe('urlToSource', () => {
|
|||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('replaceAssetsLink', () => {
|
||||
test('transform document with valid assets link', () => {
|
||||
const doc1 = fs.readFileSync(
|
||||
path.join(__dirname, '__fixtures__', 'doc1.md'),
|
||||
'utf8',
|
||||
);
|
||||
const rawContent1 = metadataUtils.extractMetadata(doc1).rawContent;
|
||||
const content1 = replaceAssetsLink(rawContent1, 'blog');
|
||||
expect(content1).toMatchSnapshot();
|
||||
expect(content1).toContain('');
|
||||
expect(content1).toContain('');
|
||||
expect(content1).toContain('');
|
||||
expect(content1).toContain('');
|
||||
expect(content1).not.toContain('');
|
||||
expect(content1).not.toContain('');
|
||||
expect(content1).not.toContain('');
|
||||
expect(content1).not.toContain('');
|
||||
expect(content1).not.toEqual(rawContent1);
|
||||
});
|
||||
|
||||
test('does not transform document without valid assets link', () => {
|
||||
const doc2 = fs.readFileSync(
|
||||
path.join(__dirname, '__fixtures__', 'doc2.md'),
|
||||
'utf8',
|
||||
);
|
||||
const rawContent2 = metadataUtils.extractMetadata(doc2).rawContent;
|
||||
const content2 = replaceAssetsLink(rawContent2, 'blog');
|
||||
expect(content2).toMatchSnapshot();
|
||||
expect(content2).not.toContain('');
|
||||
expect(content2).not.toContain('');
|
||||
expect(content2).not.toContain('');
|
||||
expect(content2).toEqual(rawContent2);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue