mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-08-02 05:02:27 +08:00
test: port spec-es6 tests to vitest
This commit is contained in:
parent
325a3b6c83
commit
3f584af171
@ -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", () => {
|
describe("Lexing", () => {
|
||||||
it("simple label", () => {
|
it("simple label", () => {
|
||||||
@ -96,5 +96,3 @@ describe("error cases", () => {
|
|||||||
expect(() => attributeParser.lexAndParse("#")).toThrow(`Attribute name is empty, please fill the name.`);
|
expect(() => attributeParser.lexAndParse("#")).toThrow(`Attribute name is empty, please fill the name.`);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
execute();
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
|
import { expect, describe, it } from "vitest";
|
||||||
import sanitizeAttributeName from "../src/services/sanitize_attribute_name";
|
import sanitizeAttributeName from "../src/services/sanitize_attribute_name";
|
||||||
import { describe, it, execute, expect } from "./mini_test";
|
|
||||||
|
|
||||||
// fn value, expected value
|
// fn value, expected value
|
||||||
const testCases: [fnValue: string, expectedValue: string][] = [
|
const testCases: [fnValue: string, expectedValue: string][] = [
|
||||||
@ -31,9 +31,7 @@ describe("sanitizeAttributeName unit tests", () => {
|
|||||||
return it(`'${testCase[0]}' should return '${testCase[1]}'`, () => {
|
return it(`'${testCase[0]}' should return '${testCase[1]}'`, () => {
|
||||||
const [value, expected] = testCase;
|
const [value, expected] = testCase;
|
||||||
const actual = sanitizeAttributeName(value);
|
const actual = sanitizeAttributeName(value);
|
||||||
expect(actual).toEqual(expected);
|
expect(actual).toStrictEqual(expected);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
execute();
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
|
import { expect, describe, it } from "vitest";
|
||||||
import { formatDownloadTitle } from "../../src/services/utils.ts";
|
import { formatDownloadTitle } from "../../src/services/utils.ts";
|
||||||
import { describe, it, execute, expect } from "../mini_test.ts";
|
|
||||||
|
|
||||||
const testCases: [fnValue: Parameters<typeof formatDownloadTitle>, expectedValue: ReturnType<typeof formatDownloadTitle>][] = [
|
const testCases: [fnValue: Parameters<typeof formatDownloadTitle>, expectedValue: ReturnType<typeof formatDownloadTitle>][] = [
|
||||||
// empty fileName tests
|
// 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]}'`, () => {
|
return it(`With args '${JSON.stringify(testCase[0])}' it should return '${testCase[1]}'`, () => {
|
||||||
const [value, expected] = testCase;
|
const [value, expected] = testCase;
|
||||||
const actual = formatDownloadTitle(...value);
|
const actual = formatDownloadTitle(...value);
|
||||||
expect(actual).toEqual(expected);
|
expect(actual).toStrictEqual(expected);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
execute();
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user