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:
parent
5cb43cc2d2
commit
f9bcf65af7
1
packages/utils/tests/circle.svg
Normal file
1
packages/utils/tests/circle.svg
Normal 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 |
15
packages/utils/tests/file-system-icon-test.ts
Normal file
15
packages/utils/tests/file-system-icon-test.ts
Normal 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();
|
||||
});
|
||||
});
|
17
packages/utils/tests/get-custom-icon-test.ts
Normal file
17
packages/utils/tests/get-custom-icon-test.ts
Normal 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();
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue
Block a user