mirror of
https://github.com/iconify/iconify.git
synced 2024-11-13 00:06:29 +00:00
86 lines
1.5 KiB
TypeScript
86 lines
1.5 KiB
TypeScript
import { setAPIModule } from '../../lib/api/modules';
|
|
import { loadIcons } from '../../lib/api/icons';
|
|
import { mockAPIModule, mockAPIData } from '../../lib/api/modules/mock';
|
|
import { allowSimpleNames } from '../../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();
|
|
}
|
|
);
|
|
});
|
|
});
|