49 lines
1.2 KiB
TypeScript
49 lines
1.2 KiB
TypeScript
import { expect, test } from "vitest";
|
|
|
|
import { mapModelOptions, mapResourceOptions } from "@/features/orders/resource-picker-options";
|
|
import type { LibraryItemVM } from "@/lib/types/view-models";
|
|
|
|
test("prefers backend-backed ids for models when the resource library provides them even without pose", () => {
|
|
const items: LibraryItemVM[] = [
|
|
{
|
|
id: "12",
|
|
libraryType: "models",
|
|
name: "Ava Studio",
|
|
description: "棚拍女模特",
|
|
previewUri: "https://images.marcusd.me/library/models/ava/thumb.png",
|
|
tags: ["女装"],
|
|
isMock: false,
|
|
backendId: 12,
|
|
},
|
|
];
|
|
|
|
expect(mapModelOptions(items)).toEqual([
|
|
expect.objectContaining({
|
|
id: "12",
|
|
backendId: 12,
|
|
}),
|
|
]);
|
|
});
|
|
|
|
test("prefers backend-backed ids for scene and garment resources when provided", () => {
|
|
const items: LibraryItemVM[] = [
|
|
{
|
|
id: "21",
|
|
libraryType: "scenes",
|
|
name: "Loft Window",
|
|
description: "暖调室内场景",
|
|
previewUri: "https://images.marcusd.me/library/scenes/loft/thumb.png",
|
|
tags: ["室内"],
|
|
isMock: false,
|
|
backendId: 21,
|
|
},
|
|
];
|
|
|
|
expect(mapResourceOptions(items)).toEqual([
|
|
expect.objectContaining({
|
|
id: "21",
|
|
backendId: 21,
|
|
}),
|
|
]);
|
|
});
|