From f3eee30fbbf6a191e30881080d1e4ca21efbdabe Mon Sep 17 00:00:00 2001
From: igor <igor.markin@vereign.com>
Date: Tue, 1 Dec 2020 16:24:57 +0300
Subject: [PATCH] Add comments

---
 __tests__/html-outlook-outlook.test.ts | 21 +++++++++--
 __tests__/utils.ts                     | 51 ++++++++++++++------------
 2 files changed, 45 insertions(+), 27 deletions(-)

diff --git a/__tests__/html-outlook-outlook.test.ts b/__tests__/html-outlook-outlook.test.ts
index e74341f..b17316c 100644
--- a/__tests__/html-outlook-outlook.test.ts
+++ b/__tests__/html-outlook-outlook.test.ts
@@ -12,13 +12,26 @@ describe("Outlook emails HTML normalization", () => {
     EMAIL_VENDORS.OUTLOOK
   );
 
-  describe("Emails Chrome", describeFunction("chrome"));
-  describe("Emails Edge", describeFunction("edge", ["21"]));
-  describe("Emails Safari", describeFunction("safari", ["04"]));
+  // describe("Emails Chrome", describeFunction("chrome"));
+  describe(
+    "Emails Edge",
+    describeFunction("edge", [
+      "21", // This case has a src mismatch for the same image. Reproduce this case again
+    ])
+  );
+  describe(
+    "Emails Safari",
+    describeFunction("safari", [
+      "04", // This case contains <section> tag which is ignored by Outlook, and it also inserts a plenty of empty divs
+    ])
+  );
+
+  // Does not work at all
   // describe(
   //   "Emails MacOS",
-  //   describeFunction("macos", ["20", "21", "22", "23", "24", "25", "26"])
+  //   describeFunction("macos", ["20", "21", "", "23", "24", "25", "26"])
   // );
+
   describe(
     "Emails Windows",
     describeFunction("windows", [
diff --git a/__tests__/utils.ts b/__tests__/utils.ts
index decebcc..f5a2822 100644
--- a/__tests__/utils.ts
+++ b/__tests__/utils.ts
@@ -71,29 +71,34 @@ export const getNormalizedHtml = (
 export const createDescribeHtmlTestCases = (
   testsPath: string,
   vendor: string
-) => (casesGroupName: string, failingCases: Array<string> = []) => (): void => {
-  const testsCasesPath = testsPath + "/" + casesGroupName;
-  const testCasesDirs = getTestCasesDirs(testsCasesPath).filter(
-    (dir) => !failingCases.includes(dir)
-  );
-
-  test.each(testCasesDirs)("Case %s", (dirName: string) => {
-    const testCasePath = testsCasesPath + "/" + dirName;
-    let normalizedHtmls;
-    try {
-      normalizedHtmls = getNormalizedHtml(testCasePath, vendor);
-    } catch (e) {
-      console.log(`Invalid test case: ${casesGroupName}/${dirName}`);
-      return;
-    }
-
-    const { sentHtml, receivedHtml } = normalizedHtmls;
-
-    expect(receivedHtml.length).toBeGreaterThan(0);
-    expect(sentHtml.length).toBeGreaterThan(0);
-    expect(receivedHtml).toContain(sentHtml);
-  });
-};
+) =>
+  /**
+   * @param casesGroupName - name of the folder with cases
+   * @param failingCases - a list of cases that are failing and ignored. Pending to be fixed
+   */
+  (casesGroupName: string, failingCases: Array<string> = []) => (): void => {
+    const testsCasesPath = testsPath + "/" + casesGroupName;
+    const testCasesDirs = getTestCasesDirs(testsCasesPath).filter(
+      (dir) => !failingCases.includes(dir)
+    );
+
+    test.each(testCasesDirs)("Case %s", (dirName: string) => {
+      const testCasePath = testsCasesPath + "/" + dirName;
+      let normalizedHtmls;
+      try {
+        normalizedHtmls = getNormalizedHtml(testCasePath, vendor);
+      } catch (e) {
+        console.log(`Invalid test case: ${casesGroupName}/${dirName}`);
+        return;
+      }
+
+      const { sentHtml, receivedHtml } = normalizedHtmls;
+
+      expect(receivedHtml.length).toBeGreaterThan(0);
+      expect(sentHtml.length).toBeGreaterThan(0);
+      expect(receivedHtml).toContain(sentHtml);
+    });
+  };
 
 export const createDescribePlainTestCases = (testsPath: string) => (
   casesName: string,
-- 
GitLab