2
0
mirror of https://github.com/iconify/iconify.git synced 2024-12-12 13:47:49 +00:00

test: add tests for gteCustomIcon and FileSystemIconLoader

This commit is contained in:
Joaquín Sánchez Jiménez 2021-12-12 00:26:58 +01:00 committed by Vjacheslav Trushkin
parent 5cb43cc2d2
commit f9bcf65af7
3 changed files with 33 additions and 0 deletions

View File

@ -0,0 +1 @@
<svg viewBox="0 0 120 120" xmlns="http://www.w3.org/2000/svg"><circle cx="60" cy="60" r="50"/></svg>

After

Width:  |  Height:  |  Size: 101 B

View File

@ -0,0 +1,15 @@
import { FileSystemIconLoader } from '../lib';
describe('Testing FileSystemIconLoader', () => {
test('FileSystemIconLoader', async() => {
const result = await FileSystemIconLoader(__dirname)('circle')
expect(result && result.indexOf('svg') > -1).toBeTruthy();
});
test('FileSystemIconLoader with transform', async() => {
const result = await FileSystemIconLoader(__dirname, (icon) => {
return icon.replace('<svg ', '<svg width="1em", height="1em" ')
})('circle')
expect(result && result.indexOf('width="1em"') > -1).toBeTruthy();
expect(result && result.indexOf('height="1em"') > -1).toBeTruthy();
});
});

View File

@ -0,0 +1,17 @@
import { getCustomIcon } from '../lib';
const svg = '<svg viewBox="0 0 120 120" xmlns="http://www.w3.org/2000/svg"><circle cx="60" cy="60" r="50"/></svg>'
describe('Testing getCustomIcon', () => {
test('CustomIconLoader', async() => {
const result = await getCustomIcon(() => svg, 'a', 'b')
expect(svg).toEqual(result);
});
test('CustomIconLoader with transform', async() => {
const result = await getCustomIcon(() => svg, 'a', 'b', (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();
});
});