mirror of
https://github.com/iconify/iconify.git
synced 2024-11-10 15:20:54 +00:00
1b3680647c
# Conflicts: # packages/utils/package-lock.json # packages/utils/src/loader/loader.ts # packages/utils/src/loader/types.ts # packages/utils/tests/iconify-icon-test.ts
48 lines
1.3 KiB
TypeScript
48 lines
1.3 KiB
TypeScript
import { promises as fs } from 'fs';
|
|
import { getCustomIcon } 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 with transform', async () => {
|
|
const svg = await fs.readFile(fixturesDir + '/circle.svg', 'utf8');
|
|
const result = await getCustomIcon(() => svg, 'a', 'b', {
|
|
customizations: {
|
|
transform(icon) {
|
|
return icon.replace(
|
|
'<svg ',
|
|
'<svg width="1em" height="1em" '
|
|
);
|
|
},
|
|
},
|
|
});
|
|
expect(result && result.indexOf('width="1em"') > -1).toBeTruthy();
|
|
expect(result && result.indexOf('height="1em"') > -1).toBeTruthy();
|
|
});
|
|
|
|
test('Icon with XML heading', async () => {
|
|
// Intercept console.warn
|
|
let warned = false;
|
|
const warn = console.warn;
|
|
console.warn = (/*...args*/) => {
|
|
// warn.apply(this, args);
|
|
warned = true;
|
|
};
|
|
|
|
const svg = await fs.readFile(fixturesDir + '/1f3eb.svg', 'utf8');
|
|
const result = await getCustomIcon(() => svg, 'a', 'b');
|
|
|
|
// Restore console.warn
|
|
console.warn = warn;
|
|
|
|
expect(svg).toEqual(result);
|
|
expect(warned).toEqual(true);
|
|
});
|
|
});
|