From 2cfd04a50e4c555f8377e56c38e2e99e87f1e0dd Mon Sep 17 00:00:00 2001 From: Mara Date: Sun, 9 Feb 2025 18:27:56 +0100 Subject: [PATCH] test: reformat --- tests/parse_csv.test.ts | 22 +++++++++++----------- tests/parse_file.test.ts | 9 ++++----- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/tests/parse_csv.test.ts b/tests/parse_csv.test.ts index 00e75f3..0c166c2 100644 --- a/tests/parse_csv.test.ts +++ b/tests/parse_csv.test.ts @@ -14,7 +14,7 @@ const mockTranslation = ((key: string, options?: any) => { }) as Translation; const columnNames: ColumnName = { term: "Term", synonyms: "Synonyms" }; describe("getThesaurus", () => { - it("should parse a valid CSV content", () => { + it("passing", () => { const csvContent = "Term,Synonyms\nword1,synonym1\nword2,synonym2"; const separator: Separator = ","; const thesaurus = getThesaurus(csvContent, separator, mockTranslation, columnNames); @@ -25,7 +25,7 @@ describe("getThesaurus", () => { }); }); describe("error handling", () => { - it("should throw an error for invalid column names", () => { + it("invalid column names", () => { const csvContent = "Invalid,Header\nword1,synonym1"; const separator: Separator = ","; expect(() => @@ -33,7 +33,7 @@ describe("error handling", () => { ).toThrow("Invalid column names"); }); - it("should throw an error for invalid separator", () => { + it("invalid separator", () => { const csvContent = "Term;Synonyms\nword1;synonym1"; const separator: Separator = ","; expect(() => @@ -41,7 +41,7 @@ describe("error handling", () => { ).toThrow("Invalid separator: ;"); }); - it("should throw an error for invalid header length", () => { + it("invalid header length", () => { const csvContent = "Term,Synonyms,Extra\nword1,synonym1"; const separator: Separator = ","; expect(() => @@ -49,7 +49,7 @@ describe("error handling", () => { ).toThrow("Invalid header length: 3"); }); - it("should throw an error for malformed line", () => { + it("malformed line", () => { const csvContent = "Term,Synonyms\nword1,synonym1\nword2"; const separator: Separator = ","; expect(() => @@ -58,7 +58,7 @@ describe("error handling", () => { }); }); describe("duplicate terms and synonyms", () => { - it("should not have duplicate terms in the result", () => { + it("terms", () => { const csvContent = "Term,Synonyms\nword1,synonym1\nword1,synonym2"; const separator: Separator = ","; const thesaurus = getThesaurus(csvContent, separator, mockTranslation, columnNames); @@ -66,7 +66,7 @@ describe("duplicate terms and synonyms", () => { expect(thesaurus["word1"]).toEqual(new Set(["synonym1", "synonym2"])); }); - it("should not have duplicate synonyms in the result", () => { + it("synonyms", () => { const csvContent = "Term,Synonyms\nword1,synonym1\nword1,synonym1"; const separator: Separator = ","; const thesaurus = getThesaurus(csvContent, separator, mockTranslation, columnNames); @@ -74,7 +74,7 @@ describe("duplicate terms and synonyms", () => { expect(thesaurus["word1"]).toEqual(new Set(["synonym1"])); }); - it("should not have duplicate terms and synonyms in the result", () => { + it("terms and synonyms", () => { const csvContent = "Term,Synonyms\nword1,synonym1\nword2,synonym1"; const separator: Separator = ","; const thesaurus = getThesaurus(csvContent, separator, mockTranslation, columnNames); @@ -84,7 +84,7 @@ describe("duplicate terms and synonyms", () => { }); }); describe("markdown table", () => { - it("header should be two even with markdown table", () => { + it("validate header", () => { const csvContent = "| Term | Synonyms |\n| --- | --- |\n| word1 | synonym1\nword2 | synonym2 |"; const separator: Separator = "|"; @@ -92,7 +92,7 @@ describe("markdown table", () => { const header = getHeader(fileContent, separator, mockTranslation); expect(header).toEqual(["Term", "Synonyms"]); }); - it("should parse a valid markdown table", () => { + it("passing", () => { const csvContent = "| Term | Synonyms |\n" + "| ----- | -------- |\n" + @@ -105,7 +105,7 @@ describe("markdown table", () => { word2: new Set(["synonym2"]), }); }); - it("should throw an error for too much columns in a markdown table", () => { + it("too much column", () => { const csvContent = "| Tag | Synonyme |Extra|\n" + "| ----- | -------- |--|\n" + diff --git a/tests/parse_file.test.ts b/tests/parse_file.test.ts index 2e9bc32..f1d8522 100644 --- a/tests/parse_file.test.ts +++ b/tests/parse_file.test.ts @@ -3,7 +3,7 @@ import type { Thesaurus } from "../src/interfaces"; import { getTags } from "../src/utils"; describe("should return tags", () => { - it("should return tags if synonyms are found in the content", () => { + it("passing test", () => { const content = "This content contains synonym1 and synonym4."; const thesaurus: Thesaurus = { tag1: new Set(["synonym1", "synonym2"]), @@ -14,7 +14,7 @@ describe("should return tags", () => { expect(result).toEqual(["tag1", "tag2"]); }); - it("should handle case insensitive matches", () => { + it("case insensitive", () => { const content = "This content contains Synonym1 and SYNONYM4."; const thesaurus: Thesaurus = { tag1: new Set(["synonym1", "synonym2"]), @@ -24,7 +24,7 @@ describe("should return tags", () => { const result = getTags(content, thesaurus); expect(result).toEqual(["tag1", "tag2"]); }); - it("should return the two tags related to the synonyms", () => { + it("synonym on the same tags", () => { const content = "This content contains synonym4."; const thesaurus: Thesaurus = { tag1: new Set(["synonym1", "synonym4"]), @@ -35,13 +35,12 @@ describe("should return tags", () => { expect(result).toEqual(["tag1", "tag2"]); }); - it("should return the tags if the synonyms is equal to the tag", () => { + it("synonym = tag", () => { const content = "This content contains tag1."; const thesaurus: Thesaurus = { tag1: new Set(["tag1", "synonym1"]), tag2: new Set(["synonym3", "synonym4"]), }; - const result = getTags(content, thesaurus); expect(result).toEqual(["tag1"]); });