import { AssesmentData } from "./types";
import { getContent, replaceAssesmentData } from "./utils";

test("Should retrieve content when file is correct", () => {
  expect(getContent("Employee")).toBeTruthy;
});

test("Should fail when file does not exists", () => {
  expect(() => {
    getContent("Other");
  }).toThrow("An error ocurred fetching file");
});

test("Should replace text in brackets by variables in data", () => {
  let text: string = "This is some [name] in a [entryDate]";
  const _data: AssesmentData[] = [
    { name: "Test" },
    { entryDate: "12/12/2022" },
  ];

  text = replaceAssesmentData(_data, text);
  expect(text).toContain("This is some Test in a 12/12/2022");
});
