2
0
mirror of https://github.com/iconify/iconify.git synced 2024-12-14 14:38:25 +00:00
iconify/components/vue/tests/api/10-api-mock-test.ts

44 lines
947 B
TypeScript
Raw Normal View History

import { loadIcons, iconLoaded } 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', () => {
2022-09-07 19:11:48 +00:00
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,
2021-05-06 08:21:39 +00:00
prefix,
2022-09-07 19:11:48 +00:00
response: {
prefix,
icons: {
[name]: {
body: '<g />',
},
2021-05-06 08:21:39 +00:00
},
},
2022-09-07 19:11:48 +00:00
});
2021-05-06 08:21:39 +00:00
2022-09-07 19:11:48 +00:00
// Check if icon has been loaded
expect(iconLoaded(iconName)).toEqual(false);
2021-05-06 08:21:39 +00:00
2022-09-07 19:11:48 +00:00
// Load icon
loadIcons([iconName], (loaded, missing, pending) => {
expect(loaded).toMatchObject([
{
provider,
prefix,
name,
},
]);
expect(missing).toMatchObject([]);
expect(pending).toMatchObject([]);
fulfill(true);
});
2021-05-06 08:21:39 +00:00
});
});
});