Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/core/bundle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ export async function resolveBundleIcons(options: ResolveBundleIconsOptions): Pr
}

return {
collections: [...collections.values()],
collections: [...collections.values()].sort((a, b) => a.prefix < b.prefix ? -1 : a.prefix > b.prefix ? 1 : 0),
count,
failed,
dropped,
Expand Down
15 changes: 15 additions & 0 deletions test/bundle.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,21 @@ afterAll(() => {
rmSync(root, { recursive: true, force: true })
})

it('returns collections in the same order regardless of icon order', async () => {
const customCollections = ['zeta', 'alpha'].map(prefix => ({
prefix,
icons: { example: { body: '<path d="M0 0h24v24H0z"/>' } },
width: 24,
height: 24,
}))
const options = { customCollections, resolvePaths: [root] }
const first = await resolveBundleIcons({ ...options, icons: ['zeta:example', 'alpha:example'] })
const second = await resolveBundleIcons({ ...options, icons: ['alpha:example', 'zeta:example'] })

expect(first.collections.map(collection => collection.prefix)).toEqual(['alpha', 'zeta'])
expect(first.collections).toEqual(second.collections)
})

it('resolves explicit, scanned and extra icons', async () => {
const result = await resolveBundleIcons({
icons: ['test-bundle:foo'],
Expand Down
Loading