import { toRichText } from "../utils";

const testRichText = [
  {
    type: "text",
    plain_text: "NTMS",
    annotations: {
      bold: true,
      italic: false,
      strikethrough: false,
      underline: false,
      code: false,
      color: "default",
    },
    href: "https://ntms.dev",
  },
  {
    type: "text",
    plain_text: " IS AWESOME",
    annotations: {
      bold: false,
      italic: false,
      strikethrough: false,
      underline: true,
      code: false,
      color: "red",
    },
    href: null,
  },
];

const testRichText2 = [
  {
    type: "text",
    plain_text: "{{NTMS}}",
    annotations: {
      bold: true,
      italic: false,
      strikethrough: false,
      underline: false,
      code: true,
      color: "default",
    },
    href: null,
  },
  {
    type: "text",
    plain_text: "{{test}}",
    annotations: {
      bold: false,
      italic: false,
      strikethrough: false,
      underline: false,
      code: false,
      color: "default",
    },
    href: null,
  },
];

const testRichText3 = [
  {
    type: "text",
    plain_text: "I have {{number}}",
    annotations: {
      bold: true,
      italic: false,
      strikethrough: false,
      underline: false,
      code: false,
      color: "default",
    },
    href: null,
  },
  {
    type: "text",
    plain_text: "((message,messages))",
    annotations: {
      bold: false,
      italic: false,
      strikethrough: false,
      underline: false,
      code: false,
      color: "default",
    },
    href: null,
  },
];

const testHtml = `<span><a href="https://ntms.dev"><b>NTMS</b></a></span><span><mark data-color="red"><u> IS AWESOME</u></mark></span>`;
const testHtml2 =
  "<span><pre><b><mustach>NTMS</mustach></b></pre></span><span><mustach>test</mustach></span>";
const testHtml3 = `<span><b>I have <mustach>number</mustach></b></span><span><plural>message,messages</plural></span>`;
describe("To plain text", () => {
  it("Should transform html to rich text", () => {
    expect(toRichText(testHtml)).toEqual(testRichText);
  });
  it("Should return a rich text with mustach", () => {
    expect(toRichText(testHtml2)).toEqual(testRichText2);
  });
  it("Should return a rich text with mustach and plural", () => {
    expect(toRichText(testHtml3)).toEqual(testRichText3);
  });
});
