mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-16 18:46:57 +02:00
test: add test for readOutputHTMLFile (#6506)
This commit is contained in:
parent
8bdecf107c
commit
58e07a6796
7 changed files with 87 additions and 215 deletions
|
@ -26,6 +26,7 @@ import {
|
|||
generate,
|
||||
reportMessage,
|
||||
posixPath,
|
||||
readOutputHTMLFile,
|
||||
} from '../index';
|
||||
import {sum} from 'lodash';
|
||||
import fs from 'fs-extra';
|
||||
|
@ -362,6 +363,71 @@ describe('findAsyncSequential', () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe('readOutputHTMLFile', () => {
|
||||
test('trailing slash undefined', async () => {
|
||||
await expect(
|
||||
readOutputHTMLFile(
|
||||
'/file',
|
||||
path.join(__dirname, '__fixtures__/build-snap'),
|
||||
undefined,
|
||||
).then(String),
|
||||
).resolves.toEqual('file\n');
|
||||
await expect(
|
||||
readOutputHTMLFile(
|
||||
'/folder',
|
||||
path.join(__dirname, '__fixtures__/build-snap'),
|
||||
undefined,
|
||||
).then(String),
|
||||
).resolves.toEqual('folder\n');
|
||||
await expect(
|
||||
readOutputHTMLFile(
|
||||
'/file/',
|
||||
path.join(__dirname, '__fixtures__/build-snap'),
|
||||
undefined,
|
||||
).then(String),
|
||||
).resolves.toEqual('file\n');
|
||||
await expect(
|
||||
readOutputHTMLFile(
|
||||
'/folder/',
|
||||
path.join(__dirname, '__fixtures__/build-snap'),
|
||||
undefined,
|
||||
).then(String),
|
||||
).resolves.toEqual('folder\n');
|
||||
});
|
||||
test('trailing slash true', async () => {
|
||||
await expect(
|
||||
readOutputHTMLFile(
|
||||
'/folder',
|
||||
path.join(__dirname, '__fixtures__/build-snap'),
|
||||
true,
|
||||
).then(String),
|
||||
).resolves.toEqual('folder\n');
|
||||
await expect(
|
||||
readOutputHTMLFile(
|
||||
'/folder/',
|
||||
path.join(__dirname, '__fixtures__/build-snap'),
|
||||
true,
|
||||
).then(String),
|
||||
).resolves.toEqual('folder\n');
|
||||
});
|
||||
test('trailing slash false', async () => {
|
||||
await expect(
|
||||
readOutputHTMLFile(
|
||||
'/file',
|
||||
path.join(__dirname, '__fixtures__/build-snap'),
|
||||
false,
|
||||
).then(String),
|
||||
).resolves.toEqual('file\n');
|
||||
await expect(
|
||||
readOutputHTMLFile(
|
||||
'/file/',
|
||||
path.join(__dirname, '__fixtures__/build-snap'),
|
||||
false,
|
||||
).then(String),
|
||||
).resolves.toEqual('file\n');
|
||||
});
|
||||
});
|
||||
|
||||
describe('updateTranslationFileMessages', () => {
|
||||
test('should update messages', () => {
|
||||
expect(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue