import { promises as fs } from 'fs';
import { getCustomIcon } from '../lib';
import type { IconifyLoaderOptions } from '../lib';
const fixturesDir = './tests/fixtures';
describe('Testing getCustomIcon', () => {
test('CustomIconLoader', async () => {
const svg = await fs.readFile(fixturesDir + '/circle.svg', 'utf8');
const result = await getCustomIcon(() => svg, 'a', 'b');
expect(svg).toEqual(result);
});
test('CustomIconLoader without xmlns', async () => {
const svg =
'';
const result = await getCustomIcon(() => svg, 'a', 'b', {
addXmlNs: true,
});
expect(result).toEqual(
''
);
});
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 = {
scale: 2,
customizations: {
additionalProps: {
width: '4em',
height: '4em',
},
transform(icon) {
return icon.replace(
'