mirror of
https://github.com/iconify/iconify.git
synced 2024-12-14 06:28:24 +00:00
41 lines
864 B
JavaScript
41 lines
864 B
JavaScript
|
import { loadIcons, iconExists } from '../../lib/iconify';
|
||
|
import { mockAPIData } from '@iconify/core/lib/api/modules/mock';
|
||
|
import { provider, nextPrefix } from './load';
|
||
|
|
||
|
describe('Testing fake API', () => {
|
||
|
test('using fake API to load icon', (done) => {
|
||
|
const prefix = nextPrefix();
|
||
|
const name = 'mock-test';
|
||
|
const iconName = `@${provider}:${prefix}:${name}`;
|
||
|
mockAPIData({
|
||
|
provider,
|
||
|
prefix,
|
||
|
response: {
|
||
|
prefix,
|
||
|
icons: {
|
||
|
[name]: {
|
||
|
body: '<g />',
|
||
|
},
|
||
|
},
|
||
|
},
|
||
|
});
|
||
|
|
||
|
// Check if icon has been loaded
|
||
|
expect(iconExists(iconName)).toEqual(false);
|
||
|
|
||
|
// Load icon
|
||
|
loadIcons([iconName], (loaded, missing, pending) => {
|
||
|
expect(loaded).toMatchObject([
|
||
|
{
|
||
|
provider,
|
||
|
prefix,
|
||
|
name,
|
||
|
},
|
||
|
]);
|
||
|
expect(missing).toMatchObject([]);
|
||
|
expect(pending).toMatchObject([]);
|
||
|
done();
|
||
|
});
|
||
|
});
|
||
|
});
|