mirror of
				https://github.com/zadam/trilium.git
				synced 2025-11-04 05:28:59 +01:00 
			
		
		
		
	chore(tests): move tests next to actual file
This commit is contained in:
		
							parent
							
								
									658317799d
								
							
						
					
					
						commit
						49246ee456
					
				@ -1,5 +1,5 @@
 | 
				
			|||||||
import { describe, it, expect } from "vitest";
 | 
					import { describe, it, expect } from "vitest";
 | 
				
			||||||
import attributeParser from "../src/public/app/services/attribute_parser.ts";
 | 
					import attributeParser from "./attribute_parser.js";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
describe("Lexing", () => {
 | 
					describe("Lexing", () => {
 | 
				
			||||||
@ -1,6 +1,6 @@
 | 
				
			|||||||
import { describe, it, expect, beforeEach, vi } from "vitest";
 | 
					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 () => {
 | 
					describe("data_dir.ts unit tests", async () => {
 | 
				
			||||||
    let getTriliumDataDir: typeof getTriliumDataDirType;
 | 
					    let getTriliumDataDir: typeof getTriliumDataDirType;
 | 
				
			||||||
@ -42,9 +42,9 @@ describe("data_dir.ts unit tests", async () => {
 | 
				
			|||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // import function to test now, after creating the mocks
 | 
					    // import function to test now, after creating the mocks
 | 
				
			||||||
    ({ getTriliumDataDir } = await import("../src/services/data_dir.ts"));
 | 
					    ({ getTriliumDataDir } = await import("./data_dir.js"));
 | 
				
			||||||
    ({ getPlatformAppDataDir } = await import("../src/services/data_dir.ts"));
 | 
					    ({ getPlatformAppDataDir } = await import("./data_dir.js"));
 | 
				
			||||||
    ({ getDataDirs } = await import("../src/services/data_dir.ts"));
 | 
					    ({ getDataDirs } = await import("./data_dir.js"));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // helper to reset call counts
 | 
					    // helper to reset call counts
 | 
				
			||||||
    const resetAllMocks = () => {
 | 
					    const resetAllMocks = () => {
 | 
				
			||||||
@ -1,5 +1,5 @@
 | 
				
			|||||||
import { expect, describe, it } from "vitest";
 | 
					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
 | 
					// fn value, expected value
 | 
				
			||||||
const testCases: [fnValue: string, expectedValue: string][] = [
 | 
					const testCases: [fnValue: string, expectedValue: string][] = [
 | 
				
			||||||
@ -1,6 +1,6 @@
 | 
				
			|||||||
import { describe, it, expect } from "vitest";
 | 
					import { describe, it, expect } from "vitest";
 | 
				
			||||||
import handleParens from "../../src/services/search/services/handle_parens.js";
 | 
					import handleParens from "./handle_parens.js";
 | 
				
			||||||
import type { TokenStructure } from "../../src/services/search/services/types.js";
 | 
					import type { TokenStructure } from "./types.js";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
describe("Parens handler", () => {
 | 
					describe("Parens handler", () => {
 | 
				
			||||||
    it("handles parens", () => {
 | 
					    it("handles parens", () => {
 | 
				
			||||||
@ -1,5 +1,5 @@
 | 
				
			|||||||
import { describe, it, expect } from "vitest";
 | 
					import { describe, it, expect } from "vitest";
 | 
				
			||||||
import lex from "../../src/services/search/services/lex.js";
 | 
					import lex from "./lex.js";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
describe("Lexer fulltext", () => {
 | 
					describe("Lexer fulltext", () => {
 | 
				
			||||||
    it("simple lexing", () => {
 | 
					    it("simple lexing", () => {
 | 
				
			||||||
@ -1,16 +1,16 @@
 | 
				
			|||||||
import { describe, it, expect } from "vitest";
 | 
					import { describe, it, expect } from "vitest";
 | 
				
			||||||
import AndExp from "../../src/services/search/expressions/and.js";
 | 
					import AndExp from "../../search/expressions/and.js";
 | 
				
			||||||
import AttributeExistsExp from "../../src/services/search/expressions/attribute_exists.js";
 | 
					import AttributeExistsExp from "../../search/expressions/attribute_exists.js";
 | 
				
			||||||
import type Expression from "../../src/services/search/expressions/expression.js";
 | 
					import type Expression from "../../search/expressions/expression.js";
 | 
				
			||||||
import LabelComparisonExp from "../../src/services/search/expressions/label_comparison.js";
 | 
					import LabelComparisonExp from "../../search/expressions/label_comparison.js";
 | 
				
			||||||
import NotExp from "../../src/services/search/expressions/not.js";
 | 
					import NotExp from "../../search/expressions/not.js";
 | 
				
			||||||
import NoteContentFulltextExp from "../../src/services/search/expressions/note_content_fulltext.js";
 | 
					import NoteContentFulltextExp from "../../search/expressions/note_content_fulltext.js";
 | 
				
			||||||
import NoteFlatTextExp from "../../src/services/search/expressions/note_flat_text.js";
 | 
					import NoteFlatTextExp from "../../search/expressions/note_flat_text.js";
 | 
				
			||||||
import OrExp from "../../src/services/search/expressions/or.js";
 | 
					import OrExp from "../../search/expressions/or.js";
 | 
				
			||||||
import OrderByAndLimitExp from "../../src/services/search/expressions/order_by_and_limit.js";
 | 
					import OrderByAndLimitExp from "../../search/expressions/order_by_and_limit.js";
 | 
				
			||||||
import PropertyComparisonExp from "../../src/services/search/expressions/property_comparison.js";
 | 
					import PropertyComparisonExp from "../../search/expressions/property_comparison.js";
 | 
				
			||||||
import SearchContext from "../../src/services/search/search_context.js";
 | 
					import SearchContext from "../../search/search_context.js";
 | 
				
			||||||
import { default as parseInternal, type ParseOpts } from "../../src/services/search/services/parse.js";
 | 
					import { default as parseInternal, type ParseOpts } from "./parse.js";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
describe("Parser", () => {
 | 
					describe("Parser", () => {
 | 
				
			||||||
    it("fulltext parser without content", () => {
 | 
					    it("fulltext parser without content", () => {
 | 
				
			||||||
@ -1,5 +1,5 @@
 | 
				
			|||||||
import { expect, describe, it } from "vitest";
 | 
					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>][] = [
 | 
					const testCases: [fnValue: Parameters<typeof formatDownloadTitle>, expectedValue: ReturnType<typeof formatDownloadTitle>][] = [
 | 
				
			||||||
    // empty fileName tests
 | 
					    // empty fileName tests
 | 
				
			||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user