Some checks failed
No response / noResponse (push) Has been cancelled
CI / Continuous releases (push) Has been cancelled
CI / test-dev (macos-latest) (push) Has been cancelled
CI / test-dev (ubuntu-latest) (push) Has been cancelled
CI / test-dev (windows-latest) (push) Has been cancelled
Maintenance / main (push) Has been cancelled
Scorecards supply-chain security / Scorecards analysis (push) Has been cancelled
CodeQL / Analyze (push) Has been cancelled
34 lines
1.3 KiB
JavaScript
34 lines
1.3 KiB
JavaScript
import { expect } from 'chai';
|
|
import { parseInline as renderInlineMarkdown } from 'marked';
|
|
import textToHash from './textToHash.mjs';
|
|
|
|
describe('textToHash', () => {
|
|
it('should hash as expected', () => {
|
|
const table = [
|
|
['createTheme(options) => theme', 'createtheme-options-theme'],
|
|
['Typography - Font family', 'typography-font-family'],
|
|
["barre d'application", 'barre-dapplication'],
|
|
[
|
|
'createGenerateClassName([options]) => class name generator',
|
|
'creategenerateclassname-options-class-name-generator',
|
|
],
|
|
['@mui/material/styles vs @mui/styles', 'mui-material-styles-vs-mui-styles'],
|
|
['Blog 📝', 'blog'],
|
|
];
|
|
table.forEach((entry, index) => {
|
|
const [markdown, expected] = entry;
|
|
// eslint-disable-next-line testing-library/render-result-naming-convention
|
|
const text = renderInlineMarkdown(markdown, { mangle: false, headerIds: false });
|
|
const actual = textToHash(text);
|
|
|
|
expect(actual).to.equal(expected, `snapshot #${index} matches`);
|
|
});
|
|
});
|
|
|
|
it('should generate a unique hash', () => {
|
|
const unique = {};
|
|
expect(textToHash('Styling solution', unique)).to.equal('styling-solution');
|
|
expect(textToHash('Styling solution', unique)).to.equal('styling-solution-2');
|
|
});
|
|
});
|