fix: address image picker review
This commit is contained in:
1 parent
a585bf88b3
commit
7b63c60675
10 files changed
+221
-213
No files matched your search
@@ -1,13 +1,7 @@
|
||||
import { describe, expect, test } from "vitest";
|
||||
|
||||
import type { IconGroup } from "./icon-picker.utils";
|
||||
import {
|
||||
arrangeIconPickerSections,
|
||||
findBestIconMatch,
|
||||
isDirectImageUrl,
|
||||
isImageSource,
|
||||
isSvgImage,
|
||||
} from "./icon-picker.utils";
|
||||
import { arrangeIconPickerSections, isDirectImageUrl, isImageSource, isSvgImage } from "./icon-picker.utils";
|
||||
|
||||
const groups = [
|
||||
{
|
||||
@@ -35,26 +29,6 @@ describe("icon picker utilities", () => {
|
||||
expect(result.other.map((icon) => icon.id)).toEqual(["raster"]);
|
||||
});
|
||||
|
||||
test("normalizes punctuation and prefers a user's exact local image", () => {
|
||||
expect(findBestIconMatch("home_assistant", groups)).toBe("/api/user-medias/home-assistant");
|
||||
});
|
||||
|
||||
test("prefers SVG over raster when equally matched outside local images", () => {
|
||||
expect(findBestIconMatch("Home Assistant", [groups[0] as IconGroup])).toBe(
|
||||
"https://cdn.example.com/home-assistant.svg?v=1",
|
||||
);
|
||||
});
|
||||
|
||||
test("prefers an exact normalized name over a longer partial match", () => {
|
||||
expect(findBestIconMatch("home assistant", [groups[0] as IconGroup])).toBe(
|
||||
"https://cdn.example.com/home-assistant.svg?v=1",
|
||||
);
|
||||
});
|
||||
|
||||
test("does not return unrelated icons", () => {
|
||||
expect(findBestIconMatch("jellyfin", groups)).toBeNull();
|
||||
});
|
||||
|
||||
test.each([
|
||||
["https://example.com/icon.png", true],
|
||||
["http://localhost:3000/icon", true],
|
||||
|
||||
Reference in new issue
Block a user