Files
gridline/desktop/src/components/db-viewer/legendHelpers.test.ts
T
adrianbonpin 6854d889c5 refactor: convert to bun-workspaces monorepo (desktop/ + www/)
- Move the Tauri app (React frontend + Rust backend) into desktop/ via
  git mv — configs unchanged (relative paths: tauri.conf.json, vite.config.ts)
- Root package.json becomes a private bun workspace container with
  orchestration scripts; desktop package renamed gridline-desktop
- Scaffold www/ with Astro 7 + Tailwind v4 (hand-wired vite plugin,
  static output, ready for Dokploy)
- Update release.yml for the new layout: projectPath: desktop,
  desktop/src-tauri resource paths, rust-cache workspace path
- Update README + AGENTS.md structure trees and dev commands
- Verified: vitest (1074), cargo test (354), desktop build, tauri dev
  (window launches), tauri build (dmg + app bundles), Astro build
2026-08-16 19:31:53 +08:00

35 lines
1.2 KiB
TypeScript

import { describe, it, expect } from "vitest";
import {
getCardinalityColor,
getCardinalityLabel,
LEGEND_ITEMS,
} from "./legendHelpers";
describe("legendHelpers", () => {
it("getCardinalityColor returns correct colors", () => {
expect(getCardinalityColor("1:1")).toBe("#22c55e"); // green
expect(getCardinalityColor("1:N")).toBe("#3b82f6"); // blue
expect(getCardinalityColor("N:M")).toBe("#f59e0b"); // amber
});
it("getCardinalityColor returns fallback for unknown", () => {
expect(getCardinalityColor("unknown")).toBe("#6b7280"); // gray fallback
});
it("getCardinalityLabel returns human-readable labels", () => {
expect(getCardinalityLabel("1:1")).toBe("One-to-One");
expect(getCardinalityLabel("1:N")).toBe("One-to-Many");
expect(getCardinalityLabel("N:M")).toBe("Many-to-Many");
});
it("getCardinalityLabel returns raw value for unknown", () => {
expect(getCardinalityLabel("unknown")).toBe("unknown");
});
it("LEGEND_ITEMS has three entries", () => {
expect(LEGEND_ITEMS).toHaveLength(3);
expect(LEGEND_ITEMS[0]).toHaveProperty("cardinality");
expect(LEGEND_ITEMS[0]).toHaveProperty("color");
expect(LEGEND_ITEMS[0]).toHaveProperty("label");
});
});