Skip to content

Commit

Permalink
replace comparing strings for sort with .localCompare, add t.plan to
Browse files Browse the repository at this point in the history
check if assertions have been called
  • Loading branch information
Tomás Ciccola committed Feb 14, 2024
1 parent 4799c4b commit 5aa4504
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/config-import.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
3 changes: 1 addition & 2 deletions tests/config-import.js
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand All @@ -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')
})

Expand Down

0 comments on commit 5aa4504

Please sign in to comment.