docusaurus/packages/docusaurus-utils/src/__tests__/webpackUtils.test.ts
Erick Zhao 0c6165b161
fix(utils): make SVGO not remove title (#6684)
* chore(utils): add `removeTitle: false` to svg loader

By default, SVGR removes the `<title>` tag from SVG inputs.
This hinders a11y since "the `<title>` element provides an
accessible, short-text description of any SVG container
element or graphics element".

Modern browsers also show tooltips on hover for inline
SVG with the `<title>` tag.

See https://developer.mozilla.org/en-US/docs/Web/SVG/Element/title

* fix test
2022-02-15 17:14:54 +08:00

34 lines
949 B
TypeScript

/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import {getFileLoaderUtils} from '../webpackUtils';
describe('getFileLoaderUtils()', () => {
test('plugin svgo/removeViewBox and removeTitle should be disabled', () => {
const {oneOf} = getFileLoaderUtils().rules.svg();
expect(oneOf[0].use).toContainEqual(
expect.objectContaining({
loader: require.resolve('@svgr/webpack'),
options: expect.objectContaining({
svgoConfig: {
plugins: [
{
name: 'preset-default',
params: {
overrides: {
removeTitle: false,
removeViewBox: false,
},
},
},
],
},
}),
}),
);
});
});