mirror of
https://github.com/iconify/iconify.git
synced 2025-01-06 07:20:40 +00:00
Fix linting errors in tests in core
This commit is contained in:
parent
32819127dd
commit
3f89dd6cec
@ -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([
|
||||
|
@ -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';
|
||||
|
@ -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<string, IconifyIcon>;
|
||||
params.icons.forEach((icon) => {
|
||||
icons[icon] = {
|
||||
body: '<path d="" />',
|
||||
|
@ -12,7 +12,7 @@ describe('Testing mock API module prepare function', () => {
|
||||
return (
|
||||
'api-mock-prepare-' +
|
||||
(prefixCounter < 10 ? '0' : '') +
|
||||
prefixCounter
|
||||
prefixCounter.toString()
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -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()
|
||||
);
|
||||
}
|
||||
|
||||
|
6
packages/core/tests/cache/fake_cache.ts
vendored
6
packages/core/tests/cache/fake_cache.ts
vendored
@ -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<string, string> = Object.create(null);
|
||||
items = Object.create(null) as Record<string, string>;
|
||||
|
||||
/**
|
||||
* 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<string, string>;
|
||||
}
|
||||
}
|
||||
|
||||
|
18
packages/core/tests/cache/loading-test.ts
vendored
18
packages/core/tests/cache/loading-test.ts
vendored
@ -427,7 +427,7 @@ describe('Testing loading from localStorage', () => {
|
||||
const icon: IconifyJSON = {
|
||||
prefix: prefix,
|
||||
icons: {
|
||||
['foo' + i]: {
|
||||
['foo' + i.toString()]: {
|
||||
body: '<g></g>',
|
||||
},
|
||||
},
|
||||
@ -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
|
||||
|
48
packages/core/tests/cache/saving-test.ts
vendored
48
packages/core/tests/cache/saving-test.ts
vendored
@ -231,7 +231,7 @@ describe('Testing saving to localStorage', () => {
|
||||
const icon: IconifyJSON = {
|
||||
prefix: prefix,
|
||||
icons: {
|
||||
['foo' + i]: {
|
||||
['foo' + i.toString()]: {
|
||||
body: '<g></g>',
|
||||
},
|
||||
},
|
||||
@ -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: '<g></g>',
|
||||
},
|
||||
},
|
||||
@ -455,7 +455,7 @@ describe('Testing saving to localStorage', () => {
|
||||
const icon: IconifyJSON = {
|
||||
prefix: prefix,
|
||||
icons: {
|
||||
['foo' + index]: {
|
||||
['foo' + index.toString()]: {
|
||||
body: '<g></g>',
|
||||
},
|
||||
},
|
||||
@ -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: '<g></g>',
|
||||
},
|
||||
},
|
||||
@ -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: '<g></g>',
|
||||
},
|
||||
},
|
||||
@ -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: '<g></g>',
|
||||
},
|
||||
},
|
||||
@ -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
|
||||
|
@ -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(
|
||||
|
Loading…
Reference in New Issue
Block a user