From 123991c68733fc6bd81d87aa0b514bb33e5444bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joaqu=C3=ADn=20S=C3=A1nchez=20Jim=C3=A9nez?= Date: Mon, 21 Mar 2022 18:38:18 +0100 Subject: [PATCH] test: add trim custom svg + remove unused imports --- packages/utils/src/loader/custom.ts | 1 - packages/utils/src/loader/utils.ts | 4 +++- packages/utils/tests/get-custom-icon-test.ts | 13 +++++++++++++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/packages/utils/src/loader/custom.ts b/packages/utils/src/loader/custom.ts index a7eb746..29c0793 100644 --- a/packages/utils/src/loader/custom.ts +++ b/packages/utils/src/loader/custom.ts @@ -5,7 +5,6 @@ import type { InlineCollection, } from './types'; import { mergeIconProps } from './utils'; -import { trimSVG } from '../svg/trim'; const debug = createDebugger('@iconify-loader:custom'); diff --git a/packages/utils/src/loader/utils.ts b/packages/utils/src/loader/utils.ts index d4706fa..bf77b54 100644 --- a/packages/utils/src/loader/utils.ts +++ b/packages/utils/src/loader/utils.ts @@ -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; } diff --git a/packages/utils/tests/get-custom-icon-test.ts b/packages/utils/tests/get-custom-icon-test.ts index c69246b..3b42bc0 100644 --- a/packages/utils/tests/get-custom-icon-test.ts +++ b/packages/utils/tests/get-custom-icon-test.ts @@ -22,6 +22,19 @@ describe('Testing getCustomIcon', () => { ); }); + test('CustomIconLoader should apply trim', async () => { + const svg = ` + + +`; + const result = await getCustomIcon(() => svg, 'a', 'b', { + customizations: { trimCustomSvg: true }, + }); + expect(result).toEqual( + '' + ); + }); + test("CustomIconLoader with transform: scale/width/height shouldn't take effect", async () => { const svg = await fs.readFile(fixturesDir + '/circle.svg', 'utf8'); const options: IconifyLoaderOptions = {