mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-10 23:02:56 +02:00
refactor(utils): remove duplicated function (#9972)
Co-authored-by: sebastien <lorber.sebastien@gmail.com>
This commit is contained in:
parent
efbe474e9c
commit
821247142e
24 changed files with 160 additions and 141 deletions
|
@ -7,34 +7,7 @@
|
|||
|
||||
import {jest} from '@jest/globals';
|
||||
import _ from 'lodash';
|
||||
import {
|
||||
removeSuffix,
|
||||
removePrefix,
|
||||
mapAsyncSequential,
|
||||
findAsyncSequential,
|
||||
} from '../jsUtils';
|
||||
|
||||
describe('removeSuffix', () => {
|
||||
it("is no-op when suffix doesn't exist", () => {
|
||||
expect(removeSuffix('abcdef', 'ijk')).toBe('abcdef');
|
||||
expect(removeSuffix('abcdef', 'abc')).toBe('abcdef');
|
||||
expect(removeSuffix('abcdef', '')).toBe('abcdef');
|
||||
});
|
||||
it('removes suffix', () => {
|
||||
expect(removeSuffix('abcdef', 'ef')).toBe('abcd');
|
||||
});
|
||||
});
|
||||
|
||||
describe('removePrefix', () => {
|
||||
it("is no-op when prefix doesn't exist", () => {
|
||||
expect(removePrefix('abcdef', 'ijk')).toBe('abcdef');
|
||||
expect(removePrefix('abcdef', 'def')).toBe('abcdef');
|
||||
expect(removePrefix('abcdef', '')).toBe('abcdef');
|
||||
});
|
||||
it('removes prefix', () => {
|
||||
expect(removePrefix('prefix', 'pre')).toBe('fix');
|
||||
});
|
||||
});
|
||||
import {mapAsyncSequential, findAsyncSequential} from '../jsUtils';
|
||||
|
||||
describe('mapAsyncSequential', () => {
|
||||
function sleep(timeout: number): Promise<void> {
|
||||
|
|
|
@ -10,9 +10,6 @@ import {
|
|||
getEditUrl,
|
||||
fileToPath,
|
||||
isValidPathname,
|
||||
addTrailingSlash,
|
||||
addLeadingSlash,
|
||||
removeTrailingSlash,
|
||||
resolvePathname,
|
||||
encodePath,
|
||||
buildSshUrl,
|
||||
|
@ -207,33 +204,6 @@ describe('isValidPathname', () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe('addTrailingSlash', () => {
|
||||
it('is no-op for path with trailing slash', () => {
|
||||
expect(addTrailingSlash('/abcd/')).toBe('/abcd/');
|
||||
});
|
||||
it('adds / for path without trailing slash', () => {
|
||||
expect(addTrailingSlash('/abcd')).toBe('/abcd/');
|
||||
});
|
||||
});
|
||||
|
||||
describe('addLeadingSlash', () => {
|
||||
it('is no-op for path with leading slash', () => {
|
||||
expect(addLeadingSlash('/abc')).toBe('/abc');
|
||||
});
|
||||
it('adds / for path without leading slash', () => {
|
||||
expect(addLeadingSlash('abc')).toBe('/abc');
|
||||
});
|
||||
});
|
||||
|
||||
describe('removeTrailingSlash', () => {
|
||||
it('is no-op for path without trailing slash', () => {
|
||||
expect(removeTrailingSlash('/abcd')).toBe('/abcd');
|
||||
});
|
||||
it('removes / for path with trailing slash', () => {
|
||||
expect(removeTrailingSlash('/abcd/')).toBe('/abcd');
|
||||
});
|
||||
});
|
||||
|
||||
describe('parseURLPath', () => {
|
||||
it('parse and resolve pathname', () => {
|
||||
expect(parseURLPath('')).toEqual({
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue