2021-12-25 16:22:56 +02:00
|
|
|
import simpleIcons from '../index.js';
|
2022-03-14 22:04:50 +02:00
|
|
|
import { getIconSlug, getIconsData, titleToSlug } from '../scripts/utils.js';
|
2022-01-19 19:23:32 +02:00
|
|
|
import { test } from 'mocha';
|
|
|
|
import { strict as assert } from 'node:assert';
|
2021-11-06 17:03:37 +02:00
|
|
|
|
2021-12-25 16:22:56 +02:00
|
|
|
(async () => {
|
|
|
|
const icons = await getIconsData();
|
2019-07-14 21:05:38 +02:00
|
|
|
|
2021-12-25 16:22:56 +02:00
|
|
|
icons.forEach((icon) => {
|
|
|
|
const slug = getIconSlug(icon);
|
|
|
|
|
|
|
|
test(`'Get' ${icon.title} by its slug`, () => {
|
|
|
|
const found = simpleIcons.Get(slug);
|
|
|
|
assert.ok(found);
|
2022-01-19 19:23:32 +02:00
|
|
|
assert.equal(found.title, icon.title);
|
|
|
|
assert.equal(found.hex, icon.hex);
|
|
|
|
assert.equal(found.source, icon.source);
|
2021-12-25 16:22:56 +02:00
|
|
|
});
|
2022-03-14 22:04:50 +02:00
|
|
|
|
|
|
|
if (icon.slug) {
|
|
|
|
// if an icon data has a slug, it must be different to the
|
|
|
|
// slug inferred from the title, which prevents adding
|
|
|
|
// unnecessary slugs to icons data
|
|
|
|
test(`'${icon.title}' slug must be necessary`, () => {
|
|
|
|
assert.notEqual(titleToSlug(icon.title), icon.slug);
|
|
|
|
});
|
|
|
|
}
|
2021-12-25 16:22:56 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
test(`Iterating over simpleIcons only exposes icons`, () => {
|
|
|
|
const iconArray = Object.values(simpleIcons);
|
|
|
|
for (let icon of iconArray) {
|
|
|
|
assert.ok(icon);
|
2022-01-19 19:23:32 +02:00
|
|
|
assert.equal(typeof icon, 'object');
|
2021-12-25 16:22:56 +02:00
|
|
|
}
|
2021-05-28 12:16:50 +02:00
|
|
|
});
|
2021-12-25 16:22:56 +02:00
|
|
|
})();
|