mirror of
https://github.com/svg/svgo.git
synced 2025-07-29 20:21:14 +03:00
Ref https://github.com/svg/svgo/issues/1499 - migrated to visitor plugin api - covered with tsdoc - made the plugin idempotent as requested a few times Now even manually running svgo a few times will not duplicate prefix in ids and classes - run each plugin test twice to see which plugin need to run many times ideally idempotent plugins will allow to get rid of multipass option in v3
25 lines
574 B
JavaScript
25 lines
574 B
JavaScript
'use strict';
|
|
|
|
const { optimize } = require('../../lib/svgo.js');
|
|
|
|
test('should extract prefix from path basename', () => {
|
|
const svg = `<svg id="my-id"></svg>`;
|
|
expect(
|
|
optimize(svg, {
|
|
plugins: ['prefixIds'],
|
|
}).data
|
|
).toEqual(`<svg id="prefix__my-id"/>`);
|
|
expect(
|
|
optimize(svg, {
|
|
plugins: ['prefixIds'],
|
|
path: 'input.svg',
|
|
}).data
|
|
).toEqual(`<svg id="input_svg__my-id"/>`);
|
|
expect(
|
|
optimize(svg, {
|
|
plugins: ['prefixIds'],
|
|
path: 'path/to/input.svg',
|
|
}).data
|
|
).toEqual(`<svg id="input_svg__my-id"/>`);
|
|
});
|