feat: bootstrap auto virtual tryon admin frontend
This commit is contained in:
50
tests/app/api/libraries.route.test.ts
Normal file
50
tests/app/api/libraries.route.test.ts
Normal file
@@ -0,0 +1,50 @@
|
||||
import { expect, test } from "vitest";
|
||||
|
||||
import { GET } from "../../../app/api/libraries/[libraryType]/route";
|
||||
|
||||
test("returns honest placeholder library data for unsupported backend modules", async () => {
|
||||
const response = await GET(new Request("http://localhost/api/libraries/models"), {
|
||||
params: Promise.resolve({ libraryType: "models" }),
|
||||
});
|
||||
const payload = await response.json();
|
||||
|
||||
expect(response.status).toBe(200);
|
||||
expect(payload).toMatchObject({
|
||||
mode: "placeholder",
|
||||
data: {
|
||||
items: expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
libraryType: "models",
|
||||
isMock: true,
|
||||
}),
|
||||
]),
|
||||
},
|
||||
message: "资源库当前使用占位数据,真实后端接口尚未提供。",
|
||||
});
|
||||
});
|
||||
|
||||
test("rejects unsupported placeholder library types with a normalized error", async () => {
|
||||
const response = await GET(new Request("http://localhost/api/libraries/unknown"), {
|
||||
params: Promise.resolve({ libraryType: "unknown" }),
|
||||
});
|
||||
const payload = await response.json();
|
||||
|
||||
expect(response.status).toBe(404);
|
||||
expect(payload).toEqual({
|
||||
error: "NOT_FOUND",
|
||||
message: "不支持的资源库类型。",
|
||||
});
|
||||
});
|
||||
|
||||
test("rejects inherited object keys instead of treating them as valid library types", async () => {
|
||||
const response = await GET(new Request("http://localhost/api/libraries/toString"), {
|
||||
params: Promise.resolve({ libraryType: "toString" }),
|
||||
});
|
||||
const payload = await response.json();
|
||||
|
||||
expect(response.status).toBe(404);
|
||||
expect(payload).toEqual({
|
||||
error: "NOT_FOUND",
|
||||
message: "不支持的资源库类型。",
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user