2
0
mirror of https://github.com/iconify/iconify.git synced 2024-12-14 22:46:06 +00:00
iconify/iconify-icon/icon/tests/icon-load-test.ts

58 lines
1.2 KiB
TypeScript
Raw Normal View History

2022-04-29 20:19:22 +00:00
import { parseIconValue } from '../src/attributes/icon/index';
describe('Testing parseIconValue without API', () => {
it('Instantly loading object', () => {
const value = {
body: '<g />',
};
const result = parseIconValue(value, () => {
throw new Error('callback should not have been called');
});
expect(result).toEqual({
value,
data: value,
2022-04-29 20:19:22 +00:00
});
expect(result.value).toBe(value);
});
it('Instantly loading serialised object', () => {
const value = JSON.stringify({
body: '<g />',
});
const result = parseIconValue(value, () => {
throw new Error('callback should not have been called');
});
expect(result).toEqual({
value,
data: {
body: '<g />',
},
});
});
it('Bad data', () => {
const value = '<svg />';
const result = parseIconValue(value, () => {
throw new Error('callback should not have been called');
});
expect(result).toEqual({
value,
});
});
it('Icon without prefix', () => {
const value = 'test';
const result = parseIconValue(value, () => {
throw new Error('callback should not have been called');
});
expect(result).toEqual({
value,
name: {
provider: '',
prefix: '',
name: value,
},
2022-04-29 20:19:22 +00:00
});
});
});