feat(guides): organize schemas and export teams
This commit is contained in:
@@ -1,6 +1,10 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { cleanLunarisText, constellationSnapshot } from "@/lib/catalog/lunaris";
|
||||
import {
|
||||
characterDetailSchema,
|
||||
cleanLunarisText,
|
||||
constellationSnapshot,
|
||||
} from "@/lib/catalog/lunaris";
|
||||
|
||||
describe("Lunaris character data", () => {
|
||||
it("removes display markup from constellation text", () => {
|
||||
@@ -20,4 +24,10 @@ describe("Lunaris character data", () => {
|
||||
iconKey: "catalog/1/constellations/UI_Talent_Test_01.webp",
|
||||
}]);
|
||||
});
|
||||
|
||||
it("accepts characters that do not have constellations", () => {
|
||||
const detail = characterDetailSchema.parse({ constellations: null });
|
||||
|
||||
expect(constellationSnapshot(detail, (icon) => icon)).toEqual([]);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -14,7 +14,7 @@ const constellationSchema = z.object({
|
||||
});
|
||||
|
||||
export const characterDetailSchema = z.object({
|
||||
constellations: z.record(z.string(), constellationSchema),
|
||||
constellations: z.record(z.string(), constellationSchema).nullish(),
|
||||
});
|
||||
|
||||
export function cleanLunarisText(value: string): string {
|
||||
@@ -32,7 +32,7 @@ export function constellationSnapshot(
|
||||
const result: CatalogConstellation[] = [];
|
||||
for (const index of Array.from({ length: 6 }, (_, itemIndex) => itemIndex)) {
|
||||
const level = index + 1;
|
||||
const item = value.constellations[`const${level}`];
|
||||
const item = value.constellations?.[`const${level}`];
|
||||
if (!item) continue;
|
||||
result.push({
|
||||
level,
|
||||
|
||||
Reference in New Issue
Block a user