mirror of
https://github.com/iconify/iconify.git
synced 2025-01-06 07:20:40 +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,
|
||||
} from './types';
|
||||
import { mergeIconProps } from './utils';
|
||||
import { trimSVG } from '../svg/trim';
|
||||
|
||||
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 () => {
|
||||
const svg = await fs.readFile(fixturesDir + '/circle.svg', 'utf8');
|
||||
const options: IconifyLoaderOptions = {
|
||||
|
Loading…
Reference in New Issue
Block a user