Skip to content

Build your personal knowledge base with Trilium Notes

chore(tests): move tests next to actual file

Panagiotis Papadopoulos49246ee456db
diff --git a/spec-es6/attribute_parser.spec.ts b/src/public/app/services/attribute_parser.spec.ts
similarity index 98%
rename from spec-es6/attribute_parser.spec.ts
rename to src/public/app/services/attribute_parser.spec.ts
index 25892ec75b..d8dcf09d57 100644
--- a/spec-es6/attribute_parser.spec.ts
+++ b/src/public/app/services/attribute_parser.spec.ts
@@ -1,5 +1,5 @@
import { describe, it, expect } from "vitest";
-import attributeParser from "../src/public/app/services/attribute_parser.ts";
+import attributeParser from "./attribute_parser.js";
describe("Lexing", () => {
diff --git a/spec-es6/data_dir.spec.ts b/src/services/data_dir.spec.ts
similarity index 98%
rename from spec-es6/data_dir.spec.ts
rename to src/services/data_dir.spec.ts
index ded078cb8e..8192b80594 100644
--- a/spec-es6/data_dir.spec.ts
+++ b/src/services/data_dir.spec.ts
@@ -1,6 +1,6 @@
import { describe, it, expect, beforeEach, vi } from "vitest";
-import type { getTriliumDataDir as getTriliumDataDirType, getDataDirs as getDataDirsType, getPlatformAppDataDir as getPlatformAppDataDirType } from "../src/services/data_dir";
+import type { getTriliumDataDir as getTriliumDataDirType, getDataDirs as getDataDirsType, getPlatformAppDataDir as getPlatformAppDataDirType } from "./data_dir.js";
describe("data_dir.ts unit tests", async () => {
let getTriliumDataDir: typeof getTriliumDataDirType;
@@ -42,9 +42,9 @@ describe("data_dir.ts unit tests", async () => {
});
// import function to test now, after creating the mocks
- ({ getTriliumDataDir } = await import("../src/services/data_dir.ts"));
- ({ getPlatformAppDataDir } = await import("../src/services/data_dir.ts"));
- ({ getDataDirs } = await import("../src/services/data_dir.ts"));
+ ({ getTriliumDataDir } = await import("./data_dir.js"));
+ ({ getPlatformAppDataDir } = await import("./data_dir.js"));
+ ({ getDataDirs } = await import("./data_dir.js"));
// helper to reset call counts
const resetAllMocks = () => {
diff --git a/spec-es6/sanitize_attribute_name.spec.ts b/src/services/sanitize_attribute_name.spec.ts
similarity index 92%
rename from spec-es6/sanitize_attribute_name.spec.ts
rename to src/services/sanitize_attribute_name.spec.ts
index 73cb5303db..dffee7ae8d 100644
--- a/spec-es6/sanitize_attribute_name.spec.ts
+++ b/src/services/sanitize_attribute_name.spec.ts
@@ -1,5 +1,5 @@
import { expect, describe, it } from "vitest";
-import sanitizeAttributeName from "../src/services/sanitize_attribute_name";
+import sanitizeAttributeName from "./sanitize_attribute_name.js";
// fn value, expected value
const testCases: [fnValue: string, expectedValue: string][] = [
diff --git a/spec/search/parens.spec.ts b/src/services/search/services/handle_parens.spec.ts
similarity index 74%
rename from spec/search/parens.spec.ts
rename to src/services/search/services/handle_parens.spec.ts
index 2cfae9e6e8..be495a90c1 100644
--- a/spec/search/parens.spec.ts
+++ b/src/services/search/services/handle_parens.spec.ts
@@ -1,6 +1,6 @@
import { describe, it, expect } from "vitest";
-import handleParens from "../../src/services/search/services/handle_parens.js";
-import type { TokenStructure } from "../../src/services/search/services/types.js";
+import handleParens from "./handle_parens.js";
+import type { TokenStructure } from "./types.js";
describe("Parens handler", () => {
it("handles parens", () => {
diff --git a/spec/search/lexer.spec.ts b/src/services/search/services/lex.spec.ts
similarity index 99%
rename from spec/search/lexer.spec.ts
rename to src/services/search/services/lex.spec.ts
index 9f4a57482a..06680af12a 100644
--- a/spec/search/lexer.spec.ts
+++ b/src/services/search/services/lex.spec.ts
@@ -1,5 +1,5 @@
import { describe, it, expect } from "vitest";
-import lex from "../../src/services/search/services/lex.js";
+import lex from "./lex.js";
describe("Lexer fulltext", () => {
it("simple lexing", () => {
diff --git a/spec/search/parser.spec.ts b/src/services/search/services/parse.spec.ts
similarity index 92%
rename from spec/search/parser.spec.ts
rename to src/services/search/services/parse.spec.ts
index 244fe62d2f..6bde8756a9 100644
--- a/spec/search/parser.spec.ts
+++ b/src/services/search/services/parse.spec.ts
@@ -1,16 +1,16 @@
import { describe, it, expect } from "vitest";
-import AndExp from "../../src/services/search/expressions/and.js";
-import AttributeExistsExp from "../../src/services/search/expressions/attribute_exists.js";
-import type Expression from "../../src/services/search/expressions/expression.js";
-import LabelComparisonExp from "../../src/services/search/expressions/label_comparison.js";
-import NotExp from "../../src/services/search/expressions/not.js";
-import NoteContentFulltextExp from "../../src/services/search/expressions/note_content_fulltext.js";
-import NoteFlatTextExp from "../../src/services/search/expressions/note_flat_text.js";
-import OrExp from "../../src/services/search/expressions/or.js";
-import OrderByAndLimitExp from "../../src/services/search/expressions/order_by_and_limit.js";
-import PropertyComparisonExp from "../../src/services/search/expressions/property_comparison.js";
-import SearchContext from "../../src/services/search/search_context.js";
-import { default as parseInternal, type ParseOpts } from "../../src/services/search/services/parse.js";
+import AndExp from "../../search/expressions/and.js";
+import AttributeExistsExp from "../../search/expressions/attribute_exists.js";
+import type Expression from "../../search/expressions/expression.js";
+import LabelComparisonExp from "../../search/expressions/label_comparison.js";
+import NotExp from "../../search/expressions/not.js";
+import NoteContentFulltextExp from "../../search/expressions/note_content_fulltext.js";
+import NoteFlatTextExp from "../../search/expressions/note_flat_text.js";
+import OrExp from "../../search/expressions/or.js";
+import OrderByAndLimitExp from "../../search/expressions/order_by_and_limit.js";
+import PropertyComparisonExp from "../../search/expressions/property_comparison.js";
+import SearchContext from "../../search/search_context.js";
+import { default as parseInternal, type ParseOpts } from "./parse.js";
describe("Parser", () => {
it("fulltext parser without content", () => {
diff --git a/spec-es6/utils/formatDownloadTitle.spec.ts b/src/services/utils.formatDownloadTitle.spec.ts
similarity index 96%
rename from spec-es6/utils/formatDownloadTitle.spec.ts
rename to src/services/utils.formatDownloadTitle.spec.ts
index d0c2636468..0cc259e161 100644
--- a/spec-es6/utils/formatDownloadTitle.spec.ts
+++ b/src/services/utils.formatDownloadTitle.spec.ts
@@ -1,5 +1,5 @@
import { expect, describe, it } from "vitest";
-import { formatDownloadTitle } from "../../src/services/utils.ts";
+import { formatDownloadTitle } from "./utils.js";
const testCases: [fnValue: Parameters<typeof formatDownloadTitle>, expectedValue: ReturnType<typeof formatDownloadTitle>][] = [
// empty fileName tests