mirror of
https://github.com/iconify/iconify.git
synced 2024-11-09 14:50:56 +00:00
chore: publish update for utils with few more unit tests
This commit is contained in:
parent
9d93ba8272
commit
78f71407d5
@ -3,7 +3,7 @@
|
||||
"type": "module",
|
||||
"description": "Common functions for working with Iconify icon sets used by various packages.",
|
||||
"author": "Vjacheslav Trushkin",
|
||||
"version": "2.1.1",
|
||||
"version": "2.1.2",
|
||||
"license": "MIT",
|
||||
"bugs": "https://github.com/iconify/iconify/issues",
|
||||
"homepage": "https://iconify.design/",
|
||||
|
@ -106,6 +106,18 @@ describe('Testing getCustomIcon', () => {
|
||||
});
|
||||
|
||||
test('Scale custom icon', async () => {
|
||||
const svg =
|
||||
'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path d="M139.61 35.5a12 12 0 0 0-17 0L58.93 98.81l-22.7-22.12a12 12 0 0 0-17 0L3.53 92.41a12 12 0 0 0 0 17l47.59 47.4a12.78 12.78 0 0 0 17.61 0l15.59-15.62L156.52 69a12.09 12.09 0 0 0 .09-17zm0 159.19a12 12 0 0 0-17 0l-63.68 63.72-22.7-22.1a12 12 0 0 0-17 0L3.53 252a12 12 0 0 0 0 17L51 316.5a12.77 12.77 0 0 0 17.6 0l15.7-15.69 72.2-72.22a12 12 0 0 0 .09-16.9zM64 368c-26.49 0-48.59 21.5-48.59 48S37.53 464 64 464a48 48 0 0 0 0-96zm432 16H208a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h288a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16zm0-320H208a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h288a16 16 0 0 0 16-16V80a16 16 0 0 0-16-16zm0 160H208a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h288a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16z"/></svg>';
|
||||
|
||||
const options: IconifyLoaderOptions = {
|
||||
scale: 2,
|
||||
};
|
||||
const result = await getCustomIcon(() => svg, 'a', 'b', options);
|
||||
expect(result && result.indexOf(' width="2em"') > -1).toBeTruthy();
|
||||
expect(result && result.indexOf(' height="2em"') > -1).toBeTruthy();
|
||||
});
|
||||
|
||||
test('Scale custom icon with stroke-width', async () => {
|
||||
const svg = `<?xml version="1.0" standalone="no"?>
|
||||
<svg fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" viewBox="0 0 24 24"
|
||||
stroke="currentColor">
|
||||
@ -119,4 +131,16 @@ describe('Testing getCustomIcon', () => {
|
||||
expect(result && result.indexOf(' width="1.2em"') > -1).toBeTruthy();
|
||||
expect(result && result.indexOf(' height="1.2em"') > -1).toBeTruthy();
|
||||
});
|
||||
|
||||
test('Disable scale for custom icon', async () => {
|
||||
const svg =
|
||||
'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path d="M139.61 35.5a12 12 0 0 0-17 0L58.93 98.81l-22.7-22.12a12 12 0 0 0-17 0L3.53 92.41a12 12 0 0 0 0 17l47.59 47.4a12.78 12.78 0 0 0 17.61 0l15.59-15.62L156.52 69a12.09 12.09 0 0 0 .09-17zm0 159.19a12 12 0 0 0-17 0l-63.68 63.72-22.7-22.1a12 12 0 0 0-17 0L3.53 252a12 12 0 0 0 0 17L51 316.5a12.77 12.77 0 0 0 17.6 0l15.7-15.69 72.2-72.22a12 12 0 0 0 .09-16.9zM64 368c-26.49 0-48.59 21.5-48.59 48S37.53 464 64 464a48 48 0 0 0 0-96zm432 16H208a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h288a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16zm0-320H208a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h288a16 16 0 0 0 16-16V80a16 16 0 0 0-16-16zm0 160H208a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h288a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16z"/></svg>';
|
||||
|
||||
const options: IconifyLoaderOptions = {
|
||||
scale: 0,
|
||||
};
|
||||
const result = await getCustomIcon(() => svg, 'a', 'b', options);
|
||||
expect(result && result.indexOf(' width="') === -1).toBeTruthy();
|
||||
expect(result && result.indexOf(' height="') === -1).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user