diff --git a/packages/core/tests/api/callbacks-test.ts b/packages/core/tests/api/callbacks-test.ts index a38897f..71a6cc6 100644 --- a/packages/core/tests/api/callbacks-test.ts +++ b/packages/core/tests/api/callbacks-test.ts @@ -10,7 +10,11 @@ describe('Testing API callbacks', () => { let prefixCounter = 0; function nextPrefix(): string { prefixCounter++; - return 'api-cb-test-' + (prefixCounter < 10 ? '0' : '') + prefixCounter; + return ( + 'api-cb-test-' + + (prefixCounter < 10 ? '0' : '') + + prefixCounter.toString() + ); } it('Simple callback', (done) => { @@ -356,7 +360,7 @@ describe('Testing API callbacks', () => { break; default: - done('Callback was called ' + counter + ' times.'); + done(`Callback was called ${counter} times.`); } }, sortIcons([ @@ -480,7 +484,7 @@ describe('Testing API callbacks', () => { break; default: - done('Callback was called ' + counter + ' times.'); + done(`Callback was called ${counter} times.`); } }, sortIcons([ diff --git a/packages/core/tests/api/fetch-test.ts b/packages/core/tests/api/fetch-test.ts index 5e42569..ac29ba6 100644 --- a/packages/core/tests/api/fetch-test.ts +++ b/packages/core/tests/api/fetch-test.ts @@ -8,7 +8,7 @@ import { mockAPIModule } from '../../lib/api/modules/mock'; describe('Testing live API with fetch', () => { let counter = 0; function nextProvider(): string { - return 'fetch-' + counter++; + return 'fetch-' + (counter++).toString(); } const host = 'https://api.iconify.design'; diff --git a/packages/core/tests/api/loading-test.ts b/packages/core/tests/api/loading-test.ts index cb3a70c..e06ce77 100644 --- a/packages/core/tests/api/loading-test.ts +++ b/packages/core/tests/api/loading-test.ts @@ -6,13 +6,16 @@ import type { } from '../../lib/api/modules'; import { setAPIModule } from '../../lib/api/modules'; import { loadIcons, loadIcon, isPending } from '../../lib/api/icons'; +import type { IconifyIcon } from '@iconify/types'; describe('Testing API loadIcons', () => { let prefixCounter = 0; function nextPrefix(): string { prefixCounter++; return ( - 'api-load-test-' + (prefixCounter < 10 ? '0' : '') + prefixCounter + 'api-load-test-' + + (prefixCounter < 10 ? '0' : '') + + prefixCounter.toString() ); } @@ -367,12 +370,12 @@ describe('Testing API loadIcons', () => { type: 'icons', provider, prefix, - icons: ['icon' + queryCounter], + icons: ['icon' + queryCounter.toString()], }; expect(params).toEqual(expected); // Send only requested icons - const icons = Object.create(null); + const icons = Object.create(null) as Record; params.icons.forEach((icon) => { icons[icon] = { body: '', diff --git a/packages/core/tests/api/mock-prepare-test.ts b/packages/core/tests/api/mock-prepare-test.ts index 7f8b510..363773e 100644 --- a/packages/core/tests/api/mock-prepare-test.ts +++ b/packages/core/tests/api/mock-prepare-test.ts @@ -12,7 +12,7 @@ describe('Testing mock API module prepare function', () => { return ( 'api-mock-prepare-' + (prefixCounter < 10 ? '0' : '') + - prefixCounter + prefixCounter.toString() ); } diff --git a/packages/core/tests/api/mock-test.ts b/packages/core/tests/api/mock-test.ts index ccc5d16..ddad0b3 100644 --- a/packages/core/tests/api/mock-test.ts +++ b/packages/core/tests/api/mock-test.ts @@ -10,7 +10,11 @@ describe('Testing mock API module', () => { let prefixCounter = 0; function nextPrefix(): string { prefixCounter++; - return 'api-mock-' + (prefixCounter < 10 ? '0' : '') + prefixCounter; + return ( + 'api-mock-' + + (prefixCounter < 10 ? '0' : '') + + prefixCounter.toString() + ); } // Set API module for provider diff --git a/packages/core/tests/api/modules-test.ts b/packages/core/tests/api/modules-test.ts index 7fda4b8..b4448e6 100644 --- a/packages/core/tests/api/modules-test.ts +++ b/packages/core/tests/api/modules-test.ts @@ -11,7 +11,9 @@ describe('Testing API modules', () => { function nextPrefix(): string { prefixCounter++; return ( - 'api-mod-test-' + (prefixCounter < 10 ? '0' : '') + prefixCounter + 'api-mod-test-' + + (prefixCounter < 10 ? '0' : '') + + prefixCounter.toString() ); } diff --git a/packages/core/tests/cache/fake_cache.ts b/packages/core/tests/cache/fake_cache.ts index befe996..11d70b3 100644 --- a/packages/core/tests/cache/fake_cache.ts +++ b/packages/core/tests/cache/fake_cache.ts @@ -5,7 +5,7 @@ import { mock, count, config, emptyList } from '../../lib/browser-storage'; */ let prefixCounter = 0; export function nextPrefix(): string { - return 'fake-storage-' + prefixCounter++; + return 'fake-storage-' + (prefixCounter++).toString(); } // Cache version. Bump when structure changes @@ -28,7 +28,7 @@ export const cacheExpiration = 168; // In hours export class Storage { canRead = true; canWrite = true; - items: Record = Object.create(null); + items = Object.create(null) as Record; /** * Get number of items @@ -84,7 +84,7 @@ export class Storage { if (!this.canWrite) { throw new Error('Read-only storage'); } - this.items = Object.create(null); + this.items = Object.create(null) as Record; } } diff --git a/packages/core/tests/cache/loading-test.ts b/packages/core/tests/cache/loading-test.ts index 42bf715..8100fdd 100644 --- a/packages/core/tests/cache/loading-test.ts +++ b/packages/core/tests/cache/loading-test.ts @@ -427,7 +427,7 @@ describe('Testing loading from localStorage', () => { const icon: IconifyJSON = { prefix: prefix, icons: { - ['foo' + i]: { + ['foo' + i.toString()]: { body: '', }, }, @@ -443,12 +443,18 @@ describe('Testing loading from localStorage', () => { // Add items 1,3,5 to localStorage [1, 3, 5].forEach((index) => { - cache1.setItem(cachePrefix + index, JSON.stringify(items[index])); + cache1.setItem( + cachePrefix + index.toString(), + JSON.stringify(items[index]) + ); }); // Add items 0 and 2 to sessionStorage [0, 2].forEach((index) => { - cache2.setItem(cachePrefix + index, JSON.stringify(items[index])); + cache2.setItem( + cachePrefix + index.toString(), + JSON.stringify(items[index]) + ); }); // Set cache @@ -460,7 +466,7 @@ describe('Testing loading from localStorage', () => { // Check icon storage const iconsStorage = getStorage(provider, prefix); for (let i = 0; i < 6; i++) { - expect(iconExists(iconsStorage, 'foo' + i)).toBe(false); + expect(iconExists(iconsStorage, 'foo' + i.toString())).toBe(false); } // Load localStorage @@ -468,7 +474,9 @@ describe('Testing loading from localStorage', () => { // Icons should exist now, except for number 4 for (let i = 0; i < 6; i++) { - expect(iconExists(iconsStorage, 'foo' + i)).toBe(i !== 4); + expect(iconExists(iconsStorage, 'foo' + i.toString())).toBe( + i !== 4 + ); } // Check data diff --git a/packages/core/tests/cache/saving-test.ts b/packages/core/tests/cache/saving-test.ts index 5e8a342..a2ac5d9 100644 --- a/packages/core/tests/cache/saving-test.ts +++ b/packages/core/tests/cache/saving-test.ts @@ -231,7 +231,7 @@ describe('Testing saving to localStorage', () => { const icon: IconifyJSON = { prefix: prefix, icons: { - ['foo' + i]: { + ['foo' + i.toString()]: { body: '', }, }, @@ -257,7 +257,7 @@ describe('Testing saving to localStorage', () => { // Skip items 1, 5, 9+ if (i !== 1 && i !== 5 && i < 9) { - cache.setItem(cachePrefix + i, JSON.stringify(item)); + cache.setItem(cachePrefix + i.toString(), JSON.stringify(item)); } } @@ -291,7 +291,7 @@ describe('Testing saving to localStorage', () => { // Check cached items [0, 3, 6, 7, 8].forEach((index) => { - expect(cache.getItem(cachePrefix + index)).toBe( + expect(cache.getItem(cachePrefix + index.toString())).toBe( JSON.stringify(items[index]) ); }); @@ -299,7 +299,7 @@ describe('Testing saving to localStorage', () => { // Check expired items - should have been deleted // Also check items that weren't supposed to be added [2, 4, 1, 5, 9, 10, 11, 12, 13].forEach((index) => { - expect(cache.getItem(cachePrefix + index)).toBeNull(); + expect(cache.getItem(cachePrefix + index.toString())).toBeNull(); }); // Add item 5 @@ -364,11 +364,11 @@ describe('Testing saving to localStorage', () => { cache.setItem(countKey, '3'); for (let i = 0; i < 3; i++) { cache.setItem( - cachePrefix + i, + cachePrefix + i.toString(), JSON.stringify({ prefix: prefix, icons: { - ['foo' + i]: { + ['foo' + i.toString()]: { body: '', }, }, @@ -455,7 +455,7 @@ describe('Testing saving to localStorage', () => { const icon: IconifyJSON = { prefix: prefix, icons: { - ['foo' + index]: { + ['foo' + index.toString()]: { body: '', }, }, @@ -465,7 +465,10 @@ describe('Testing saving to localStorage', () => { provider, data: icon, }; - cache1.setItem(cachePrefix + index, JSON.stringify(item)); + cache1.setItem( + cachePrefix + index.toString(), + JSON.stringify(item) + ); }); // Add icon sets to sessionStorage @@ -475,7 +478,7 @@ describe('Testing saving to localStorage', () => { const icon: IconifyJSON = { prefix: prefix, icons: { - ['bar' + index]: { + ['bar' + index.toString()]: { body: '', }, }, @@ -485,7 +488,10 @@ describe('Testing saving to localStorage', () => { provider, data: icon, }; - cache2.setItem(cachePrefix + index, JSON.stringify(item)); + cache2.setItem( + cachePrefix + index.toString(), + JSON.stringify(item) + ); }); // Set cache @@ -514,10 +520,10 @@ describe('Testing saving to localStorage', () => { // Check icon storage const iconsStorage = getStorage(provider, prefix); for (let i = 0; i < count.local; i++) { - expect(iconExists(iconsStorage, 'foo' + i)).toBe(true); + expect(iconExists(iconsStorage, 'foo' + i.toString())).toBe(true); } for (let i = 0; i < count.session; i++) { - expect(iconExists(iconsStorage, 'bar' + i)).toBe(true); + expect(iconExists(iconsStorage, 'bar' + i.toString())).toBe(true); } // Add new item to localStorage @@ -562,7 +568,7 @@ describe('Testing saving to localStorage', () => { const icon: IconifyJSON = { prefix: prefix, icons: { - ['foo' + index]: { + ['foo' + index.toString()]: { body: '', }, }, @@ -572,7 +578,10 @@ describe('Testing saving to localStorage', () => { provider, data: icon, }; - cache1.setItem(cachePrefix + index, JSON.stringify(item)); + cache1.setItem( + cachePrefix + index.toString(), + JSON.stringify(item) + ); }); // Add icon sets to sessionStorage @@ -582,7 +591,7 @@ describe('Testing saving to localStorage', () => { const icon: IconifyJSON = { prefix: prefix, icons: { - ['bar' + index]: { + ['bar' + index.toString()]: { body: '', }, }, @@ -592,7 +601,10 @@ describe('Testing saving to localStorage', () => { provider, data: icon, }; - cache2.setItem(cachePrefix + index, JSON.stringify(item)); + cache2.setItem( + cachePrefix + index.toString(), + JSON.stringify(item) + ); }); // Set cache @@ -621,10 +633,10 @@ describe('Testing saving to localStorage', () => { // Check icon storage const iconsStorage = getStorage(provider, prefix); for (let i = 0; i < count.local; i++) { - expect(iconExists(iconsStorage, 'foo' + i)).toBe(true); + expect(iconExists(iconsStorage, 'foo' + i.toString())).toBe(true); } for (let i = 0; i < count.session; i++) { - expect(iconExists(iconsStorage, 'bar' + i)).toBe(true); + expect(iconExists(iconsStorage, 'bar' + i.toString())).toBe(true); } // Set localStorage to read-only diff --git a/packages/core/tests/storage/storage-functions-test.ts b/packages/core/tests/storage/storage-functions-test.ts index c05003c..88db3df 100644 --- a/packages/core/tests/storage/storage-functions-test.ts +++ b/packages/core/tests/storage/storage-functions-test.ts @@ -12,7 +12,7 @@ describe('Testing IconifyStorageFunctions', () => { let count = 0; function nextProvider(): string { - return 'storage-test-' + count++; + return 'storage-test-' + (count++).toString(); } it('Storage functions', () => { @@ -35,7 +35,7 @@ describe('Testing IconifyStorageFunctions', () => { }); it('Invalid icon name', () => { - const testName = 'storage' + count++; + const testName = 'storage' + (count++).toString(); // Reset module allowSimpleNames(false); @@ -71,7 +71,7 @@ describe('Testing IconifyStorageFunctions', () => { }); it('Simple icon name', () => { - const testName = 'storage' + count++; + const testName = 'storage' + (count++).toString(); // Enable empty storage allowSimpleNames(true); @@ -101,7 +101,7 @@ describe('Testing IconifyStorageFunctions', () => { allowSimpleNames(true); // Add icon set - const name1 = 'test' + n; + const name1 = 'test' + n.toString(); const prefix2 = `prefixed${n}`; const name2 = `icon${n2}`; expect(