From 996051c963f19e52f667ad2e58a3b7316528d441 Mon Sep 17 00:00:00 2001 From: gin-lsl Date: Fri, 22 Dec 2023 22:41:58 +0800 Subject: [PATCH] test: add icon path id test --- packages/icons/src/__tests__/index.test.tsx | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/packages/icons/src/__tests__/index.test.tsx b/packages/icons/src/__tests__/index.test.tsx index d4e715a62..7e6d7ac63 100644 --- a/packages/icons/src/__tests__/index.test.tsx +++ b/packages/icons/src/__tests__/index.test.tsx @@ -10,4 +10,20 @@ describe('Test Icons', () => { expect(container.firstChild).toMatchSnapshot(); }); }); + + it('icon path referenced id should start with `ant-web3-icon-`', async () => { + const comps = await getComponents('components'); + + comps.forEach((Comp) => { + const { container } = render(); + + const pathWithFill = container.querySelectorAll('path[fill^="url(#"]'); + + // The `id` referenced by the `fill` attr of the `path` element + // must start with `ant-web3-icon-` + pathWithFill.forEach((path) => { + expect(path.getAttribute('fill')).toMatch(/^url\(#ant-web3-icon-/); + }); + }); + }); });