From 5aa450472d1edd22421d69318eb694461d2b4de8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Ciccola?= Date: Wed, 14 Feb 2024 13:28:30 -0300 Subject: [PATCH] replace comparing strings for sort with `.localCompare`, add t.plan to check if assertions have been called --- src/config-import.js | 4 +++- tests/config-import.js | 3 +-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/config-import.js b/src/config-import.js index 26e32e8e7..0b52db36e 100644 --- a/src/config-import.js +++ b/src/config-import.js @@ -60,7 +60,9 @@ export async function readConfig(configPath) { // we sort the icons by filename so we can group variants together const iconEntries = entries .filter((entry) => entry.filename.match(/^icons\/([^/]+)$/)) - .sort((icon, nextIcon) => (icon.filename > nextIcon.filename ? 1 : -1)) + .sort((icon, nextIcon) => + icon.filename.localeCompare(nextIcon.filename) + ) for (const entry of iconEntries) { if (entry.uncompressedSize > MAX_ICON_SIZE) { diff --git a/tests/config-import.js b/tests/config-import.js index 3e4f885f6..c414cd758 100644 --- a/tests/config-import.js +++ b/tests/config-import.js @@ -130,8 +130,8 @@ test('config import - icons', async (t) => { ) config = await readConfig('./tests/fixtures/config/validIcons.zip') + t.plan(15) // 2 icon assertions + (3+9) variant assertions + 1 no warnings for await (const icon of config.icons()) { - // t.is(icon.name, 'plant', 'icon name is `plant`') if (icon.name === 'plant') { t.is(icon.variants.length, 3, '3 variants of plant icons') } else if (icon.name === 'tree') { @@ -141,7 +141,6 @@ test('config import - icons', async (t) => { t.is(variant.mimeType, 'image/png', 'variant is a png') } } - t.is(config.warnings.length, 0, 'no warnings on the file') })