mirror of
https://github.com/iconify/iconify.git
synced 2024-11-17 01:55:09 +00:00
chore: rename badly named iconExists to iconLoaded
This commit is contained in:
parent
4765dc962f
commit
617f394b30
@ -5,7 +5,7 @@ import type { IconifyIconName } from '@iconify/utils/lib/icon/name';
|
|||||||
import type { IconifyIconSize } from '@iconify/utils/lib/customisations/defaults';
|
import type { IconifyIconSize } from '@iconify/utils/lib/customisations/defaults';
|
||||||
import type { IconifyStorageFunctions } from '@iconify/core/lib/storage/functions';
|
import type { IconifyStorageFunctions } from '@iconify/core/lib/storage/functions';
|
||||||
import {
|
import {
|
||||||
iconExists,
|
iconLoaded,
|
||||||
getIcon,
|
getIcon,
|
||||||
addIcon,
|
addIcon,
|
||||||
addCollection,
|
addCollection,
|
||||||
@ -225,7 +225,14 @@ export { _api };
|
|||||||
export { addAPIProvider, loadIcons, loadIcon };
|
export { addAPIProvider, loadIcons, loadIcon };
|
||||||
|
|
||||||
// IconifyStorageFunctions
|
// IconifyStorageFunctions
|
||||||
export { iconExists, getIcon, listIcons, addIcon, addCollection };
|
export {
|
||||||
|
iconLoaded,
|
||||||
|
iconLoaded as iconExists, // deprecated, kept to avoid breaking changes
|
||||||
|
getIcon,
|
||||||
|
listIcons,
|
||||||
|
addIcon,
|
||||||
|
addCollection,
|
||||||
|
};
|
||||||
|
|
||||||
// IconifyBuilderFunctions
|
// IconifyBuilderFunctions
|
||||||
export { replaceIDs, calculateSize, buildIcon };
|
export { replaceIDs, calculateSize, buildIcon };
|
||||||
|
@ -9,7 +9,7 @@ import { stringToIcon } from '@iconify/utils/lib/icon/name';
|
|||||||
import type { IconifyIconSize } from '@iconify/utils/lib/customisations/defaults';
|
import type { IconifyIconSize } from '@iconify/utils/lib/customisations/defaults';
|
||||||
import type { IconifyStorageFunctions } from '@iconify/core/lib/storage/functions';
|
import type { IconifyStorageFunctions } from '@iconify/core/lib/storage/functions';
|
||||||
import {
|
import {
|
||||||
iconExists,
|
iconLoaded,
|
||||||
getIcon,
|
getIcon,
|
||||||
addIcon,
|
addIcon,
|
||||||
addCollection,
|
addCollection,
|
||||||
@ -475,7 +475,14 @@ export { _api };
|
|||||||
export { addAPIProvider, loadIcons, loadIcon };
|
export { addAPIProvider, loadIcons, loadIcon };
|
||||||
|
|
||||||
// IconifyStorageFunctions
|
// IconifyStorageFunctions
|
||||||
export { iconExists, getIcon, listIcons, addIcon, addCollection };
|
export {
|
||||||
|
iconLoaded,
|
||||||
|
iconLoaded as iconExists, // deprecated, kept to avoid breaking changes
|
||||||
|
getIcon,
|
||||||
|
listIcons,
|
||||||
|
addIcon,
|
||||||
|
addCollection,
|
||||||
|
};
|
||||||
|
|
||||||
// IconifyBuilderFunctions
|
// IconifyBuilderFunctions
|
||||||
export { replaceIDs, calculateSize, buildIcon };
|
export { replaceIDs, calculateSize, buildIcon };
|
||||||
|
@ -31,9 +31,9 @@ describe('Rendering as span', () => {
|
|||||||
'height': '1em',
|
'height': '1em',
|
||||||
'display': 'inline-block',
|
'display': 'inline-block',
|
||||||
'backgroundColor': 'currentColor',
|
'backgroundColor': 'currentColor',
|
||||||
'webkitMaskImage': 'var(--svg)',
|
// 'webkitMaskImage': 'var(--svg)',
|
||||||
'webkitMaskRepeat': 'no-repeat',
|
// 'webkitMaskRepeat': 'no-repeat',
|
||||||
'webkitMaskSize': '100% 100%',
|
// 'webkitMaskSize': '100% 100%',
|
||||||
'maskImage': 'var(--svg)',
|
'maskImage': 'var(--svg)',
|
||||||
'maskRepeat': 'no-repeat',
|
'maskRepeat': 'no-repeat',
|
||||||
'maskSize': '100% 100%',
|
'maskSize': '100% 100%',
|
||||||
@ -67,9 +67,9 @@ describe('Rendering as span', () => {
|
|||||||
'height': '48px',
|
'height': '48px',
|
||||||
'display': 'inline-block',
|
'display': 'inline-block',
|
||||||
'backgroundColor': 'currentColor',
|
'backgroundColor': 'currentColor',
|
||||||
'webkitMaskImage': 'var(--svg)',
|
// 'webkitMaskImage': 'var(--svg)',
|
||||||
'webkitMaskRepeat': 'no-repeat',
|
// 'webkitMaskRepeat': 'no-repeat',
|
||||||
'webkitMaskSize': '100% 100%',
|
// 'webkitMaskSize': '100% 100%',
|
||||||
'maskImage': 'var(--svg)',
|
'maskImage': 'var(--svg)',
|
||||||
'maskRepeat': 'no-repeat',
|
'maskRepeat': 'no-repeat',
|
||||||
'maskSize': '100% 100%',
|
'maskSize': '100% 100%',
|
||||||
|
@ -5,7 +5,8 @@
|
|||||||
import {
|
import {
|
||||||
enableCache,
|
enableCache,
|
||||||
disableCache,
|
disableCache,
|
||||||
iconExists,
|
iconLoaded,
|
||||||
|
iconExists, // deprecated, kept to avoid breaking changes
|
||||||
getIcon,
|
getIcon,
|
||||||
listIcons,
|
listIcons,
|
||||||
addIcon,
|
addIcon,
|
||||||
@ -22,7 +23,8 @@ import {
|
|||||||
export {
|
export {
|
||||||
enableCache,
|
enableCache,
|
||||||
disableCache,
|
disableCache,
|
||||||
iconExists,
|
iconLoaded,
|
||||||
|
iconExists, // deprecated, kept to avoid breaking changes
|
||||||
getIcon,
|
getIcon,
|
||||||
listIcons,
|
listIcons,
|
||||||
addIcon,
|
addIcon,
|
||||||
|
@ -6,7 +6,7 @@ import { stringToIcon } from '@iconify/utils/lib/icon/name';
|
|||||||
import type { IconifyIconSize } from '@iconify/utils/lib/customisations/defaults';
|
import type { IconifyIconSize } from '@iconify/utils/lib/customisations/defaults';
|
||||||
import type { IconifyStorageFunctions } from '@iconify/core/lib/storage/functions';
|
import type { IconifyStorageFunctions } from '@iconify/core/lib/storage/functions';
|
||||||
import {
|
import {
|
||||||
iconExists,
|
iconLoaded,
|
||||||
getIcon,
|
getIcon,
|
||||||
addIcon,
|
addIcon,
|
||||||
addCollection,
|
addCollection,
|
||||||
@ -363,7 +363,14 @@ export { _api };
|
|||||||
export { addAPIProvider, loadIcons, loadIcon };
|
export { addAPIProvider, loadIcons, loadIcon };
|
||||||
|
|
||||||
// IconifyStorageFunctions
|
// IconifyStorageFunctions
|
||||||
export { iconExists, getIcon, listIcons, addIcon, addCollection };
|
export {
|
||||||
|
iconLoaded,
|
||||||
|
iconLoaded as iconExists, // deprecated, kept to avoid breaking changes
|
||||||
|
getIcon,
|
||||||
|
listIcons,
|
||||||
|
addIcon,
|
||||||
|
addCollection,
|
||||||
|
};
|
||||||
|
|
||||||
// IconifyBuilderFunctions
|
// IconifyBuilderFunctions
|
||||||
export { replaceIDs, calculateSize, buildIcon };
|
export { replaceIDs, calculateSize, buildIcon };
|
||||||
|
@ -50,7 +50,8 @@ export { IconifyIconOnLoad } from './functions';
|
|||||||
export { enableCache, disableCache } from './functions';
|
export { enableCache, disableCache } from './functions';
|
||||||
|
|
||||||
export {
|
export {
|
||||||
iconExists,
|
iconLoaded,
|
||||||
|
iconExists, // deprecated, kept to avoid breaking changes
|
||||||
getIcon,
|
getIcon,
|
||||||
listIcons,
|
listIcons,
|
||||||
addIcon,
|
addIcon,
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/**
|
/**
|
||||||
* @jest-environment jsdom
|
* @jest-environment jsdom
|
||||||
*/
|
*/
|
||||||
import { loadIcons, iconExists } from '../../dist';
|
import { loadIcons, iconLoaded } from '../../dist';
|
||||||
import { mockAPIData } from '@iconify/core/lib/api/modules/mock';
|
import { mockAPIData } from '@iconify/core/lib/api/modules/mock';
|
||||||
import { provider, nextPrefix } from './load';
|
import { provider, nextPrefix } from './load';
|
||||||
|
|
||||||
@ -26,7 +26,7 @@ describe('Testing fake API', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Check if icon has been loaded
|
// Check if icon has been loaded
|
||||||
expect(iconExists(iconName)).toBe(false);
|
expect(iconLoaded(iconName)).toBe(false);
|
||||||
|
|
||||||
// Load icon
|
// Load icon
|
||||||
loadIcons([iconName], (loaded, missing, pending) => {
|
loadIcons([iconName], (loaded, missing, pending) => {
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
*/
|
*/
|
||||||
import { tick } from 'svelte';
|
import { tick } from 'svelte';
|
||||||
import { render } from '@testing-library/svelte';
|
import { render } from '@testing-library/svelte';
|
||||||
import Icon, { loadIcons, iconExists } from '../../dist';
|
import Icon, { loadIcons, iconLoaded } from '../../dist';
|
||||||
import { mockAPIData } from '@iconify/core/lib/api/modules/mock';
|
import { mockAPIData } from '@iconify/core/lib/api/modules/mock';
|
||||||
import { provider, nextPrefix } from './load';
|
import { provider, nextPrefix } from './load';
|
||||||
|
|
||||||
@ -35,7 +35,7 @@ describe('Rendering icon', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Check if icon has been loaded
|
// Check if icon has been loaded
|
||||||
expect(iconExists(iconName)).toBe(false);
|
expect(iconLoaded(iconName)).toBe(false);
|
||||||
|
|
||||||
// Load icon
|
// Load icon
|
||||||
loadIcons([iconName], (loaded, missing, pending) => {
|
loadIcons([iconName], (loaded, missing, pending) => {
|
||||||
@ -49,7 +49,7 @@ describe('Rendering icon', () => {
|
|||||||
]);
|
]);
|
||||||
expect(missing).toMatchObject([]);
|
expect(missing).toMatchObject([]);
|
||||||
expect(pending).toMatchObject([]);
|
expect(pending).toMatchObject([]);
|
||||||
expect(iconExists(iconName)).toBe(true);
|
expect(iconLoaded(iconName)).toBe(true);
|
||||||
|
|
||||||
// Render component
|
// Render component
|
||||||
const component = render(Icon, {
|
const component = render(Icon, {
|
||||||
@ -98,7 +98,7 @@ describe('Rendering icon', () => {
|
|||||||
},
|
},
|
||||||
delay: (next) => {
|
delay: (next) => {
|
||||||
// Icon should not have loaded yet
|
// Icon should not have loaded yet
|
||||||
expect(iconExists(iconName)).toBe(false);
|
expect(iconLoaded(iconName)).toBe(false);
|
||||||
|
|
||||||
// onLoad should not have been called yet
|
// onLoad should not have been called yet
|
||||||
expect(onLoadCalled).toBe(false);
|
expect(onLoadCalled).toBe(false);
|
||||||
@ -107,12 +107,12 @@ describe('Rendering icon', () => {
|
|||||||
next();
|
next();
|
||||||
|
|
||||||
// Test it again
|
// Test it again
|
||||||
expect(iconExists(iconName)).toBe(true);
|
expect(iconLoaded(iconName)).toBe(true);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
// Check if icon has been loaded
|
// Check if icon has been loaded
|
||||||
expect(iconExists(iconName)).toBe(false);
|
expect(iconLoaded(iconName)).toBe(false);
|
||||||
|
|
||||||
// Render component
|
// Render component
|
||||||
const component = render(Icon, {
|
const component = render(Icon, {
|
||||||
@ -167,13 +167,13 @@ describe('Rendering icon', () => {
|
|||||||
response: 404,
|
response: 404,
|
||||||
delay: (next) => {
|
delay: (next) => {
|
||||||
// Icon should not have loaded yet
|
// Icon should not have loaded yet
|
||||||
expect(iconExists(iconName)).toBe(false);
|
expect(iconLoaded(iconName)).toBe(false);
|
||||||
|
|
||||||
// Send icon data
|
// Send icon data
|
||||||
next();
|
next();
|
||||||
|
|
||||||
// Test it again
|
// Test it again
|
||||||
expect(iconExists(iconName)).toBe(false);
|
expect(iconLoaded(iconName)).toBe(false);
|
||||||
|
|
||||||
// Check if state was changed on next few ticks
|
// Check if state was changed on next few ticks
|
||||||
tick()
|
tick()
|
||||||
@ -203,7 +203,7 @@ describe('Rendering icon', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Check if icon has been loaded
|
// Check if icon has been loaded
|
||||||
expect(iconExists(iconName)).toBe(false);
|
expect(iconLoaded(iconName)).toBe(false);
|
||||||
|
|
||||||
// Render component
|
// Render component
|
||||||
const component = render(Icon, {
|
const component = render(Icon, {
|
||||||
|
@ -5,7 +5,7 @@ import type { IconifyIconSize } from '@iconify/utils/lib/customisations/defaults
|
|||||||
import type { IconifyIconBuildResult } from '@iconify/utils/lib/svg/build';
|
import type { IconifyIconBuildResult } from '@iconify/utils/lib/svg/build';
|
||||||
import type { IconifyStorageFunctions } from '@iconify/core/lib/storage/functions';
|
import type { IconifyStorageFunctions } from '@iconify/core/lib/storage/functions';
|
||||||
import {
|
import {
|
||||||
iconExists,
|
iconLoaded,
|
||||||
getIcon,
|
getIcon,
|
||||||
addIcon,
|
addIcon,
|
||||||
addCollection,
|
addCollection,
|
||||||
@ -206,7 +206,8 @@ const Iconify: IconifyGlobal = {
|
|||||||
loadIcon,
|
loadIcon,
|
||||||
|
|
||||||
// IconifyStorageFunctions
|
// IconifyStorageFunctions
|
||||||
iconExists,
|
iconLoaded,
|
||||||
|
iconExists: iconLoaded, // deprecated, kept to avoid breaking changes
|
||||||
getIcon,
|
getIcon,
|
||||||
listIcons,
|
listIcons,
|
||||||
addIcon,
|
addIcon,
|
||||||
@ -248,7 +249,14 @@ export { _api };
|
|||||||
export { addAPIProvider, loadIcons, loadIcon };
|
export { addAPIProvider, loadIcons, loadIcon };
|
||||||
|
|
||||||
// IconifyStorageFunctions
|
// IconifyStorageFunctions
|
||||||
export { iconExists, getIcon, listIcons, addIcon, addCollection };
|
export {
|
||||||
|
iconLoaded,
|
||||||
|
iconLoaded as iconExists, // deprecated, kept to avoid breaking changes
|
||||||
|
getIcon,
|
||||||
|
listIcons,
|
||||||
|
addIcon,
|
||||||
|
addCollection,
|
||||||
|
};
|
||||||
|
|
||||||
// IconifyBuilderFunctions
|
// IconifyBuilderFunctions
|
||||||
export { replaceIDs, calculateSize, buildIcon };
|
export { replaceIDs, calculateSize, buildIcon };
|
||||||
|
@ -5,7 +5,7 @@ import type { IconifyIconSize } from '@iconify/utils/lib/customisations/defaults
|
|||||||
import type { IconifyIconBuildResult } from '@iconify/utils/lib/svg/build';
|
import type { IconifyIconBuildResult } from '@iconify/utils/lib/svg/build';
|
||||||
import type { IconifyStorageFunctions } from '@iconify/core/lib/storage/functions';
|
import type { IconifyStorageFunctions } from '@iconify/core/lib/storage/functions';
|
||||||
import {
|
import {
|
||||||
iconExists,
|
iconLoaded,
|
||||||
getIcon,
|
getIcon,
|
||||||
addIcon,
|
addIcon,
|
||||||
addCollection,
|
addCollection,
|
||||||
@ -58,7 +58,8 @@ export interface IconifyGlobal
|
|||||||
*/
|
*/
|
||||||
const Iconify: IconifyGlobal = {
|
const Iconify: IconifyGlobal = {
|
||||||
// IconifyStorageFunctions
|
// IconifyStorageFunctions
|
||||||
iconExists,
|
iconLoaded,
|
||||||
|
iconExists: iconLoaded, // deprecated, kept to avoid breaking changes
|
||||||
getIcon,
|
getIcon,
|
||||||
listIcons,
|
listIcons,
|
||||||
addIcon,
|
addIcon,
|
||||||
@ -90,7 +91,14 @@ export default Iconify;
|
|||||||
* Named exports
|
* Named exports
|
||||||
*/
|
*/
|
||||||
// IconifyStorageFunctions
|
// IconifyStorageFunctions
|
||||||
export { iconExists, getIcon, listIcons, addIcon, addCollection };
|
export {
|
||||||
|
iconLoaded,
|
||||||
|
iconLoaded as iconExists, // deprecated, kept to avoid breaking changes
|
||||||
|
getIcon,
|
||||||
|
listIcons,
|
||||||
|
addIcon,
|
||||||
|
addCollection,
|
||||||
|
};
|
||||||
|
|
||||||
// IconifyBuilderFunctions
|
// IconifyBuilderFunctions
|
||||||
export { replaceIDs, calculateSize, buildIcon };
|
export { replaceIDs, calculateSize, buildIcon };
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { iconExists } from '@iconify/core/lib/storage/functions';
|
import { iconLoaded } from '@iconify/core/lib/storage/functions';
|
||||||
import {
|
import {
|
||||||
fakeAPI,
|
fakeAPI,
|
||||||
nextPrefix,
|
nextPrefix,
|
||||||
@ -27,7 +27,7 @@ describe('Changing render modes', () => {
|
|||||||
const iconName = `@${provider}:${prefix}:home`;
|
const iconName = `@${provider}:${prefix}:home`;
|
||||||
|
|
||||||
// Add icon with API
|
// Add icon with API
|
||||||
expect(iconExists(iconName)).toBe(false);
|
expect(iconLoaded(iconName)).toBe(false);
|
||||||
mockAPIData({
|
mockAPIData({
|
||||||
type: 'icons',
|
type: 'icons',
|
||||||
provider,
|
provider,
|
||||||
|
@ -7,7 +7,7 @@ import { loadIcons } from '../dist/iconify.mjs';
|
|||||||
|
|
||||||
// Shortcut for offline module
|
// Shortcut for offline module
|
||||||
import IconifyOffline from '@iconify/iconify/offline';
|
import IconifyOffline from '@iconify/iconify/offline';
|
||||||
import { iconExists } from '@iconify/iconify/offline';
|
import { iconLoaded, iconExists } from '@iconify/iconify/offline';
|
||||||
|
|
||||||
// Direct link to offline module
|
// Direct link to offline module
|
||||||
import { addCollection } from '../dist/iconify.without-api.mjs';
|
import { addCollection } from '../dist/iconify.without-api.mjs';
|
||||||
@ -36,10 +36,15 @@ test(typeof Iconify.addIcon, 'function', 'Testing addIcon in default export');
|
|||||||
* Test default export in offline module
|
* Test default export in offline module
|
||||||
*/
|
*/
|
||||||
test(typeof IconifyOffline, 'object', 'Testing default offline export');
|
test(typeof IconifyOffline, 'object', 'Testing default offline export');
|
||||||
|
test(
|
||||||
|
typeof IconifyOffline.iconLoaded,
|
||||||
|
'function',
|
||||||
|
'Testing iconLoaded in default offline export'
|
||||||
|
);
|
||||||
test(
|
test(
|
||||||
typeof IconifyOffline.iconExists,
|
typeof IconifyOffline.iconExists,
|
||||||
'function',
|
'function',
|
||||||
'Testing iconExists in default offline export'
|
'Testing deprecated iconExists in default offline export'
|
||||||
);
|
);
|
||||||
test(
|
test(
|
||||||
typeof IconifyOffline.loadIcons,
|
typeof IconifyOffline.loadIcons,
|
||||||
@ -56,5 +61,10 @@ test(typeof loadIcons, 'function', 'Testing loadIcons named export');
|
|||||||
/**
|
/**
|
||||||
* Test exports without API
|
* Test exports without API
|
||||||
*/
|
*/
|
||||||
test(typeof iconExists, 'function', 'Testing iconExists named export');
|
test(typeof iconLoaded, 'function', 'Testing iconLoaded named export');
|
||||||
|
test(
|
||||||
|
typeof iconExists,
|
||||||
|
'function',
|
||||||
|
'Testing deprecated iconExists named export'
|
||||||
|
);
|
||||||
test(typeof addCollection, 'function', 'Testing addCollection named export');
|
test(typeof addCollection, 'function', 'Testing addCollection named export');
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { iconExists } from '@iconify/core/lib/storage/functions';
|
import { iconLoaded } from '@iconify/core/lib/storage/functions';
|
||||||
import { loadIcon } from '@iconify/core/lib/api/icons';
|
import { loadIcon } from '@iconify/core/lib/api/icons';
|
||||||
import { defaultIconProps } from '@iconify/utils/lib/icon/defaults';
|
import { defaultIconProps } from '@iconify/utils/lib/icon/defaults';
|
||||||
import { fakeAPI, nextPrefix, mockAPIData } from './helpers';
|
import { fakeAPI, nextPrefix, mockAPIData } from './helpers';
|
||||||
@ -29,7 +29,7 @@ describe('Testing mock API', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Check if icon has been loaded
|
// Check if icon has been loaded
|
||||||
expect(iconExists(iconName)).toBe(false);
|
expect(iconLoaded(iconName)).toBe(false);
|
||||||
|
|
||||||
// Load icon
|
// Load icon
|
||||||
const data = await loadIcon(iconName);
|
const data = await loadIcon(iconName);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { iconExists } from '@iconify/core/lib/storage/functions';
|
import { iconLoaded } from '@iconify/core/lib/storage/functions';
|
||||||
import {
|
import {
|
||||||
fakeAPI,
|
fakeAPI,
|
||||||
nextPrefix,
|
nextPrefix,
|
||||||
@ -28,7 +28,7 @@ describe('Observing DOM changes', () => {
|
|||||||
const iconName = `@${provider}:${prefix}:home`;
|
const iconName = `@${provider}:${prefix}:home`;
|
||||||
|
|
||||||
// Add icon with API
|
// Add icon with API
|
||||||
expect(iconExists(iconName)).toBe(false);
|
expect(iconLoaded(iconName)).toBe(false);
|
||||||
mockAPIData({
|
mockAPIData({
|
||||||
type: 'icons',
|
type: 'icons',
|
||||||
provider,
|
provider,
|
||||||
@ -89,8 +89,8 @@ describe('Observing DOM changes', () => {
|
|||||||
let sendSecondIcon = null;
|
let sendSecondIcon = null;
|
||||||
|
|
||||||
// Add icon with API
|
// Add icon with API
|
||||||
expect(iconExists(iconName)).toBe(false);
|
expect(iconLoaded(iconName)).toBe(false);
|
||||||
expect(iconExists(iconName2)).toBe(false);
|
expect(iconLoaded(iconName2)).toBe(false);
|
||||||
mockAPIData({
|
mockAPIData({
|
||||||
type: 'icons',
|
type: 'icons',
|
||||||
provider,
|
provider,
|
||||||
@ -185,8 +185,8 @@ describe('Observing DOM changes', () => {
|
|||||||
let sendSecondIcon = null;
|
let sendSecondIcon = null;
|
||||||
|
|
||||||
// Add icon with API
|
// Add icon with API
|
||||||
expect(iconExists(iconName)).toBe(false);
|
expect(iconLoaded(iconName)).toBe(false);
|
||||||
expect(iconExists(iconName2)).toBe(false);
|
expect(iconLoaded(iconName2)).toBe(false);
|
||||||
mockAPIData({
|
mockAPIData({
|
||||||
type: 'icons',
|
type: 'icons',
|
||||||
provider,
|
provider,
|
||||||
@ -263,7 +263,7 @@ describe('Observing DOM changes', () => {
|
|||||||
|
|
||||||
// Send first API query
|
// Send first API query
|
||||||
sendFirstIcon();
|
sendFirstIcon();
|
||||||
await awaitUntil(() => iconExists(iconName));
|
await awaitUntil(() => iconLoaded(iconName));
|
||||||
|
|
||||||
// Wait a bit more
|
// Wait a bit more
|
||||||
await nextTick([0, 0, 0]);
|
await nextTick([0, 0, 0]);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { iconExists, addIcon } from '@iconify/core/lib/storage/functions';
|
import { iconLoaded, addIcon } from '@iconify/core/lib/storage/functions';
|
||||||
import {
|
import {
|
||||||
fakeAPI,
|
fakeAPI,
|
||||||
nextPrefix,
|
nextPrefix,
|
||||||
@ -26,11 +26,11 @@ describe('Scanning DOM', () => {
|
|||||||
const iconName = `@${provider}:${prefix}:home`;
|
const iconName = `@${provider}:${prefix}:home`;
|
||||||
|
|
||||||
// Add icon
|
// Add icon
|
||||||
expect(iconExists(iconName)).toBe(false);
|
expect(iconLoaded(iconName)).toBe(false);
|
||||||
addIcon(iconName, {
|
addIcon(iconName, {
|
||||||
body: '<g />',
|
body: '<g />',
|
||||||
});
|
});
|
||||||
expect(iconExists(iconName)).toBe(true);
|
expect(iconLoaded(iconName)).toBe(true);
|
||||||
|
|
||||||
// Setup DOM and wait for it to be ready
|
// Setup DOM and wait for it to be ready
|
||||||
setupDOM(`<span class="iconify" data-icon="${iconName}"></span>`);
|
setupDOM(`<span class="iconify" data-icon="${iconName}"></span>`);
|
||||||
@ -64,7 +64,7 @@ describe('Scanning DOM', () => {
|
|||||||
const iconName = `@${provider}:${prefix}:home`;
|
const iconName = `@${provider}:${prefix}:home`;
|
||||||
|
|
||||||
// Add icon with API
|
// Add icon with API
|
||||||
expect(iconExists(iconName)).toBe(false);
|
expect(iconLoaded(iconName)).toBe(false);
|
||||||
mockAPIData({
|
mockAPIData({
|
||||||
type: 'icons',
|
type: 'icons',
|
||||||
provider,
|
provider,
|
||||||
@ -123,7 +123,7 @@ describe('Scanning DOM', () => {
|
|||||||
const iconName = `@${provider}:${prefix}:home`;
|
const iconName = `@${provider}:${prefix}:home`;
|
||||||
|
|
||||||
// Add icon with API
|
// Add icon with API
|
||||||
expect(iconExists(iconName)).toBe(false);
|
expect(iconLoaded(iconName)).toBe(false);
|
||||||
mockAPIData({
|
mockAPIData({
|
||||||
type: 'icons',
|
type: 'icons',
|
||||||
provider,
|
provider,
|
||||||
|
@ -16,7 +16,7 @@ import { stringToIcon } from '@iconify/utils/lib/icon/name';
|
|||||||
import type { IconifyIconSize } from '@iconify/utils/lib/customisations/defaults';
|
import type { IconifyIconSize } from '@iconify/utils/lib/customisations/defaults';
|
||||||
import type { IconifyStorageFunctions } from '@iconify/core/lib/storage/functions';
|
import type { IconifyStorageFunctions } from '@iconify/core/lib/storage/functions';
|
||||||
import {
|
import {
|
||||||
iconExists,
|
iconLoaded,
|
||||||
getIcon,
|
getIcon,
|
||||||
addIcon,
|
addIcon,
|
||||||
addCollection,
|
addCollection,
|
||||||
@ -408,7 +408,14 @@ export { _api };
|
|||||||
export { addAPIProvider, loadIcons, loadIcon };
|
export { addAPIProvider, loadIcons, loadIcon };
|
||||||
|
|
||||||
// IconifyStorageFunctions
|
// IconifyStorageFunctions
|
||||||
export { iconExists, getIcon, listIcons, addIcon, addCollection };
|
export {
|
||||||
|
iconLoaded,
|
||||||
|
iconLoaded as iconExists, // deprecated, kept to avoid breaking changes
|
||||||
|
getIcon,
|
||||||
|
listIcons,
|
||||||
|
addIcon,
|
||||||
|
addCollection,
|
||||||
|
};
|
||||||
|
|
||||||
// IconifyBuilderFunctions
|
// IconifyBuilderFunctions
|
||||||
export { replaceIDs, calculateSize, buildIcon };
|
export { replaceIDs, calculateSize, buildIcon };
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { loadIcons, iconExists } from '../../';
|
import { loadIcons, iconLoaded } from '../../';
|
||||||
import { mockAPIData } from '@iconify/core/lib/api/modules/mock';
|
import { mockAPIData } from '@iconify/core/lib/api/modules/mock';
|
||||||
import { provider, nextPrefix } from './load';
|
import { provider, nextPrefix } from './load';
|
||||||
|
|
||||||
@ -23,7 +23,7 @@ describe('Testing fake API', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Check if icon has been loaded
|
// Check if icon has been loaded
|
||||||
expect(iconExists(iconName)).toEqual(false);
|
expect(iconLoaded(iconName)).toEqual(false);
|
||||||
|
|
||||||
// Load icon
|
// Load icon
|
||||||
loadIcons([iconName], (loaded, missing, pending) => {
|
loadIcons([iconName], (loaded, missing, pending) => {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { nextTick } from 'vue';
|
import { nextTick } from 'vue';
|
||||||
import { mount } from '@vue/test-utils';
|
import { mount } from '@vue/test-utils';
|
||||||
import { Icon, loadIcons, iconExists } from '../../';
|
import { Icon, loadIcons, iconLoaded } from '../../';
|
||||||
import { mockAPIData } from '@iconify/core/lib/api/modules/mock';
|
import { mockAPIData } from '@iconify/core/lib/api/modules/mock';
|
||||||
import { provider, nextPrefix } from './load';
|
import { provider, nextPrefix } from './load';
|
||||||
import { defaultIconResult } from '../empty';
|
import { defaultIconResult } from '../empty';
|
||||||
@ -33,7 +33,7 @@ describe('Rendering icon', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Check if icon has been loaded
|
// Check if icon has been loaded
|
||||||
expect(iconExists(iconName)).toEqual(false);
|
expect(iconLoaded(iconName)).toEqual(false);
|
||||||
|
|
||||||
// Load icon
|
// Load icon
|
||||||
loadIcons([iconName], (loaded, missing, pending) => {
|
loadIcons([iconName], (loaded, missing, pending) => {
|
||||||
@ -47,7 +47,7 @@ describe('Rendering icon', () => {
|
|||||||
]);
|
]);
|
||||||
expect(missing).toMatchObject([]);
|
expect(missing).toMatchObject([]);
|
||||||
expect(pending).toMatchObject([]);
|
expect(pending).toMatchObject([]);
|
||||||
expect(iconExists(iconName)).toEqual(true);
|
expect(iconLoaded(iconName)).toEqual(true);
|
||||||
|
|
||||||
// Render component
|
// Render component
|
||||||
const Wrapper = {
|
const Wrapper = {
|
||||||
@ -104,7 +104,7 @@ describe('Rendering icon', () => {
|
|||||||
},
|
},
|
||||||
delay: (next) => {
|
delay: (next) => {
|
||||||
// Icon should not have loaded yet
|
// Icon should not have loaded yet
|
||||||
expect(iconExists(iconName)).toEqual(false);
|
expect(iconLoaded(iconName)).toEqual(false);
|
||||||
|
|
||||||
// onLoad should not have been called yet
|
// onLoad should not have been called yet
|
||||||
expect(onLoadCalled).toEqual(false);
|
expect(onLoadCalled).toEqual(false);
|
||||||
@ -113,12 +113,12 @@ describe('Rendering icon', () => {
|
|||||||
next();
|
next();
|
||||||
|
|
||||||
// Test it again
|
// Test it again
|
||||||
expect(iconExists(iconName)).toEqual(true);
|
expect(iconLoaded(iconName)).toEqual(true);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
// Check if icon has been loaded
|
// Check if icon has been loaded
|
||||||
expect(iconExists(iconName)).toEqual(false);
|
expect(iconLoaded(iconName)).toEqual(false);
|
||||||
|
|
||||||
// Render component
|
// Render component
|
||||||
const Wrapper = {
|
const Wrapper = {
|
||||||
@ -176,13 +176,13 @@ describe('Rendering icon', () => {
|
|||||||
response: 404,
|
response: 404,
|
||||||
delay: (next) => {
|
delay: (next) => {
|
||||||
// Icon should not have loaded yet
|
// Icon should not have loaded yet
|
||||||
expect(iconExists(iconName)).toEqual(false);
|
expect(iconLoaded(iconName)).toEqual(false);
|
||||||
|
|
||||||
// Send icon data
|
// Send icon data
|
||||||
next();
|
next();
|
||||||
|
|
||||||
// Test it again
|
// Test it again
|
||||||
expect(iconExists(iconName)).toEqual(false);
|
expect(iconLoaded(iconName)).toEqual(false);
|
||||||
|
|
||||||
// Check if state was changed on next few ticks
|
// Check if state was changed on next few ticks
|
||||||
nextTick()
|
nextTick()
|
||||||
@ -203,7 +203,7 @@ describe('Rendering icon', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Check if icon has been loaded
|
// Check if icon has been loaded
|
||||||
expect(iconExists(iconName)).toEqual(false);
|
expect(iconLoaded(iconName)).toEqual(false);
|
||||||
|
|
||||||
// Render component
|
// Render component
|
||||||
const Wrapper = {
|
const Wrapper = {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { nextTick } from 'vue';
|
import { nextTick } from 'vue';
|
||||||
import { mount } from '@vue/test-utils';
|
import { mount } from '@vue/test-utils';
|
||||||
import { Icon, iconExists } from '../../';
|
import { Icon, iconLoaded } from '../../';
|
||||||
import { mockAPIData } from '@iconify/core/lib/api/modules/mock';
|
import { mockAPIData } from '@iconify/core/lib/api/modules/mock';
|
||||||
import { provider, nextPrefix } from './load';
|
import { provider, nextPrefix } from './load';
|
||||||
|
|
||||||
@ -92,7 +92,7 @@ describe('Rendering icon', () => {
|
|||||||
},
|
},
|
||||||
delay: (next) => {
|
delay: (next) => {
|
||||||
// Icon should not have loaded yet
|
// Icon should not have loaded yet
|
||||||
expect(iconExists(iconName)).toEqual(false);
|
expect(iconLoaded(iconName)).toEqual(false);
|
||||||
|
|
||||||
// onLoad should not have been called yet
|
// onLoad should not have been called yet
|
||||||
expect(onLoadCalled).toEqual('');
|
expect(onLoadCalled).toEqual('');
|
||||||
@ -101,7 +101,7 @@ describe('Rendering icon', () => {
|
|||||||
next();
|
next();
|
||||||
|
|
||||||
// Make sure icon data is available
|
// Make sure icon data is available
|
||||||
expect(iconExists(iconName)).toEqual(true);
|
expect(iconLoaded(iconName)).toEqual(true);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -117,7 +117,7 @@ describe('Rendering icon', () => {
|
|||||||
},
|
},
|
||||||
delay: (next) => {
|
delay: (next) => {
|
||||||
// Icon should not have loaded yet
|
// Icon should not have loaded yet
|
||||||
expect(iconExists(iconName2)).toEqual(false);
|
expect(iconLoaded(iconName2)).toEqual(false);
|
||||||
|
|
||||||
// onLoad should have been called only once for previous icon
|
// onLoad should have been called only once for previous icon
|
||||||
expect(onLoadCalled).toEqual(iconName);
|
expect(onLoadCalled).toEqual(iconName);
|
||||||
@ -126,12 +126,12 @@ describe('Rendering icon', () => {
|
|||||||
next();
|
next();
|
||||||
|
|
||||||
// Make sure icon data is available
|
// Make sure icon data is available
|
||||||
expect(iconExists(iconName2)).toEqual(true);
|
expect(iconLoaded(iconName2)).toEqual(true);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
// Check if icon has been loaded
|
// Check if icon has been loaded
|
||||||
expect(iconExists(iconName)).toEqual(false);
|
expect(iconLoaded(iconName)).toEqual(false);
|
||||||
|
|
||||||
// Render component
|
// Render component
|
||||||
const Wrapper = {
|
const Wrapper = {
|
||||||
@ -221,18 +221,18 @@ describe('Rendering icon', () => {
|
|||||||
expect(isSync).toEqual(false);
|
expect(isSync).toEqual(false);
|
||||||
|
|
||||||
// Icon should not have loaded yet
|
// Icon should not have loaded yet
|
||||||
expect(iconExists(iconName2)).toEqual(false);
|
expect(iconLoaded(iconName2)).toEqual(false);
|
||||||
|
|
||||||
// Send icon data
|
// Send icon data
|
||||||
next();
|
next();
|
||||||
|
|
||||||
// Make sure icon was loaded
|
// Make sure icon was loaded
|
||||||
expect(iconExists(iconName2)).toEqual(true);
|
expect(iconLoaded(iconName2)).toEqual(true);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
// Check if icon has been loaded
|
// Check if icon has been loaded
|
||||||
expect(iconExists(iconName)).toEqual(false);
|
expect(iconLoaded(iconName)).toEqual(false);
|
||||||
|
|
||||||
// Render component
|
// Render component
|
||||||
const Wrapper = {
|
const Wrapper = {
|
||||||
@ -313,18 +313,18 @@ describe('Rendering icon', () => {
|
|||||||
},
|
},
|
||||||
delay: (next) => {
|
delay: (next) => {
|
||||||
// Icon should not have loaded yet
|
// Icon should not have loaded yet
|
||||||
expect(iconExists(iconName)).toEqual(false);
|
expect(iconLoaded(iconName)).toEqual(false);
|
||||||
|
|
||||||
// Send icon data
|
// Send icon data
|
||||||
next();
|
next();
|
||||||
|
|
||||||
// Make sure icon was loaded
|
// Make sure icon was loaded
|
||||||
expect(iconExists(iconName)).toEqual(true);
|
expect(iconLoaded(iconName)).toEqual(true);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
// Check if icon has been loaded
|
// Check if icon has been loaded
|
||||||
expect(iconExists(iconName)).toEqual(false);
|
expect(iconLoaded(iconName)).toEqual(false);
|
||||||
|
|
||||||
// Render component with placeholder text
|
// Render component with placeholder text
|
||||||
const Wrapper = {
|
const Wrapper = {
|
||||||
|
@ -9,7 +9,7 @@ import { stringToIcon } from '@iconify/utils/lib/icon/name';
|
|||||||
import type { IconifyIconSize } from '@iconify/utils/lib/customisations/defaults';
|
import type { IconifyIconSize } from '@iconify/utils/lib/customisations/defaults';
|
||||||
import type { IconifyStorageFunctions } from '@iconify/core/lib/storage/functions';
|
import type { IconifyStorageFunctions } from '@iconify/core/lib/storage/functions';
|
||||||
import {
|
import {
|
||||||
iconExists,
|
iconLoaded,
|
||||||
getIcon,
|
getIcon,
|
||||||
addIcon,
|
addIcon,
|
||||||
addCollection,
|
addCollection,
|
||||||
@ -385,7 +385,14 @@ export { _api };
|
|||||||
export { addAPIProvider, loadIcons, loadIcon };
|
export { addAPIProvider, loadIcons, loadIcon };
|
||||||
|
|
||||||
// IconifyStorageFunctions
|
// IconifyStorageFunctions
|
||||||
export { iconExists, getIcon, listIcons, addIcon, addCollection };
|
export {
|
||||||
|
iconLoaded,
|
||||||
|
iconLoaded as iconExists, // deprecated, kept to avoid breaking changes
|
||||||
|
getIcon,
|
||||||
|
listIcons,
|
||||||
|
addIcon,
|
||||||
|
addCollection,
|
||||||
|
};
|
||||||
|
|
||||||
// IconifyBuilderFunctions
|
// IconifyBuilderFunctions
|
||||||
export { replaceIDs, calculateSize, buildIcon };
|
export { replaceIDs, calculateSize, buildIcon };
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/**
|
/**
|
||||||
* @jest-environment jsdom
|
* @jest-environment jsdom
|
||||||
*/
|
*/
|
||||||
import { loadIcons, iconExists } from '../../';
|
import { loadIcons, iconLoaded } from '../../';
|
||||||
import { mockAPIData } from '@iconify/core/lib/api/modules/mock.cjs';
|
import { mockAPIData } from '@iconify/core/lib/api/modules/mock.cjs';
|
||||||
import { provider, nextPrefix } from './load';
|
import { provider, nextPrefix } from './load';
|
||||||
|
|
||||||
@ -26,7 +26,7 @@ describe('Testing fake API', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Check if icon has been loaded
|
// Check if icon has been loaded
|
||||||
expect(iconExists(iconName)).toBe(false);
|
expect(iconLoaded(iconName)).toBe(false);
|
||||||
|
|
||||||
// Load icon
|
// Load icon
|
||||||
loadIcons([iconName], (loaded, missing, pending) => {
|
loadIcons([iconName], (loaded, missing, pending) => {
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
*/
|
*/
|
||||||
import Vue from 'vue';
|
import Vue from 'vue';
|
||||||
import { mount } from '@vue/test-utils';
|
import { mount } from '@vue/test-utils';
|
||||||
import { Icon, loadIcons, iconExists } from '../../';
|
import { Icon, loadIcons, iconLoaded } from '../../';
|
||||||
import { mockAPIData } from '@iconify/core/lib/api/modules/mock.cjs';
|
import { mockAPIData } from '@iconify/core/lib/api/modules/mock.cjs';
|
||||||
import { provider, nextPrefix } from './load';
|
import { provider, nextPrefix } from './load';
|
||||||
import { defaultIconResult } from '../empty';
|
import { defaultIconResult } from '../empty';
|
||||||
@ -36,7 +36,7 @@ describe('Rendering icon', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Check if icon has been loaded
|
// Check if icon has been loaded
|
||||||
expect(iconExists(iconName)).toBe(false);
|
expect(iconLoaded(iconName)).toBe(false);
|
||||||
|
|
||||||
// Load icon
|
// Load icon
|
||||||
loadIcons([iconName], (loaded, missing, pending) => {
|
loadIcons([iconName], (loaded, missing, pending) => {
|
||||||
@ -50,7 +50,7 @@ describe('Rendering icon', () => {
|
|||||||
]);
|
]);
|
||||||
expect(missing).toMatchObject([]);
|
expect(missing).toMatchObject([]);
|
||||||
expect(pending).toMatchObject([]);
|
expect(pending).toMatchObject([]);
|
||||||
expect(iconExists(iconName)).toBe(true);
|
expect(iconLoaded(iconName)).toBe(true);
|
||||||
|
|
||||||
// Render component
|
// Render component
|
||||||
const Wrapper = {
|
const Wrapper = {
|
||||||
@ -105,7 +105,7 @@ describe('Rendering icon', () => {
|
|||||||
},
|
},
|
||||||
delay: (next) => {
|
delay: (next) => {
|
||||||
// Icon should not have loaded yet
|
// Icon should not have loaded yet
|
||||||
expect(iconExists(iconName)).toBe(false);
|
expect(iconLoaded(iconName)).toBe(false);
|
||||||
|
|
||||||
// onLoad should not have been called yet
|
// onLoad should not have been called yet
|
||||||
expect(onLoadCalled).toBe(false);
|
expect(onLoadCalled).toBe(false);
|
||||||
@ -114,12 +114,12 @@ describe('Rendering icon', () => {
|
|||||||
next();
|
next();
|
||||||
|
|
||||||
// Test it again
|
// Test it again
|
||||||
expect(iconExists(iconName)).toBe(true);
|
expect(iconLoaded(iconName)).toBe(true);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
// Check if icon has been loaded
|
// Check if icon has been loaded
|
||||||
expect(iconExists(iconName)).toBe(false);
|
expect(iconLoaded(iconName)).toBe(false);
|
||||||
|
|
||||||
// Render component
|
// Render component
|
||||||
const Wrapper = {
|
const Wrapper = {
|
||||||
@ -179,13 +179,13 @@ describe('Rendering icon', () => {
|
|||||||
response: 404,
|
response: 404,
|
||||||
delay: (next) => {
|
delay: (next) => {
|
||||||
// Icon should not have loaded yet
|
// Icon should not have loaded yet
|
||||||
expect(iconExists(iconName)).toBe(false);
|
expect(iconLoaded(iconName)).toBe(false);
|
||||||
|
|
||||||
// Send icon data
|
// Send icon data
|
||||||
next();
|
next();
|
||||||
|
|
||||||
// Test it again
|
// Test it again
|
||||||
expect(iconExists(iconName)).toBe(false);
|
expect(iconLoaded(iconName)).toBe(false);
|
||||||
|
|
||||||
// Check if state was changed after few ticks
|
// Check if state was changed after few ticks
|
||||||
Vue.nextTick(() => {
|
Vue.nextTick(() => {
|
||||||
@ -201,7 +201,7 @@ describe('Rendering icon', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Check if icon has been loaded
|
// Check if icon has been loaded
|
||||||
expect(iconExists(iconName)).toBe(false);
|
expect(iconLoaded(iconName)).toBe(false);
|
||||||
|
|
||||||
// Render component
|
// Render component
|
||||||
const Wrapper = {
|
const Wrapper = {
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
*/
|
*/
|
||||||
import Vue from 'vue';
|
import Vue from 'vue';
|
||||||
import { mount } from '@vue/test-utils';
|
import { mount } from '@vue/test-utils';
|
||||||
import { Icon, iconExists } from '../../';
|
import { Icon, iconLoaded } from '../../';
|
||||||
import { mockAPIData } from '@iconify/core/lib/api/modules/mock.cjs';
|
import { mockAPIData } from '@iconify/core/lib/api/modules/mock.cjs';
|
||||||
import { provider, nextPrefix } from './load';
|
import { provider, nextPrefix } from './load';
|
||||||
import { defaultIconResult } from '../empty';
|
import { defaultIconResult } from '../empty';
|
||||||
@ -96,7 +96,7 @@ describe('Rendering icon', () => {
|
|||||||
},
|
},
|
||||||
delay: (next) => {
|
delay: (next) => {
|
||||||
// Icon should not have loaded yet
|
// Icon should not have loaded yet
|
||||||
expect(iconExists(iconName)).toBe(false);
|
expect(iconLoaded(iconName)).toBe(false);
|
||||||
|
|
||||||
// onLoad should not have been called yet
|
// onLoad should not have been called yet
|
||||||
expect(onLoadCalled).toBe('');
|
expect(onLoadCalled).toBe('');
|
||||||
@ -105,7 +105,7 @@ describe('Rendering icon', () => {
|
|||||||
next();
|
next();
|
||||||
|
|
||||||
// Make sure icon data is available
|
// Make sure icon data is available
|
||||||
expect(iconExists(iconName)).toBe(true);
|
expect(iconLoaded(iconName)).toBe(true);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -121,7 +121,7 @@ describe('Rendering icon', () => {
|
|||||||
},
|
},
|
||||||
delay: (next) => {
|
delay: (next) => {
|
||||||
// Icon should not have loaded yet
|
// Icon should not have loaded yet
|
||||||
expect(iconExists(iconName2)).toBe(false);
|
expect(iconLoaded(iconName2)).toBe(false);
|
||||||
|
|
||||||
// onLoad should have been called only once for previous icon
|
// onLoad should have been called only once for previous icon
|
||||||
expect(onLoadCalled).toBe(iconName);
|
expect(onLoadCalled).toBe(iconName);
|
||||||
@ -130,12 +130,12 @@ describe('Rendering icon', () => {
|
|||||||
next();
|
next();
|
||||||
|
|
||||||
// Make sure icon data is available
|
// Make sure icon data is available
|
||||||
expect(iconExists(iconName2)).toBe(true);
|
expect(iconLoaded(iconName2)).toBe(true);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
// Check if icon has been loaded
|
// Check if icon has been loaded
|
||||||
expect(iconExists(iconName)).toBe(false);
|
expect(iconLoaded(iconName)).toBe(false);
|
||||||
|
|
||||||
// Render component
|
// Render component
|
||||||
const wrapper = mount(Icon, {
|
const wrapper = mount(Icon, {
|
||||||
@ -224,18 +224,18 @@ describe('Rendering icon', () => {
|
|||||||
expect(isSync).toBe(false);
|
expect(isSync).toBe(false);
|
||||||
|
|
||||||
// Icon should not have loaded yet
|
// Icon should not have loaded yet
|
||||||
expect(iconExists(iconName2)).toBe(false);
|
expect(iconLoaded(iconName2)).toBe(false);
|
||||||
|
|
||||||
// Send icon data
|
// Send icon data
|
||||||
next();
|
next();
|
||||||
|
|
||||||
// Test it again
|
// Test it again
|
||||||
expect(iconExists(iconName2)).toBe(true);
|
expect(iconLoaded(iconName2)).toBe(true);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
// Check if icon has been loaded
|
// Check if icon has been loaded
|
||||||
expect(iconExists(iconName)).toBe(false);
|
expect(iconLoaded(iconName)).toBe(false);
|
||||||
|
|
||||||
// Render component
|
// Render component
|
||||||
const wrapper = mount(Icon, {
|
const wrapper = mount(Icon, {
|
||||||
@ -310,18 +310,18 @@ describe('Rendering icon', () => {
|
|||||||
},
|
},
|
||||||
delay: (next) => {
|
delay: (next) => {
|
||||||
// Icon should not have loaded yet
|
// Icon should not have loaded yet
|
||||||
expect(iconExists(iconName)).toBe(false);
|
expect(iconLoaded(iconName)).toBe(false);
|
||||||
|
|
||||||
// Send icon data
|
// Send icon data
|
||||||
next();
|
next();
|
||||||
|
|
||||||
// Make sure icon was loaded
|
// Make sure icon was loaded
|
||||||
expect(iconExists(iconName)).toBe(true);
|
expect(iconLoaded(iconName)).toBe(true);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
// Check if icon has been loaded
|
// Check if icon has been loaded
|
||||||
expect(iconExists(iconName)).toBe(false);
|
expect(iconLoaded(iconName)).toBe(false);
|
||||||
|
|
||||||
// Render component with placeholder text
|
// Render component with placeholder text
|
||||||
const wrapper = mount(Icon, {
|
const wrapper = mount(Icon, {
|
||||||
|
@ -6,7 +6,7 @@ import {
|
|||||||
IconifyStorageFunctions,
|
IconifyStorageFunctions,
|
||||||
} from '@iconify/core/lib/storage/functions';
|
} from '@iconify/core/lib/storage/functions';
|
||||||
import {
|
import {
|
||||||
iconExists,
|
iconLoaded,
|
||||||
getIcon,
|
getIcon,
|
||||||
addIcon,
|
addIcon,
|
||||||
addCollection,
|
addCollection,
|
||||||
@ -159,7 +159,8 @@ export function exportFunctions(): IconifyExportedFunctions {
|
|||||||
toggleBrowserCache(storage, true),
|
toggleBrowserCache(storage, true),
|
||||||
disableCache: (storage: IconifyBrowserCacheType) =>
|
disableCache: (storage: IconifyBrowserCacheType) =>
|
||||||
toggleBrowserCache(storage, false),
|
toggleBrowserCache(storage, false),
|
||||||
iconExists,
|
iconLoaded,
|
||||||
|
iconExists: iconLoaded, // deprecated, kept to avoid breaking changes
|
||||||
getIcon,
|
getIcon,
|
||||||
listIcons,
|
listIcons,
|
||||||
addIcon,
|
addIcon,
|
||||||
|
@ -110,7 +110,8 @@ export const IconifyIconComponent = defineIconifyIcon() || exportFunctions();
|
|||||||
const {
|
const {
|
||||||
enableCache,
|
enableCache,
|
||||||
disableCache,
|
disableCache,
|
||||||
iconExists,
|
iconLoaded,
|
||||||
|
iconExists, // deprecated, kept to avoid breaking changes
|
||||||
getIcon,
|
getIcon,
|
||||||
listIcons,
|
listIcons,
|
||||||
addIcon,
|
addIcon,
|
||||||
@ -126,7 +127,8 @@ const {
|
|||||||
export {
|
export {
|
||||||
enableCache,
|
enableCache,
|
||||||
disableCache,
|
disableCache,
|
||||||
iconExists,
|
iconLoaded,
|
||||||
|
iconExists, // deprecated, kept to avoid breaking changes
|
||||||
getIcon,
|
getIcon,
|
||||||
listIcons,
|
listIcons,
|
||||||
addIcon,
|
addIcon,
|
||||||
|
@ -88,8 +88,8 @@ describe('Testing icon component with API', () => {
|
|||||||
sendQuery();
|
sendQuery();
|
||||||
|
|
||||||
// Wait until icon exists
|
// Wait until icon exists
|
||||||
const iconExists = node.iconExists;
|
const iconLoaded = node.iconLoaded;
|
||||||
await awaitUntil(() => iconExists(iconName));
|
await awaitUntil(() => iconLoaded(iconName));
|
||||||
|
|
||||||
// Wait for render
|
// Wait for render
|
||||||
await nextTick();
|
await nextTick();
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { iconExists } from '@iconify/core/lib/storage/functions';
|
import { iconLoaded } from '@iconify/core/lib/storage/functions';
|
||||||
import { loadIcon } from '@iconify/core/lib/api/icons';
|
import { loadIcon } from '@iconify/core/lib/api/icons';
|
||||||
import { defaultIconProps } from '@iconify/utils/lib/icon/defaults';
|
import { defaultIconProps } from '@iconify/utils/lib/icon/defaults';
|
||||||
import { fakeAPI, nextPrefix, mockAPIData } from '../src/tests/helpers';
|
import { fakeAPI, nextPrefix, mockAPIData } from '../src/tests/helpers';
|
||||||
@ -29,7 +29,7 @@ describe('Testing mock API', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Check if icon has been loaded
|
// Check if icon has been loaded
|
||||||
expect(iconExists(iconName)).toBe(false);
|
expect(iconLoaded(iconName)).toBe(false);
|
||||||
|
|
||||||
// Load icon
|
// Load icon
|
||||||
const data = await loadIcon(iconName);
|
const data = await loadIcon(iconName);
|
||||||
|
@ -57,7 +57,8 @@ export type {
|
|||||||
export {
|
export {
|
||||||
enableCache,
|
enableCache,
|
||||||
disableCache,
|
disableCache,
|
||||||
iconExists,
|
iconLoaded,
|
||||||
|
iconExists, // deprecated, kept to avoid breaking changes
|
||||||
getIcon,
|
getIcon,
|
||||||
listIcons,
|
listIcons,
|
||||||
addIcon,
|
addIcon,
|
||||||
|
@ -58,7 +58,8 @@ export type {
|
|||||||
export {
|
export {
|
||||||
enableCache,
|
enableCache,
|
||||||
disableCache,
|
disableCache,
|
||||||
iconExists,
|
iconLoaded,
|
||||||
|
iconExists, // deprecated, kept to avoid breaking changes
|
||||||
getIcon,
|
getIcon,
|
||||||
listIcons,
|
listIcons,
|
||||||
addIcon,
|
addIcon,
|
||||||
|
@ -11,7 +11,14 @@ import { getStorage, addIconToStorage, addIconSet } from './storage';
|
|||||||
*/
|
*/
|
||||||
export interface IconifyStorageFunctions {
|
export interface IconifyStorageFunctions {
|
||||||
/**
|
/**
|
||||||
* Check if icon exists
|
* Check if icon data is available
|
||||||
|
*/
|
||||||
|
iconLoaded: (name: string) => boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Older, badly named, version of iconLoaded()
|
||||||
|
*
|
||||||
|
* @deprecated
|
||||||
*/
|
*/
|
||||||
iconExists: (name: string) => boolean;
|
iconExists: (name: string) => boolean;
|
||||||
|
|
||||||
@ -133,9 +140,9 @@ export function addCollection(data: IconifyJSON, provider?: string): boolean {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if icon exists
|
* Check if icon data is available
|
||||||
*/
|
*/
|
||||||
export function iconExists(name: string): boolean {
|
export function iconLoaded(name: string): boolean {
|
||||||
return !!getIconData(name);
|
return !!getIconData(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,9 +98,9 @@ export function addIconToStorage(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if icon exists
|
* Check if icon is available in storage
|
||||||
*/
|
*/
|
||||||
export function iconExists(storage: IconStorage, name: string): boolean {
|
export function iconInStorage(storage: IconStorage, name: string): boolean {
|
||||||
return !!storage.icons[name];
|
return !!storage.icons[name];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ import { setAPIModule } from '../../lib/api/modules';
|
|||||||
import { loadIcons } from '../../lib/api/icons';
|
import { loadIcons } from '../../lib/api/icons';
|
||||||
import type { IconifyMockAPIDelayDoneCallback } from '../../lib/api/modules/mock';
|
import type { IconifyMockAPIDelayDoneCallback } from '../../lib/api/modules/mock';
|
||||||
import { mockAPIModule, mockAPIData } from '../../lib/api/modules/mock';
|
import { mockAPIModule, mockAPIData } from '../../lib/api/modules/mock';
|
||||||
import { getStorage, iconExists } from '../../lib/storage/storage';
|
import { getStorage, iconInStorage } from '../../lib/storage/storage';
|
||||||
import { sendAPIQuery } from '../../lib/api/query';
|
import { sendAPIQuery } from '../../lib/api/query';
|
||||||
|
|
||||||
describe('Testing mock API module', () => {
|
describe('Testing mock API module', () => {
|
||||||
@ -278,13 +278,13 @@ describe('Testing mock API module', () => {
|
|||||||
delay: (next) => {
|
delay: (next) => {
|
||||||
// Icon should not be loaded yet
|
// Icon should not be loaded yet
|
||||||
const storage = getStorage(provider, prefix);
|
const storage = getStorage(provider, prefix);
|
||||||
expect(iconExists(storage, name)).toBe(false);
|
expect(iconInStorage(storage, name)).toBe(false);
|
||||||
|
|
||||||
// Set data
|
// Set data
|
||||||
next();
|
next();
|
||||||
|
|
||||||
// Icon should be loaded now
|
// Icon should be loaded now
|
||||||
expect(iconExists(storage, name)).toBe(true);
|
expect(iconInStorage(storage, name)).toBe(true);
|
||||||
|
|
||||||
fulfill(true);
|
fulfill(true);
|
||||||
},
|
},
|
||||||
|
42
packages/core/tests/cache/loading-test.ts
vendored
42
packages/core/tests/cache/loading-test.ts
vendored
@ -10,7 +10,7 @@ import {
|
|||||||
} from '../../lib/browser-storage/data';
|
} from '../../lib/browser-storage/data';
|
||||||
import { getBrowserStorageItemsCount } from '../../lib/browser-storage/count';
|
import { getBrowserStorageItemsCount } from '../../lib/browser-storage/count';
|
||||||
import { getBrowserStorage } from '../../lib/browser-storage/global';
|
import { getBrowserStorage } from '../../lib/browser-storage/global';
|
||||||
import { getStorage, iconExists } from '../../lib/storage/storage';
|
import { getStorage, iconInStorage } from '../../lib/storage/storage';
|
||||||
import { nextPrefix, createCache, reset } from '../../lib/browser-storage/mock';
|
import { nextPrefix, createCache, reset } from '../../lib/browser-storage/mock';
|
||||||
import {
|
import {
|
||||||
browserCacheCountKey,
|
browserCacheCountKey,
|
||||||
@ -64,14 +64,14 @@ describe('Testing loading from localStorage', () => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Check icon storage
|
// Check icon storage
|
||||||
expect(iconExists(storage, 'foo')).toBe(false);
|
expect(iconInStorage(storage, 'foo')).toBe(false);
|
||||||
expect(storage.lastModifiedCached).toBeUndefined();
|
expect(storage.lastModifiedCached).toBeUndefined();
|
||||||
|
|
||||||
// Load localStorage
|
// Load localStorage
|
||||||
initBrowserStorage();
|
initBrowserStorage();
|
||||||
|
|
||||||
// Icon should exist now and lastModified should be set
|
// Icon should exist now and lastModified should be set
|
||||||
expect(iconExists(storage, 'foo')).toBe(true);
|
expect(iconInStorage(storage, 'foo')).toBe(true);
|
||||||
expect(storage.lastModifiedCached).toBe(-1);
|
expect(storage.lastModifiedCached).toBe(-1);
|
||||||
|
|
||||||
// Check data
|
// Check data
|
||||||
@ -119,19 +119,19 @@ describe('Testing loading from localStorage', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Check icon storage
|
// Check icon storage
|
||||||
expect(iconExists(storage, 'foo')).toBe(false);
|
expect(iconInStorage(storage, 'foo')).toBe(false);
|
||||||
expect(storage.lastModifiedCached).toBeUndefined();
|
expect(storage.lastModifiedCached).toBeUndefined();
|
||||||
|
|
||||||
// Check default provider
|
// Check default provider
|
||||||
expect(iconExists(defaultStorage, 'foo')).toBe(false);
|
expect(iconInStorage(defaultStorage, 'foo')).toBe(false);
|
||||||
expect(defaultStorage.lastModifiedCached).toBeUndefined();
|
expect(defaultStorage.lastModifiedCached).toBeUndefined();
|
||||||
|
|
||||||
// Load localStorage
|
// Load localStorage
|
||||||
initBrowserStorage();
|
initBrowserStorage();
|
||||||
|
|
||||||
// Icon should exist now
|
// Icon should exist now
|
||||||
expect(iconExists(storage, 'foo')).toBe(true);
|
expect(iconInStorage(storage, 'foo')).toBe(true);
|
||||||
expect(iconExists(defaultStorage, 'foo')).toBe(false);
|
expect(iconInStorage(defaultStorage, 'foo')).toBe(false);
|
||||||
|
|
||||||
// Check data
|
// Check data
|
||||||
expect(browserStorageConfig).toEqual({
|
expect(browserStorageConfig).toEqual({
|
||||||
@ -189,13 +189,13 @@ describe('Testing loading from localStorage', () => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Check icon storage
|
// Check icon storage
|
||||||
expect(iconExists(storage, 'foo')).toBe(false);
|
expect(iconInStorage(storage, 'foo')).toBe(false);
|
||||||
|
|
||||||
// Load localStorage
|
// Load localStorage
|
||||||
initBrowserStorage();
|
initBrowserStorage();
|
||||||
|
|
||||||
// Icon should not have loaded
|
// Icon should not have loaded
|
||||||
expect(iconExists(storage, 'foo')).toBe(false);
|
expect(iconInStorage(storage, 'foo')).toBe(false);
|
||||||
expect(storage.lastModifiedCached).toBeUndefined();
|
expect(storage.lastModifiedCached).toBeUndefined();
|
||||||
|
|
||||||
// Check data
|
// Check data
|
||||||
@ -253,13 +253,13 @@ describe('Testing loading from localStorage', () => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Check icon storage
|
// Check icon storage
|
||||||
expect(iconExists(storage, 'foo')).toBe(false);
|
expect(iconInStorage(storage, 'foo')).toBe(false);
|
||||||
|
|
||||||
// Load localStorage
|
// Load localStorage
|
||||||
initBrowserStorage();
|
initBrowserStorage();
|
||||||
|
|
||||||
// Icon should not have loaded
|
// Icon should not have loaded
|
||||||
expect(iconExists(storage, 'foo')).toBe(false);
|
expect(iconInStorage(storage, 'foo')).toBe(false);
|
||||||
|
|
||||||
// Check data
|
// Check data
|
||||||
expect(browserStorageConfig).toEqual({
|
expect(browserStorageConfig).toEqual({
|
||||||
@ -316,13 +316,13 @@ describe('Testing loading from localStorage', () => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Check icon storage
|
// Check icon storage
|
||||||
expect(iconExists(storage, 'foo')).toBe(false);
|
expect(iconInStorage(storage, 'foo')).toBe(false);
|
||||||
|
|
||||||
// Load localStorage
|
// Load localStorage
|
||||||
initBrowserStorage();
|
initBrowserStorage();
|
||||||
|
|
||||||
// Icon should not have loaded
|
// Icon should not have loaded
|
||||||
expect(iconExists(storage, 'foo')).toBe(false);
|
expect(iconInStorage(storage, 'foo')).toBe(false);
|
||||||
|
|
||||||
// Check data
|
// Check data
|
||||||
expect(browserStorageConfig).toEqual({
|
expect(browserStorageConfig).toEqual({
|
||||||
@ -370,13 +370,13 @@ describe('Testing loading from localStorage', () => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Check icon storage
|
// Check icon storage
|
||||||
expect(iconExists(storage, 'foo')).toBe(false);
|
expect(iconInStorage(storage, 'foo')).toBe(false);
|
||||||
|
|
||||||
// Load localStorage
|
// Load localStorage
|
||||||
initBrowserStorage();
|
initBrowserStorage();
|
||||||
|
|
||||||
// Icon should exist now
|
// Icon should exist now
|
||||||
expect(iconExists(storage, 'foo')).toBe(true);
|
expect(iconInStorage(storage, 'foo')).toBe(true);
|
||||||
|
|
||||||
// Check data
|
// Check data
|
||||||
expect(browserStorageConfig).toEqual({
|
expect(browserStorageConfig).toEqual({
|
||||||
@ -445,15 +445,15 @@ describe('Testing loading from localStorage', () => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Check icon storage
|
// Check icon storage
|
||||||
expect(iconExists(storage, 'foo1')).toBe(false);
|
expect(iconInStorage(storage, 'foo1')).toBe(false);
|
||||||
expect(iconExists(storage, 'foo4')).toBe(false);
|
expect(iconInStorage(storage, 'foo4')).toBe(false);
|
||||||
|
|
||||||
// Load localStorage
|
// Load localStorage
|
||||||
initBrowserStorage();
|
initBrowserStorage();
|
||||||
|
|
||||||
// Icons should exist now
|
// Icons should exist now
|
||||||
expect(iconExists(storage, 'foo1')).toBe(true);
|
expect(iconInStorage(storage, 'foo1')).toBe(true);
|
||||||
expect(iconExists(storage, 'foo4')).toBe(true);
|
expect(iconInStorage(storage, 'foo4')).toBe(true);
|
||||||
|
|
||||||
// Check data
|
// Check data
|
||||||
expect(browserStorageConfig).toEqual({
|
expect(browserStorageConfig).toEqual({
|
||||||
@ -531,7 +531,7 @@ describe('Testing loading from localStorage', () => {
|
|||||||
|
|
||||||
// Check icon storage
|
// Check icon storage
|
||||||
for (let i = 0; i < 6; i++) {
|
for (let i = 0; i < 6; i++) {
|
||||||
expect(iconExists(storage, 'foo' + i.toString())).toBe(false);
|
expect(iconInStorage(storage, 'foo' + i.toString())).toBe(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load localStorage
|
// Load localStorage
|
||||||
@ -539,7 +539,7 @@ describe('Testing loading from localStorage', () => {
|
|||||||
|
|
||||||
// Icons should exist now, except for number 4
|
// Icons should exist now, except for number 4
|
||||||
for (let i = 0; i < 6; i++) {
|
for (let i = 0; i < 6; i++) {
|
||||||
expect(iconExists(storage, 'foo' + i.toString())).toBe(i !== 4);
|
expect(iconInStorage(storage, 'foo' + i.toString())).toBe(i !== 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check data
|
// Check data
|
||||||
|
18
packages/core/tests/cache/saving-test.ts
vendored
18
packages/core/tests/cache/saving-test.ts
vendored
@ -11,7 +11,7 @@ import {
|
|||||||
} from '../../lib/browser-storage/data';
|
} from '../../lib/browser-storage/data';
|
||||||
import { getBrowserStorageItemsCount } from '../../lib/browser-storage/count';
|
import { getBrowserStorageItemsCount } from '../../lib/browser-storage/count';
|
||||||
import { getBrowserStorage } from '../../lib/browser-storage/global';
|
import { getBrowserStorage } from '../../lib/browser-storage/global';
|
||||||
import { getStorage, iconExists } from '../../lib/storage/storage';
|
import { getStorage, iconInStorage } from '../../lib/storage/storage';
|
||||||
import { nextPrefix, createCache, reset } from '../../lib/browser-storage/mock';
|
import { nextPrefix, createCache, reset } from '../../lib/browser-storage/mock';
|
||||||
import {
|
import {
|
||||||
browserCacheCountKey,
|
browserCacheCountKey,
|
||||||
@ -51,7 +51,7 @@ describe('Testing saving to localStorage', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Check icon storage
|
// Check icon storage
|
||||||
expect(iconExists(storage, 'foo')).toBe(false);
|
expect(iconInStorage(storage, 'foo')).toBe(false);
|
||||||
expect(storage.lastModifiedCached).toBeUndefined();
|
expect(storage.lastModifiedCached).toBeUndefined();
|
||||||
|
|
||||||
// Counter should be 0
|
// Counter should be 0
|
||||||
@ -64,7 +64,7 @@ describe('Testing saving to localStorage', () => {
|
|||||||
storeInBrowserStorage(storage, icon);
|
storeInBrowserStorage(storage, icon);
|
||||||
|
|
||||||
// Storing in cache should not add item to storage
|
// Storing in cache should not add item to storage
|
||||||
expect(iconExists(storage, 'foo')).toBe(false);
|
expect(iconInStorage(storage, 'foo')).toBe(false);
|
||||||
|
|
||||||
// lastModified is missing, so should not have updated
|
// lastModified is missing, so should not have updated
|
||||||
expect(storage.lastModifiedCached).toBeUndefined();
|
expect(storage.lastModifiedCached).toBeUndefined();
|
||||||
@ -571,7 +571,7 @@ describe('Testing saving to localStorage', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Check icon storage
|
// Check icon storage
|
||||||
expect(iconExists(storage, 'foo1')).toBe(false);
|
expect(iconInStorage(storage, 'foo1')).toBe(false);
|
||||||
|
|
||||||
// Load cache
|
// Load cache
|
||||||
initBrowserStorage();
|
initBrowserStorage();
|
||||||
@ -604,7 +604,7 @@ describe('Testing saving to localStorage', () => {
|
|||||||
storeInBrowserStorage(storage, icon);
|
storeInBrowserStorage(storage, icon);
|
||||||
|
|
||||||
// Storing in cache should not add item to storage
|
// Storing in cache should not add item to storage
|
||||||
expect(iconExists(storage, 'foo')).toBe(false);
|
expect(iconInStorage(storage, 'foo')).toBe(false);
|
||||||
|
|
||||||
// Check data that should have been updated because storeCache()
|
// Check data that should have been updated because storeCache()
|
||||||
// should call load function before first execution
|
// should call load function before first execution
|
||||||
@ -708,10 +708,10 @@ describe('Testing saving to localStorage', () => {
|
|||||||
|
|
||||||
// Check icon storage
|
// Check icon storage
|
||||||
for (let i = 0; i < 3; i++) {
|
for (let i = 0; i < 3; i++) {
|
||||||
expect(iconExists(storage, 'foo' + i.toString())).toBe(true);
|
expect(iconInStorage(storage, 'foo' + i.toString())).toBe(true);
|
||||||
}
|
}
|
||||||
for (let i = 0; i < 4; i++) {
|
for (let i = 0; i < 4; i++) {
|
||||||
expect(iconExists(storage, 'bar' + i.toString())).toBe(true);
|
expect(iconInStorage(storage, 'bar' + i.toString())).toBe(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add new item to localStorage
|
// Add new item to localStorage
|
||||||
@ -833,10 +833,10 @@ describe('Testing saving to localStorage', () => {
|
|||||||
|
|
||||||
// Check icon storage
|
// Check icon storage
|
||||||
for (let i = 0; i < 3; i++) {
|
for (let i = 0; i < 3; i++) {
|
||||||
expect(iconExists(storage, 'foo' + i.toString())).toBe(true);
|
expect(iconInStorage(storage, 'foo' + i.toString())).toBe(true);
|
||||||
}
|
}
|
||||||
for (let i = 0; i < 4; i++) {
|
for (let i = 0; i < 4; i++) {
|
||||||
expect(iconExists(storage, 'bar' + i.toString())).toBe(true);
|
expect(iconInStorage(storage, 'bar' + i.toString())).toBe(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set localStorage to read-only
|
// Set localStorage to read-only
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { defaultIconProps } from '@iconify/utils/lib/icon/defaults';
|
import { defaultIconProps } from '@iconify/utils/lib/icon/defaults';
|
||||||
import { addIconSet, getStorage, listIcons } from '../../lib/storage/storage';
|
import { addIconSet, getStorage, listIcons } from '../../lib/storage/storage';
|
||||||
import {
|
import {
|
||||||
iconExists,
|
iconLoaded,
|
||||||
getIcon,
|
getIcon,
|
||||||
addIcon,
|
addIcon,
|
||||||
addCollection,
|
addCollection,
|
||||||
@ -28,7 +28,7 @@ describe('Testing IconifyStorageFunctions', () => {
|
|||||||
const testName = `@${provider}:foo:bar`;
|
const testName = `@${provider}:foo:bar`;
|
||||||
|
|
||||||
// Empty
|
// Empty
|
||||||
expect(iconExists(testName)).toBe(false);
|
expect(iconLoaded(testName)).toBe(false);
|
||||||
expect(getIconData(testName)).toBeUndefined();
|
expect(getIconData(testName)).toBeUndefined();
|
||||||
expect(getIcon(testName)).toBeNull();
|
expect(getIcon(testName)).toBeNull();
|
||||||
expect(listIcons(provider)).toEqual([]);
|
expect(listIcons(provider)).toEqual([]);
|
||||||
@ -39,7 +39,7 @@ describe('Testing IconifyStorageFunctions', () => {
|
|||||||
body: '<g />',
|
body: '<g />',
|
||||||
})
|
})
|
||||||
).toBe(true);
|
).toBe(true);
|
||||||
expect(iconExists(testName)).toBe(true);
|
expect(iconLoaded(testName)).toBe(true);
|
||||||
expect(listIcons(provider)).toEqual([testName]);
|
expect(listIcons(provider)).toEqual([testName]);
|
||||||
|
|
||||||
let expected = {
|
let expected = {
|
||||||
@ -65,7 +65,7 @@ describe('Testing IconifyStorageFunctions', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Test 'home' icon
|
// Test 'home' icon
|
||||||
expect(iconExists(`${prefix}:home`)).toBe(true);
|
expect(iconLoaded(`${prefix}:home`)).toBe(true);
|
||||||
expected = {
|
expected = {
|
||||||
body: '<g id="home" />',
|
body: '<g id="home" />',
|
||||||
};
|
};
|
||||||
@ -76,12 +76,12 @@ describe('Testing IconifyStorageFunctions', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Test 'missing' icon
|
// Test 'missing' icon
|
||||||
expect(iconExists(`${prefix}:missing`)).toBe(false);
|
expect(iconLoaded(`${prefix}:missing`)).toBe(false);
|
||||||
expect(getIconData(`${prefix}:missing`)).toBeNull();
|
expect(getIconData(`${prefix}:missing`)).toBeNull();
|
||||||
expect(getIcon(`${prefix}:missing`)).toBeNull();
|
expect(getIcon(`${prefix}:missing`)).toBeNull();
|
||||||
|
|
||||||
// Test 'invalid' icon
|
// Test 'invalid' icon
|
||||||
expect(iconExists(`${prefix}:invalid`)).toBe(false);
|
expect(iconLoaded(`${prefix}:invalid`)).toBe(false);
|
||||||
expect(getIconData(`${prefix}:invalid`)).toBeUndefined();
|
expect(getIconData(`${prefix}:invalid`)).toBeUndefined();
|
||||||
expect(getIcon(`${prefix}:invalid`)).toBeNull();
|
expect(getIcon(`${prefix}:invalid`)).toBeNull();
|
||||||
});
|
});
|
||||||
@ -90,7 +90,7 @@ describe('Testing IconifyStorageFunctions', () => {
|
|||||||
const testName = 'storage' + (count++).toString();
|
const testName = 'storage' + (count++).toString();
|
||||||
|
|
||||||
// Empty
|
// Empty
|
||||||
expect(iconExists(testName)).toBe(false);
|
expect(iconLoaded(testName)).toBe(false);
|
||||||
expect(getIconData(testName)).toBeUndefined();
|
expect(getIconData(testName)).toBeUndefined();
|
||||||
expect(getIcon(testName)).toBeNull();
|
expect(getIcon(testName)).toBeNull();
|
||||||
|
|
||||||
@ -100,7 +100,7 @@ describe('Testing IconifyStorageFunctions', () => {
|
|||||||
body: '<g />',
|
body: '<g />',
|
||||||
})
|
})
|
||||||
).toBe(false);
|
).toBe(false);
|
||||||
expect(iconExists(testName)).toBe(false);
|
expect(iconLoaded(testName)).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Invalid icon set', () => {
|
it('Invalid icon set', () => {
|
||||||
@ -124,7 +124,7 @@ describe('Testing IconifyStorageFunctions', () => {
|
|||||||
allowSimpleNames(true);
|
allowSimpleNames(true);
|
||||||
|
|
||||||
// Empty
|
// Empty
|
||||||
expect(iconExists(testName)).toBe(false);
|
expect(iconLoaded(testName)).toBe(false);
|
||||||
expect(getIcon(testName)).toBeNull();
|
expect(getIcon(testName)).toBeNull();
|
||||||
|
|
||||||
// Add and test one icon
|
// Add and test one icon
|
||||||
@ -133,7 +133,7 @@ describe('Testing IconifyStorageFunctions', () => {
|
|||||||
body: '<g />',
|
body: '<g />',
|
||||||
})
|
})
|
||||||
).toBe(true);
|
).toBe(true);
|
||||||
expect(iconExists(testName)).toBe(true);
|
expect(iconLoaded(testName)).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Collection with simple icon name', () => {
|
it('Collection with simple icon name', () => {
|
||||||
@ -166,7 +166,7 @@ describe('Testing IconifyStorageFunctions', () => {
|
|||||||
|
|
||||||
// Test 'test'
|
// Test 'test'
|
||||||
name = name1;
|
name = name1;
|
||||||
expect(iconExists(name)).toBe(true);
|
expect(iconLoaded(name)).toBe(true);
|
||||||
let expected = {
|
let expected = {
|
||||||
body: '<g data-icon="basic-icon" />',
|
body: '<g data-icon="basic-icon" />',
|
||||||
};
|
};
|
||||||
@ -179,7 +179,7 @@ describe('Testing IconifyStorageFunctions', () => {
|
|||||||
// Test prefixed icon, using ':' separator
|
// Test prefixed icon, using ':' separator
|
||||||
name = `${prefix2}:${name2}`;
|
name = `${prefix2}:${name2}`;
|
||||||
expect(listIcons('', prefix2)).toEqual([name]);
|
expect(listIcons('', prefix2)).toEqual([name]);
|
||||||
expect(iconExists(name)).toBe(true);
|
expect(iconLoaded(name)).toBe(true);
|
||||||
expected = {
|
expected = {
|
||||||
body: '<g data-icon="prefixed-icon" />',
|
body: '<g data-icon="prefixed-icon" />',
|
||||||
};
|
};
|
||||||
@ -191,7 +191,7 @@ describe('Testing IconifyStorageFunctions', () => {
|
|||||||
|
|
||||||
// Test prefixed icon, using '-' separator
|
// Test prefixed icon, using '-' separator
|
||||||
name = `${prefix2}-${name2}`;
|
name = `${prefix2}-${name2}`;
|
||||||
expect(iconExists(name)).toBe(true);
|
expect(iconLoaded(name)).toBe(true);
|
||||||
expected = {
|
expected = {
|
||||||
body: '<g data-icon="prefixed-icon" />',
|
body: '<g data-icon="prefixed-icon" />',
|
||||||
};
|
};
|
||||||
@ -202,7 +202,7 @@ describe('Testing IconifyStorageFunctions', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Test missing icon: should not exist because without provider missing icon cannot be added
|
// Test missing icon: should not exist because without provider missing icon cannot be added
|
||||||
expect(iconExists(missing)).toBe(false);
|
expect(iconLoaded(missing)).toBe(false);
|
||||||
expect(getIconData(missing)).toBeUndefined();
|
expect(getIconData(missing)).toBeUndefined();
|
||||||
expect(getIcon(missing)).toBeNull();
|
expect(getIcon(missing)).toBeNull();
|
||||||
});
|
});
|
||||||
|
@ -3,7 +3,7 @@ import type { IconifyIcon } from '@iconify/types';
|
|||||||
import {
|
import {
|
||||||
newStorage,
|
newStorage,
|
||||||
addIconToStorage,
|
addIconToStorage,
|
||||||
iconExists,
|
iconInStorage,
|
||||||
addIconSet,
|
addIconSet,
|
||||||
getStorage,
|
getStorage,
|
||||||
listIcons,
|
listIcons,
|
||||||
@ -46,12 +46,12 @@ describe('Testing storage', () => {
|
|||||||
'constructor',
|
'constructor',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Test iconExists
|
// Test iconInStorage
|
||||||
expect(iconExists(storage, 'test')).toBe(true);
|
expect(iconInStorage(storage, 'test')).toBe(true);
|
||||||
expect(iconExists(storage, 'constructor')).toBe(true);
|
expect(iconInStorage(storage, 'constructor')).toBe(true);
|
||||||
expect(iconExists(storage, 'invalid')).toBe(false);
|
expect(iconInStorage(storage, 'invalid')).toBe(false);
|
||||||
expect(iconExists(storage, 'missing')).toBe(false);
|
expect(iconInStorage(storage, 'missing')).toBe(false);
|
||||||
expect(iconExists(storage, 'not-really-missing')).toBe(true);
|
expect(iconInStorage(storage, 'not-really-missing')).toBe(true);
|
||||||
|
|
||||||
// Test getIcon
|
// Test getIcon
|
||||||
let expected: IconifyIcon = {
|
let expected: IconifyIcon = {
|
||||||
@ -96,11 +96,11 @@ describe('Testing storage', () => {
|
|||||||
|
|
||||||
expect(Object.keys(storage.icons)).toEqual(['icon1', 'icon2']);
|
expect(Object.keys(storage.icons)).toEqual(['icon1', 'icon2']);
|
||||||
|
|
||||||
// Test iconExists
|
// Test iconInStorage
|
||||||
expect(iconExists(storage, 'icon1')).toBe(true);
|
expect(iconInStorage(storage, 'icon1')).toBe(true);
|
||||||
expect(iconExists(storage, 'icon2')).toBe(true);
|
expect(iconInStorage(storage, 'icon2')).toBe(true);
|
||||||
expect(iconExists(storage, 'invalid')).toBe(false);
|
expect(iconInStorage(storage, 'invalid')).toBe(false);
|
||||||
expect(iconExists(storage, 'missing')).toBe(false);
|
expect(iconInStorage(storage, 'missing')).toBe(false);
|
||||||
|
|
||||||
// Test getIcon
|
// Test getIcon
|
||||||
let expected: IconifyIcon = {
|
let expected: IconifyIcon = {
|
||||||
|
Loading…
Reference in New Issue
Block a user