2
0
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:
Joaquín Sánchez Jiménez 2022-03-21 18:38:18 +01:00
parent e506d76843
commit 123991c687
3 changed files with 16 additions and 2 deletions

View File

@ -5,7 +5,6 @@ import type {
InlineCollection,
} from './types';
import { mergeIconProps } from './utils';
import { trimSVG } from '../svg/trim';
const debug = createDebugger('@iconify-loader:custom');

View File

@ -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;
}

View File

@ -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 = {