test: port spec tests to vitest

This commit is contained in:
Panagiotis Papadopoulos 2025-01-13 00:32:58 +01:00
parent 6be7109ce3
commit 33274ada65
10 changed files with 22 additions and 11 deletions

View File

@ -1,3 +1,5 @@
describe("Notes", () => { import { describe, it } from "vitest";
describe.todo("Notes", () => {
it("zzz", () => {}); it("zzz", () => {});
}); });

View File

@ -1,3 +1,4 @@
import { describe, it, expect } from "vitest";
import lex from "../../src/services/search/services/lex.js"; import lex from "../../src/services/search/services/lex.js";
describe("Lexer fulltext", () => { describe("Lexer fulltext", () => {

View File

@ -1,3 +1,4 @@
import { describe, it, expect } from "vitest";
import handleParens from "../../src/services/search/services/handle_parens.js"; import handleParens from "../../src/services/search/services/handle_parens.js";
import type { TokenStructure } from "../../src/services/search/services/types.js"; import type { TokenStructure } from "../../src/services/search/services/types.js";

View File

@ -1,3 +1,4 @@
import { describe, it, expect } from "vitest";
import AndExp from "../../src/services/search/expressions/and.js"; import AndExp from "../../src/services/search/expressions/and.js";
import AttributeExistsExp from "../../src/services/search/expressions/attribute_exists.js"; import AttributeExistsExp from "../../src/services/search/expressions/attribute_exists.js";
import type Expression from "../../src/services/search/expressions/expression.js"; import type Expression from "../../src/services/search/expressions/expression.js";

View File

@ -1,3 +1,4 @@
import { describe, it, expect, beforeEach, } from "vitest";
import searchService from "../../src/services/search/services/search.js"; import searchService from "../../src/services/search/services/search.js";
import BNote from "../../src/becca/entities/bnote.js"; import BNote from "../../src/becca/entities/bnote.js";
import BBranch from "../../src/becca/entities/bbranch.js"; import BBranch from "../../src/becca/entities/bbranch.js";
@ -21,7 +22,7 @@ describe("Search", () => {
}); });
}); });
xit("simple path match", () => { it.skip("simple path match", () => {
rootNote.child(becca_mocking.note("Europe").child(becca_mocking.note("Austria"))); rootNote.child(becca_mocking.note("Europe").child(becca_mocking.note("Austria")));
const searchContext = new SearchContext(); const searchContext = new SearchContext();
@ -31,7 +32,7 @@ describe("Search", () => {
expect(becca_mocking.findNoteByTitle(searchResults, "Austria")).toBeTruthy(); expect(becca_mocking.findNoteByTitle(searchResults, "Austria")).toBeTruthy();
}); });
xit("normal search looks also at attributes", () => { it.skip("normal search looks also at attributes", () => {
const austria = becca_mocking.note("Austria"); const austria = becca_mocking.note("Austria");
const vienna = becca_mocking.note("Vienna"); const vienna = becca_mocking.note("Vienna");
@ -49,7 +50,7 @@ describe("Search", () => {
expect(becca_mocking.findNoteByTitle(searchResults, "Vienna")).toBeTruthy(); expect(becca_mocking.findNoteByTitle(searchResults, "Vienna")).toBeTruthy();
}); });
xit("normal search looks also at type and mime", () => { it.skip("normal search looks also at type and mime", () => {
rootNote.child(becca_mocking.note("Effective Java", { type: "book", mime: "" })).child(becca_mocking.note("Hello World.java", { type: "code", mime: "text/x-java" })); rootNote.child(becca_mocking.note("Effective Java", { type: "book", mime: "" })).child(becca_mocking.note("Hello World.java", { type: "code", mime: "text/x-java" }));
const searchContext = new SearchContext(); const searchContext = new SearchContext();
@ -68,7 +69,7 @@ describe("Search", () => {
expect(searchResults.length).toEqual(2); expect(searchResults.length).toEqual(2);
}); });
xit("only end leafs are results", () => { it.skip("only end leafs are results", () => {
rootNote.child(becca_mocking.note("Europe").child(becca_mocking.note("Austria"))); rootNote.child(becca_mocking.note("Europe").child(becca_mocking.note("Austria")));
const searchContext = new SearchContext(); const searchContext = new SearchContext();
@ -78,7 +79,7 @@ describe("Search", () => {
expect(becca_mocking.findNoteByTitle(searchResults, "Europe")).toBeTruthy(); expect(becca_mocking.findNoteByTitle(searchResults, "Europe")).toBeTruthy();
}); });
xit("only end leafs are results", () => { it.skip("only end leafs are results", () => {
rootNote.child(becca_mocking.note("Europe").child(becca_mocking.note("Austria").label("capital", "Vienna"))); rootNote.child(becca_mocking.note("Europe").child(becca_mocking.note("Austria").label("capital", "Vienna")));
const searchContext = new SearchContext(); const searchContext = new SearchContext();
@ -133,7 +134,7 @@ describe("Search", () => {
expect(becca_mocking.findNoteByTitle(searchResults, "Czech Republic")).toBeTruthy(); expect(becca_mocking.findNoteByTitle(searchResults, "Czech Republic")).toBeTruthy();
}); });
xit("inherited label comparison", () => { it.skip("inherited label comparison", () => {
rootNote.child(becca_mocking.note("Europe").label("country", "", true).child(becca_mocking.note("Austria")).child(becca_mocking.note("Czech Republic"))); rootNote.child(becca_mocking.note("Europe").label("country", "", true).child(becca_mocking.note("Austria")).child(becca_mocking.note("Czech Republic")));
const searchContext = new SearchContext(); const searchContext = new SearchContext();
@ -549,7 +550,7 @@ describe("Search", () => {
expect(becca.notes[searchResults[0].noteId].title).toEqual("Europe"); expect(becca.notes[searchResults[0].noteId].title).toEqual("Europe");
}); });
xit("test note.text *=* something", () => { it.skip("test note.text *=* something", () => {
const italy = becca_mocking.note("Italy").label("capital", "Rome"); const italy = becca_mocking.note("Italy").label("capital", "Rome");
const slovakia = becca_mocking.note("Slovakia").label("capital", "Bratislava"); const slovakia = becca_mocking.note("Slovakia").label("capital", "Bratislava");
@ -562,7 +563,7 @@ describe("Search", () => {
expect(becca.notes[searchResults[0].noteId].title).toEqual("Slovakia"); expect(becca.notes[searchResults[0].noteId].title).toEqual("Slovakia");
}); });
xit("test that fulltext does not match archived notes", () => { it.skip("test that fulltext does not match archived notes", () => {
const italy = becca_mocking.note("Italy").label("capital", "Rome"); const italy = becca_mocking.note("Italy").label("capital", "Rome");
const slovakia = becca_mocking.note("Slovakia").label("capital", "Bratislava"); const slovakia = becca_mocking.note("Slovakia").label("capital", "Bratislava");

View File

@ -1,3 +1,4 @@
import { describe, it, expect, beforeEach } from "vitest";
import becca_mocking from "./becca_mocking.js"; import becca_mocking from "./becca_mocking.js";
import ValueExtractor from "../../src/services/search/value_extractor.js"; import ValueExtractor from "../../src/services/search/value_extractor.js";
import becca from "../../src/becca/becca.js"; import becca from "../../src/becca/becca.js";

View File

@ -1,3 +1,4 @@
import { describe, it, expect } from "vitest";
import { trimIndentation } from "./utils.js"; import { trimIndentation } from "./utils.js";
describe("Utils", () => { describe("Utils", () => {

View File

@ -1,3 +1,4 @@
import { describe, it, expect } from "vitest";
import markdownExportService from "./md.js"; import markdownExportService from "./md.js";
import { trimIndentation } from "../../../spec/support/utils.js"; import { trimIndentation } from "../../../spec/support/utils.js";

View File

@ -1,3 +1,4 @@
import { describe, it, expect } from "vitest";
import { trimIndentation } from "../../../spec/support/utils.js"; import { trimIndentation } from "../../../spec/support/utils.js";
import markdownService from "./markdown.js"; import markdownService from "./markdown.js";

View File

@ -1,3 +1,4 @@
import { describe, it, expect } from "vitest";
import { renderCode, type Result } from "./content_renderer.js"; import { renderCode, type Result } from "./content_renderer.js";
describe("content_renderer", () => { describe("content_renderer", () => {
@ -8,7 +9,7 @@ describe("content_renderer", () => {
content: " " content: " "
}; };
renderCode(emptyResult); renderCode(emptyResult);
expect(emptyResult.isEmpty).toBeTrue(); expect(emptyResult.isEmpty).toBeTruthy();
}); });
it("identifies unsupported content type", () => { it("identifies unsupported content type", () => {
@ -17,7 +18,7 @@ describe("content_renderer", () => {
content: Buffer.from("Hello world") content: Buffer.from("Hello world")
}; };
renderCode(emptyResult); renderCode(emptyResult);
expect(emptyResult.isEmpty).toBeTrue(); expect(emptyResult.isEmpty).toBeTruthy();
}); });
it("wraps code in <pre>", () => { it("wraps code in <pre>", () => {