mirror of
https://github.com/facebook/docusaurus.git
synced 2025-07-31 07:18:59 +02:00
refactor: prefer fs.outputFile to ensureDir + writeFile (#6880)
* refactor: prefer fs.outputFile to ensureDir + writeFile * fix test * fix
This commit is contained in:
parent
73df485aec
commit
23a34c1a07
15 changed files with 66 additions and 108 deletions
|
@ -186,8 +186,7 @@ describe('docsVersion', () => {
|
|||
|
||||
test('first time versioning', async () => {
|
||||
const copyMock = jest.spyOn(fs, 'copy').mockImplementation();
|
||||
const ensureMock = jest.spyOn(fs, 'ensureDir').mockImplementation();
|
||||
const writeMock = jest.spyOn(fs, 'writeFile');
|
||||
const writeMock = jest.spyOn(fs, 'outputFile');
|
||||
let versionedSidebar;
|
||||
let versionedSidebarPath;
|
||||
writeMock.mockImplementationOnce((filepath, content) => {
|
||||
|
@ -238,13 +237,11 @@ describe('docsVersion', () => {
|
|||
copyMock.mockRestore();
|
||||
writeMock.mockRestore();
|
||||
consoleMock.mockRestore();
|
||||
ensureMock.mockRestore();
|
||||
});
|
||||
|
||||
test('not the first time versioning', async () => {
|
||||
const copyMock = jest.spyOn(fs, 'copy').mockImplementation();
|
||||
const ensureMock = jest.spyOn(fs, 'ensureDir').mockImplementation();
|
||||
const writeMock = jest.spyOn(fs, 'writeFile');
|
||||
const writeMock = jest.spyOn(fs, 'outputFile');
|
||||
let versionedSidebar;
|
||||
let versionedSidebarPath;
|
||||
writeMock.mockImplementationOnce((filepath, content) => {
|
||||
|
@ -295,15 +292,13 @@ describe('docsVersion', () => {
|
|||
copyMock.mockRestore();
|
||||
writeMock.mockRestore();
|
||||
consoleMock.mockRestore();
|
||||
ensureMock.mockRestore();
|
||||
});
|
||||
|
||||
test('second docs instance versioning', async () => {
|
||||
const pluginId = 'community';
|
||||
|
||||
const copyMock = jest.spyOn(fs, 'copy').mockImplementation();
|
||||
const ensureMock = jest.spyOn(fs, 'ensureDir').mockImplementation();
|
||||
const writeMock = jest.spyOn(fs, 'writeFile');
|
||||
const writeMock = jest.spyOn(fs, 'outputFile');
|
||||
let versionedSidebar;
|
||||
let versionedSidebarPath;
|
||||
writeMock.mockImplementationOnce((filepath, content) => {
|
||||
|
@ -350,6 +345,5 @@ describe('docsVersion', () => {
|
|||
copyMock.mockRestore();
|
||||
writeMock.mockRestore();
|
||||
consoleMock.mockRestore();
|
||||
ensureMock.mockRestore();
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue