2021-09-27 13:58:47 +00:00
|
|
|
/**
|
|
|
|
* @jest-environment jsdom
|
|
|
|
*/
|
|
|
|
import { loadIcons, iconExists } from '../../';
|
2021-05-06 08:21:39 +00:00
|
|
|
import { mockAPIData } from '@iconify/core/lib/api/modules/mock';
|
|
|
|
import { provider, nextPrefix } from './load';
|
|
|
|
|
|
|
|
describe('Testing fake API', () => {
|
2021-09-27 13:58:47 +00:00
|
|
|
test('using fake API to load icon', (done) => {
|
2021-05-06 08:21:39 +00:00
|
|
|
const prefix = nextPrefix();
|
|
|
|
const name = 'mock-test';
|
|
|
|
const iconName = `@${provider}:${prefix}:${name}`;
|
|
|
|
mockAPIData({
|
2021-09-05 16:09:25 +00:00
|
|
|
type: 'icons',
|
2021-05-06 08:21:39 +00:00
|
|
|
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();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|