2
0
mirror of https://github.com/iconify/iconify.git synced 2024-09-20 09:19:02 +00:00
iconify/packages/core/spec/api/simpleNamesSpec.mjs

86 lines
1.5 KiB
JavaScript

import { setAPIModule } from '@iconify/core/lib/api/modules';
import { loadIcons } from '@iconify/core/lib/api/icons';
import { mockAPIModule, mockAPIData } from '@iconify/core/lib/api/modules/mock';
import { allowSimpleNames } from '@iconify/core/lib/storage/functions';
describe('Testing simple names with API module', () => {
// Set API config and allow simple names
beforeEach(() => {
allowSimpleNames(true);
setAPIModule('', mockAPIModule);
});
afterAll(() => {
allowSimpleNames(false);
});
it('Loading icons without prefix', (done) => {
mockAPIData({
type: 'icons',
provider: '',
prefix: '',
response: {
prefix: '',
icons: {
test100: {
body: '<g />',
},
test101: {
body: '<g />',
},
},
},
});
mockAPIData({
type: 'icons',
provider: '',
prefix: 'test200',
response: {
prefix: 'test200',
icons: {
foo: {
body: '<g />',
},
bar: {
body: '<g />',
},
},
},
});
loadIcons(
[
{
provider: '',
prefix: '',
name: 'test100',
},
{
provider: '',
prefix: 'test200',
name: 'foo',
},
],
(loaded, missing, pending) => {
// 'test100' should be missing because it does not have a prefix
expect(loaded).toEqual([
{
provider: '',
prefix: 'test200',
name: 'foo',
},
]);
expect(pending).toEqual([]);
expect(missing).toEqual([
{
provider: '',
prefix: '',
name: 'test100',
},
]);
done();
}
);
});
});