From 3f584af17119cb07dba828d8a8ad625e4ec45c38 Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Sun, 12 Jan 2025 23:42:46 +0100 Subject: [PATCH] test: port spec-es6 tests to vitest --- spec-es6/attribute_parser.spec.ts | 6 ++---- spec-es6/sanitize_attribute_name.spec.ts | 8 +++----- spec-es6/utils/formatDownloadTitle.spec.ts | 8 +++----- 3 files changed, 8 insertions(+), 14 deletions(-) diff --git a/spec-es6/attribute_parser.spec.ts b/spec-es6/attribute_parser.spec.ts index c7932b378..72dcda6b4 100644 --- a/spec-es6/attribute_parser.spec.ts +++ b/spec-es6/attribute_parser.spec.ts @@ -1,6 +1,6 @@ -import * as attributeParser from "../src/public/app/services/attribute_parser.js"; +import { describe, it, expect } from "vitest"; +import attributeParser from "../src/public/app/services/attribute_parser.ts"; -import { describe, it, expect, execute } from "./mini_test.js"; describe("Lexing", () => { it("simple label", () => { @@ -96,5 +96,3 @@ describe("error cases", () => { expect(() => attributeParser.lexAndParse("#")).toThrow(`Attribute name is empty, please fill the name.`); }); }); - -execute(); diff --git a/spec-es6/sanitize_attribute_name.spec.ts b/spec-es6/sanitize_attribute_name.spec.ts index 9399d1edb..73cb5303d 100644 --- a/spec-es6/sanitize_attribute_name.spec.ts +++ b/spec-es6/sanitize_attribute_name.spec.ts @@ -1,5 +1,5 @@ +import { expect, describe, it } from "vitest"; import sanitizeAttributeName from "../src/services/sanitize_attribute_name"; -import { describe, it, execute, expect } from "./mini_test"; // fn value, expected value const testCases: [fnValue: string, expectedValue: string][] = [ @@ -31,9 +31,7 @@ describe("sanitizeAttributeName unit tests", () => { return it(`'${testCase[0]}' should return '${testCase[1]}'`, () => { const [value, expected] = testCase; const actual = sanitizeAttributeName(value); - expect(actual).toEqual(expected); + expect(actual).toStrictEqual(expected); }); }); -}); - -execute(); +}); \ No newline at end of file diff --git a/spec-es6/utils/formatDownloadTitle.spec.ts b/spec-es6/utils/formatDownloadTitle.spec.ts index 053f79fb7..d0c263646 100644 --- a/spec-es6/utils/formatDownloadTitle.spec.ts +++ b/spec-es6/utils/formatDownloadTitle.spec.ts @@ -1,5 +1,5 @@ +import { expect, describe, it } from "vitest"; import { formatDownloadTitle } from "../../src/services/utils.ts"; -import { describe, it, execute, expect } from "../mini_test.ts"; const testCases: [fnValue: Parameters, expectedValue: ReturnType][] = [ // empty fileName tests @@ -55,9 +55,7 @@ describe("utils/formatDownloadTitle unit tests", () => { return it(`With args '${JSON.stringify(testCase[0])}' it should return '${testCase[1]}'`, () => { const [value, expected] = testCase; const actual = formatDownloadTitle(...value); - expect(actual).toEqual(expected); + expect(actual).toStrictEqual(expected); }); }); -}); - -execute(); +}); \ No newline at end of file