/** * @copyright NHCarrigan * @license Naomi's Public License * @author Naomi Carrigan */ import type { Art, CreateArtDto, UpdateArtDto } from "../src/lib/art.types"; describe("art Types", () => { describe("art interface", () => { it("should accept valid art object with minimal fields", () => { const art: Art = { artist: "Jane Doe", createdAt: new Date(), dateAdded: new Date(), id: "art123", imageUrl: "https://example.com/sunset.jpg", links: [], tags: [], title: "Beautiful Sunset", updatedAt: new Date(), }; expect(art.description).toBeUndefined(); expect(art.tags).toEqual([]); }); it("should accept valid art object with all fields", () => { const fullArt: Art = { artist: "John Smith", createdAt: new Date("2024-01-01"), dateAdded: new Date("2024-01-01"), description: "A breathtaking view of the mountains", id: "art456", imageUrl: "https://example.com/mountains.jpg", links: [ { title: "Artist Portfolio", url: "https://artist.com" }, { title: "Instagram", url: "https://instagram.com/artist" }, ], tags: [ "landscape", "nature", "mountains" ], title: "Mountain Landscape", updatedAt: new Date("2024-01-02"), }; expect(fullArt.description).toBe("A breathtaking view of the mountains"); expect(fullArt.tags).toHaveLength(3); expect(fullArt.links).toHaveLength(2); }); }); describe("createArtDto interface", () => { it("should accept DTO with required fields only", () => { const createDto: CreateArtDto = { artist: "New Artist", imageUrl: "https://example.com/art.jpg", title: "New Artwork", }; expect(createDto.description).toBeUndefined(); expect(createDto.tags).toBeUndefined(); expect(createDto.links).toBeUndefined(); }); it("should accept DTO with all fields", () => { const fullCreateDto: CreateArtDto = { artist: "Famous Artist", description: "Detailed description", imageUrl: "https://example.com/complete.jpg", links: [ { title: "Website", url: "https://website.com" } ], tags: [ "tag1", "tag2" ], title: "Complete Artwork", }; expect(fullCreateDto.tags).toEqual([ "tag1", "tag2" ]); expect(fullCreateDto.links).toHaveLength(1); }); }); describe("updateArtDto type", () => { it("should accept empty update DTO", () => { const emptyUpdate: UpdateArtDto = {}; expect(emptyUpdate).toEqual({}); }); it("should accept partial updates", () => { const partialUpdate: UpdateArtDto = { tags: [ "new-tag" ], title: "Updated Title", }; expect(partialUpdate.title).toBe("Updated Title"); expect(partialUpdate.artist).toBeUndefined(); expect(partialUpdate.tags).toEqual([ "new-tag" ]); }); it("should accept full update", () => { const fullUpdate: UpdateArtDto = { artist: "Different Artist", description: "New description", imageUrl: "https://example.com/new-image.jpg", links: [ { title: "New Link", url: "https://newlink.com" } ], tags: [ "updated", "tags" ], title: "Completely New Title", }; expect(fullUpdate.title).toBe("Completely New Title"); expect(fullUpdate.links).toHaveLength(1); }); }); });