/**
 * @copyright 2026 NHCarrigan
 * @license Naomi's Public License
 * @author Naomi Carrigan
 */

import type { CommentUser, Comment, CreateCommentDto } from "../src/lib/comment.types";

describe("comment Types", () => {
  describe("commentUser interface", () => {
    it("should accept valid user object with minimal fields", () => {
      const user: CommentUser = {
        id:       "user123",
        username: "testuser",
      };

      expect(user.avatar).toBeUndefined();
      expect(user.inDiscord).toBeUndefined();
      expect(user.isVip).toBeUndefined();
      expect(user.isMod).toBeUndefined();
      expect(user.isStaff).toBeUndefined();
    });

    it("should accept valid user object with all fields", () => {
      const fullUser: CommentUser = {
        avatar:    "https://example.com/avatar.png",
        id:        "user456",
        inDiscord: true,
        isMod:     true,
        isStaff:   false,
        isVip:     true,
        username:  "vipmoduser",
      };

      expect(fullUser.avatar).toBe("https://example.com/avatar.png");
      expect(fullUser.inDiscord).toBeTruthy();
      expect(fullUser.isVip).toBeTruthy();
      expect(fullUser.isMod).toBeTruthy();
      expect(fullUser.isStaff).toBeFalsy();
    });
  });

  describe("comment interface", () => {
    it("should accept valid comment object with minimal fields", () => {
      const comment: Comment = {
        content:   "This is a great book!",
        createdAt: new Date("2024-01-15"),
        id:        "comment123",
        updatedAt: new Date("2024-01-15"),
        user:      {
          id:       "user123",
          username: "bookworm",
        },
        userId: "user123",
      };

      expect(comment.rawContent).toBeUndefined();
      expect(comment.gameId).toBeUndefined();
      expect(comment.bookId).toBeUndefined();
      expect(comment.musicId).toBeUndefined();
      expect(comment.artId).toBeUndefined();
      expect(comment.showId).toBeUndefined();
      expect(comment.mangaId).toBeUndefined();
    });

    it("should accept comment for a book", () => {
      const bookComment: Comment = {
        bookId:     "book123",
        content:    "<p>Amazing read!</p>",
        createdAt:  new Date("2024-01-20"),
        id:         "comment456",
        rawContent: "Amazing read!",
        updatedAt:  new Date("2024-01-21"),
        user:       {
          avatar:    "https://example.com/reader.png",
          id:        "user789",
          inDiscord: true,
          isMod:     false,
          isStaff:   false,
          isVip:     false,
          username:  "reader",
        },
        userId: "user789",
      };

      expect(bookComment.bookId).toBe("book123");
      expect(bookComment.rawContent).toBe("Amazing read!");
      expect(bookComment.gameId).toBeUndefined();
    });

    it("should accept comment for a game", () => {
      const gameComment: Comment = {
        content:   "Best game ever!",
        createdAt: new Date("2024-02-01"),
        gameId:    "game789",
        id:        "comment789",
        updatedAt: new Date("2024-02-01"),
        user:      {
          id:       "user456",
          username: "gamer",
        },
        userId: "user456",
      };

      expect(gameComment.gameId).toBe("game789");
      expect(gameComment.bookId).toBeUndefined();
    });

    it("should accept comment for music", () => {
      const musicComment: Comment = {
        content:   "Beautiful album",
        createdAt: new Date("2024-02-10"),
        id:        "comment999",
        musicId:   "music123",
        updatedAt: new Date("2024-02-10"),
        user:      {
          id:       "user111",
          username: "musiclover",
        },
        userId: "user111",
      };

      expect(musicComment.musicId).toBe("music123");
    });

    it("should accept comment for art", () => {
      const artComment: Comment = {
        artId:     "art456",
        content:   "Stunning artwork!",
        createdAt: new Date("2024-02-15"),
        id:        "comment111",
        updatedAt: new Date("2024-02-15"),
        user:      {
          id:       "user222",
          username: "artcritic",
        },
        userId: "user222",
      };

      expect(artComment.artId).toBe("art456");
    });

    it("should accept comment for a show", () => {
      const showComment: Comment = {
        content:   "Great series!",
        createdAt: new Date("2024-02-20"),
        id:        "comment222",
        showId:    "show789",
        updatedAt: new Date("2024-02-20"),
        user:      {
          id:       "user333",
          username: "tvfan",
        },
        userId: "user333",
      };

      expect(showComment.showId).toBe("show789");
    });

    it("should accept comment for manga", () => {
      const mangaComment: Comment = {
        content:   "Awesome manga!",
        createdAt: new Date("2024-02-25"),
        id:        "comment333",
        mangaId:   "manga123",
        updatedAt: new Date("2024-02-25"),
        user:      {
          id:       "user444",
          username: "mangareader",
        },
        userId: "user444",
      };

      expect(mangaComment.mangaId).toBe("manga123");
    });
  });

  describe("createCommentDto interface", () => {
    it("should accept DTO with content", () => {
      const createDto: CreateCommentDto = {
        content: "This is my comment",
      };

      expect(createDto.content).toBe("This is my comment");
    });

    it("should accept DTO with formatted content", () => {
      const createDto: CreateCommentDto = {
        content: "<p>This is <strong>formatted</strong> content!</p>",
      };

      expect(createDto.content).toBe("<p>This is <strong>formatted</strong> content!</p>");
    });
  });
});
