32 lines
1.6 KiB
JavaScript
32 lines
1.6 KiB
JavaScript
// The icon sets: every icon offered has a drawing, nothing is offered twice, and the drawings are well-formed.
|
|
import { test } from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import { PATHS, PICKER_ICONS, PICKER_EMOJI, isEmoji } from '../src/lib/icons.js';
|
|
|
|
test('every icon in the picker has a drawing, and none is listed twice', () => {
|
|
const names = PICKER_ICONS.map(([n]) => n);
|
|
assert.deepEqual(names.filter((n) => !PATHS[n]), [], 'missing drawings');
|
|
assert.deepEqual(names.filter((n, i) => names.indexOf(n) !== i), [], 'duplicates');
|
|
for (const [n, words] of PICKER_ICONS) assert.ok(words && words.trim(), `${n} has search words`);
|
|
assert.ok(names.length >= 100, `a good number of icons (${names.length})`);
|
|
});
|
|
|
|
test('every drawing is made of valid path commands, inside the 24px grid', () => {
|
|
for (const [name, d] of Object.entries(PATHS)) {
|
|
for (const part of d.split('|')) {
|
|
assert.match(part, /^[MmLlHhVvCcSsQqTtAaZz0-9eE.,\s-]+$/, `${name}: unexpected characters in "${part}"`);
|
|
assert.match(part, /^[Mm]/, `${name}: a path starts with a move`);
|
|
const nums = (part.match(/-?\d*\.?\d+/g) || []).map(Number);
|
|
assert.ok(nums.length >= 2, `${name} has coordinates`);
|
|
}
|
|
}
|
|
});
|
|
|
|
test('emoji in the picker are real emoji, listed once, with words to find them by', () => {
|
|
const list = PICKER_EMOJI.map(([e]) => e);
|
|
assert.ok(list.every((e) => isEmoji(e)), 'all are emoji');
|
|
assert.deepEqual(list.filter((e, i) => list.indexOf(e) !== i), [], 'duplicates');
|
|
assert.ok(PICKER_EMOJI.every(([, words]) => words.trim()));
|
|
assert.ok(list.length >= 200, `plenty of emoji (${list.length})`);
|
|
});
|