chore: fix lint errors — auto-format, isNaN, unused imports, button type
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -536,9 +536,15 @@ describe("listGlobalItemsForAdmin", () => {
|
||||
|
||||
it("filters by query string (brand/model)", async () => {
|
||||
const mfr = await insertManufacturer(db, "Salsa", "salsa");
|
||||
await insertGlobalItem(db, { manufacturerId: mfr.id, model: "Woodsmoke 700" });
|
||||
await insertGlobalItem(db, {
|
||||
manufacturerId: mfr.id,
|
||||
model: "Woodsmoke 700",
|
||||
});
|
||||
const mfr2 = await insertManufacturer(db, "Apidura", "apidura");
|
||||
await insertGlobalItem(db, { manufacturerId: mfr2.id, model: "Racing Saddle Bag" });
|
||||
await insertGlobalItem(db, {
|
||||
manufacturerId: mfr2.id,
|
||||
model: "Racing Saddle Bag",
|
||||
});
|
||||
|
||||
const result = await listGlobalItemsForAdmin(db, { query: "salsa" });
|
||||
expect(result.items).toHaveLength(1);
|
||||
@@ -547,7 +553,10 @@ describe("listGlobalItemsForAdmin", () => {
|
||||
|
||||
it("includes tags and ownerCount per item", async () => {
|
||||
const mfr = await insertManufacturer(db);
|
||||
const globalItem = await insertGlobalItem(db, { manufacturerId: mfr.id, model: "Test Item" });
|
||||
const globalItem = await insertGlobalItem(db, {
|
||||
manufacturerId: mfr.id,
|
||||
model: "Test Item",
|
||||
});
|
||||
const tag = await insertTag(db, "bikepacking");
|
||||
await tagGlobalItem(db, globalItem.id, tag.id!);
|
||||
|
||||
@@ -556,7 +565,9 @@ describe("listGlobalItemsForAdmin", () => {
|
||||
.insert(schema.users)
|
||||
.values({ logtoSub: "test-sub" })
|
||||
.returning();
|
||||
await insertItem(db, "My Test Item", user!.id, { globalItemId: globalItem.id });
|
||||
await insertItem(db, "My Test Item", user!.id, {
|
||||
globalItemId: globalItem.id,
|
||||
});
|
||||
|
||||
const result = await listGlobalItemsForAdmin(db);
|
||||
expect(result.items).toHaveLength(1);
|
||||
@@ -579,7 +590,10 @@ describe("updateGlobalItemById", () => {
|
||||
|
||||
it("updates model field by id", async () => {
|
||||
const mfr = await insertManufacturer(db);
|
||||
const globalItem = await insertGlobalItem(db, { manufacturerId: mfr.id, model: "Original" });
|
||||
const globalItem = await insertGlobalItem(db, {
|
||||
manufacturerId: mfr.id,
|
||||
model: "Original",
|
||||
});
|
||||
|
||||
await updateGlobalItemById(db, globalItem.id, { model: "Updated" });
|
||||
|
||||
@@ -589,9 +603,14 @@ describe("updateGlobalItemById", () => {
|
||||
|
||||
it("syncs tags when tags array provided", async () => {
|
||||
const mfr = await insertManufacturer(db);
|
||||
const globalItem = await insertGlobalItem(db, { manufacturerId: mfr.id, model: "Tagged Item" });
|
||||
const globalItem = await insertGlobalItem(db, {
|
||||
manufacturerId: mfr.id,
|
||||
model: "Tagged Item",
|
||||
});
|
||||
|
||||
await updateGlobalItemById(db, globalItem.id, { tags: ["cycling", "gravel"] });
|
||||
await updateGlobalItemById(db, globalItem.id, {
|
||||
tags: ["cycling", "gravel"],
|
||||
});
|
||||
|
||||
const result = await listGlobalItemsForAdmin(db);
|
||||
const found = result.items.find((i) => i.id === globalItem.id);
|
||||
@@ -614,7 +633,10 @@ describe("deleteGlobalItem", () => {
|
||||
|
||||
it("deletes item and returns true", async () => {
|
||||
const mfr = await insertManufacturer(db);
|
||||
const globalItem = await insertGlobalItem(db, { manufacturerId: mfr.id, model: "To Delete" });
|
||||
const globalItem = await insertGlobalItem(db, {
|
||||
manufacturerId: mfr.id,
|
||||
model: "To Delete",
|
||||
});
|
||||
|
||||
const result = await deleteGlobalItem(db, globalItem.id);
|
||||
expect(result).toBe(true);
|
||||
@@ -625,12 +647,17 @@ describe("deleteGlobalItem", () => {
|
||||
|
||||
it("nullifies items.globalItemId before deleting", async () => {
|
||||
const mfr = await insertManufacturer(db);
|
||||
const globalItem = await insertGlobalItem(db, { manufacturerId: mfr.id, model: "Owned Item" });
|
||||
const globalItem = await insertGlobalItem(db, {
|
||||
manufacturerId: mfr.id,
|
||||
model: "Owned Item",
|
||||
});
|
||||
const [user] = await db
|
||||
.insert(schema.users)
|
||||
.values({ logtoSub: "delete-test-sub" })
|
||||
.returning();
|
||||
const userItem = await insertItem(db, "User Item", user!.id, { globalItemId: globalItem.id });
|
||||
const userItem = await insertItem(db, "User Item", user!.id, {
|
||||
globalItemId: globalItem.id,
|
||||
});
|
||||
|
||||
await deleteGlobalItem(db, globalItem.id);
|
||||
|
||||
@@ -643,7 +670,10 @@ describe("deleteGlobalItem", () => {
|
||||
|
||||
it("removes globalItemTags before deleting", async () => {
|
||||
const mfr = await insertManufacturer(db);
|
||||
const globalItem = await insertGlobalItem(db, { manufacturerId: mfr.id, model: "Tagged Delete" });
|
||||
const globalItem = await insertGlobalItem(db, {
|
||||
manufacturerId: mfr.id,
|
||||
model: "Tagged Delete",
|
||||
});
|
||||
const tag = await insertTag(db, "delete-tag");
|
||||
await tagGlobalItem(db, globalItem.id, tag.id!);
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { beforeEach, describe, expect, it } from "bun:test";
|
||||
import { manufacturers } from "../../src/db/schema.ts";
|
||||
import {
|
||||
createManufacturer,
|
||||
getManufacturerBySlug,
|
||||
|
||||
@@ -5,16 +5,11 @@ import {
|
||||
deleteTag,
|
||||
getAdminTags,
|
||||
getAllTags,
|
||||
getTagWithCounts,
|
||||
updateTag,
|
||||
} from "../../src/server/services/tag.service.ts";
|
||||
import { createTestDb } from "../helpers/db.ts";
|
||||
|
||||
async function insertTag(
|
||||
db: any,
|
||||
name: string,
|
||||
parentId?: number | null,
|
||||
) {
|
||||
async function insertTag(db: any, name: string, parentId?: number | null) {
|
||||
const [row] = await db
|
||||
.insert(tags)
|
||||
.values({ name, parentId: parentId ?? null })
|
||||
@@ -108,7 +103,10 @@ describe("createTag", () => {
|
||||
|
||||
it("creates a tag with parentId set to an existing tag id", async () => {
|
||||
const parent = await createTag(db, { name: "gear" });
|
||||
const child = await createTag(db, { name: "clothing", parentId: parent.id });
|
||||
const child = await createTag(db, {
|
||||
name: "clothing",
|
||||
parentId: parent.id,
|
||||
});
|
||||
expect(child.parentId).toBe(parent.id);
|
||||
});
|
||||
});
|
||||
@@ -175,7 +173,7 @@ describe("deleteTag", () => {
|
||||
const parent = await insertTag(db, "parent");
|
||||
const child = await insertTag(db, "child", parent.id);
|
||||
await deleteTag(db, parent.id);
|
||||
const [childRow] = await db
|
||||
const [_childRow] = await db
|
||||
.select({ parentId: tags.parentId })
|
||||
.from(tags)
|
||||
.where((t: any) => t.id === child.id);
|
||||
|
||||
Reference in New Issue
Block a user