mirror of
https://github.com/iconify/iconify.git
synced 2024-12-13 22:18:24 +00:00
42 lines
906 B
TypeScript
42 lines
906 B
TypeScript
import { iconExists } from '@iconify/core/lib/storage/functions';
|
|
import { loadIcon } from '@iconify/core/lib/api/icons';
|
|
import { defaultIconProps } from '@iconify/utils/lib/icon/defaults';
|
|
import { fakeAPI, nextPrefix, mockAPIData } from './helpers';
|
|
|
|
describe('Testing mock API', () => {
|
|
it('Setting up API', async () => {
|
|
// Set config
|
|
const provider = nextPrefix();
|
|
const prefix = nextPrefix();
|
|
fakeAPI(provider);
|
|
|
|
// Mock data
|
|
const name = 'mock-test';
|
|
const iconName = `@${provider}:${prefix}:${name}`;
|
|
|
|
mockAPIData({
|
|
type: 'icons',
|
|
provider,
|
|
prefix,
|
|
response: {
|
|
prefix,
|
|
icons: {
|
|
[name]: {
|
|
body: '<g />',
|
|
},
|
|
},
|
|
},
|
|
});
|
|
|
|
// Check if icon has been loaded
|
|
expect(iconExists(iconName)).toBe(false);
|
|
|
|
// Load icon
|
|
const data = await loadIcon(iconName);
|
|
expect(data).toEqual({
|
|
...defaultIconProps,
|
|
body: '<g />',
|
|
});
|
|
});
|
|
});
|