mirror of
https://github.com/iconify/iconify.git
synced 2025-01-08 15:54:09 +00:00
test: add trim custom svg + remove unused imports
This commit is contained in:
parent
e506d76843
commit
123991c687
@ -5,7 +5,6 @@ import type {
|
|||||||
InlineCollection,
|
InlineCollection,
|
||||||
} from './types';
|
} from './types';
|
||||||
import { mergeIconProps } from './utils';
|
import { mergeIconProps } from './utils';
|
||||||
import { trimSVG } from '../svg/trim';
|
|
||||||
|
|
||||||
const debug = createDebugger('@iconify-loader:custom');
|
const debug = createDebugger('@iconify-loader:custom');
|
||||||
|
|
||||||
|
@ -109,5 +109,7 @@ export async function mergeIconProps(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return customSvg && options?.customizations?.trimCustomSvg === true ? trimSVG(svg) : svg;
|
return customSvg && options?.customizations?.trimCustomSvg === true
|
||||||
|
? trimSVG(svg)
|
||||||
|
: svg;
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,19 @@ describe('Testing getCustomIcon', () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('CustomIconLoader should apply trim', async () => {
|
||||||
|
const svg = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 120 120">
|
||||||
|
<circle cx="60" cy="60" r="50"/>
|
||||||
|
</svg>
|
||||||
|
`;
|
||||||
|
const result = await getCustomIcon(() => svg, 'a', 'b', {
|
||||||
|
customizations: { trimCustomSvg: true },
|
||||||
|
});
|
||||||
|
expect(result).toEqual(
|
||||||
|
'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 120 120"><circle cx="60" cy="60" r="50"/></svg>'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
test("CustomIconLoader with transform: scale/width/height shouldn't take effect", async () => {
|
test("CustomIconLoader with transform: scale/width/height shouldn't take effect", async () => {
|
||||||
const svg = await fs.readFile(fixturesDir + '/circle.svg', 'utf8');
|
const svg = await fs.readFile(fixturesDir + '/circle.svg', 'utf8');
|
||||||
const options: IconifyLoaderOptions = {
|
const options: IconifyLoaderOptions = {
|
||||||
|
Loading…
Reference in New Issue
Block a user