2
0
mirror of https://github.com/iconify/iconify.git synced 2024-12-13 22:18:24 +00:00
iconify/components/vue2/tests/api/10-api-mock.test.js
2022-09-07 22:11:48 +03:00

47 lines
983 B
JavaScript

/**
* @jest-environment jsdom
*/
import { loadIcons, iconExists } from '../../';
import { mockAPIData } from '@iconify/core/lib/api/modules/mock.cjs';
import { provider, nextPrefix } from './load';
describe('Testing fake API', () => {
test('using fake API to load icon', () => {
return new Promise((fulfill) => {
const prefix = nextPrefix();
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
loadIcons([iconName], (loaded, missing, pending) => {
expect(loaded).toMatchObject([
{
provider,
prefix,
name,
},
]);
expect(missing).toMatchObject([]);
expect(pending).toMatchObject([]);
fulfill(true);
});
});
});
});