mirror of
https://github.com/svg/svgo.git
synced 2026-01-25 18:41:39 +03:00
Updates the interface for addClassesToSVGElement to match prefixIds, where we'll accept Array<string|function> instead of just a string.
37 lines
903 B
JavaScript
37 lines
903 B
JavaScript
import { optimize } from '../../lib/svgo.js';
|
|
|
|
test('should accept function as className parameter', () => {
|
|
const svg = `<svg xmlns="http://www.w3.org/2000/svg"/>`;
|
|
|
|
expect(
|
|
optimize(svg, {
|
|
path: 'uwu.svg',
|
|
plugins: [
|
|
{
|
|
name: 'addClassesToSVGElement',
|
|
params: {
|
|
classNames: [
|
|
'icon',
|
|
(_, info) => `icon__${info?.path?.split('.')[0]}`,
|
|
],
|
|
},
|
|
},
|
|
],
|
|
}).data,
|
|
).toBe(`<svg xmlns="http://www.w3.org/2000/svg" class="icon icon__uwu"/>`);
|
|
|
|
expect(
|
|
optimize(svg, {
|
|
path: 'uwu.svg',
|
|
plugins: [
|
|
{
|
|
name: 'addClassesToSVGElement',
|
|
params: {
|
|
className: (_, info) => `icon__${info?.path?.split('.')[0]}`,
|
|
},
|
|
},
|
|
],
|
|
}).data,
|
|
).toBe(`<svg xmlns="http://www.w3.org/2000/svg" class="icon__uwu"/>`);
|
|
});
|