mirror of
https://github.com/facebook/docusaurus.git
synced 2025-12-27 20:02:50 +00:00
37 lines
926 B
JavaScript
37 lines
926 B
JavaScript
/**
|
|
* Copyright (c) 2017-present, Facebook, Inc.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/
|
|
|
|
const toSlug = require('../toSlug');
|
|
|
|
[
|
|
['Hello world! ', 'hello-world'],
|
|
['React 16', 'react-16'],
|
|
['Hello. // (world?)! ', 'hello-world'],
|
|
['Привет мир! ', 'привет-мир'],
|
|
['Über Café.', 'uber-cafe'],
|
|
['Someting long ...', 'someting-long-'],
|
|
].forEach(([input, output]) => {
|
|
test(`toSlug('${input}') -> '${output}'`, () => {
|
|
expect(toSlug(input)).toBe(output);
|
|
});
|
|
});
|
|
|
|
test('unique slugs if `context` argument passed', () => {
|
|
[
|
|
['foo', 'foo'],
|
|
['foo', 'foo-1'],
|
|
['foo 1', 'foo-1-1'],
|
|
['foo 1', 'foo-1-2'],
|
|
['foo 2', 'foo-2'],
|
|
['foo', 'foo-3'],
|
|
].reduce((context, [input, output]) => {
|
|
expect(toSlug(input, context)).toBe(output);
|
|
|
|
return context;
|
|
}, {});
|
|
});
|