mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 18:08:33 +02:00
test fixes
This commit is contained in:
parent
995f4f2582
commit
2b1383205b
@ -24,12 +24,13 @@ describe("Parser", () => {
|
|||||||
const rootExp = parse({
|
const rootExp = parse({
|
||||||
fulltextTokens: tokens(["hello", "hi"]),
|
fulltextTokens: tokens(["hello", "hi"]),
|
||||||
expressionTokens: [],
|
expressionTokens: [],
|
||||||
searchContext: new SearchContext({includeNoteContent: false})
|
searchContext: new SearchContext({includeNoteContent: false, excludeArchived: true})
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(rootExp.constructor.name).toEqual("AndExp");
|
expect(rootExp.constructor.name).toEqual("AndExp");
|
||||||
expect(rootExp.subExpressions[0].constructor.name).toEqual("NoteCacheFlatTextExp");
|
expect(rootExp.subExpressions[0].constructor.name).toEqual("PropertyComparisonExp");
|
||||||
expect(rootExp.subExpressions[0].tokens).toEqual(["hello", "hi"]);
|
expect(rootExp.subExpressions[1].constructor.name).toEqual("NoteCacheFlatTextExp");
|
||||||
|
expect(rootExp.subExpressions[1].tokens).toEqual(["hello", "hi"]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("fulltext parser with content", () => {
|
it("fulltext parser with content", () => {
|
||||||
@ -39,11 +40,9 @@ describe("Parser", () => {
|
|||||||
searchContext: new SearchContext({includeNoteContent: true})
|
searchContext: new SearchContext({includeNoteContent: true})
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(rootExp.constructor.name).toEqual("AndExp");
|
expect(rootExp.constructor.name).toEqual("OrExp");
|
||||||
expect(rootExp.subExpressions[0].constructor.name).toEqual("OrExp");
|
|
||||||
expect(rootExp.subExpressions[1].constructor.name).toEqual("PropertyComparisonExp");
|
|
||||||
|
|
||||||
const subs = rootExp.subExpressions[0].subExpressions;
|
const subs = rootExp.subExpressions;
|
||||||
|
|
||||||
expect(subs[0].constructor.name).toEqual("NoteCacheFlatTextExp");
|
expect(subs[0].constructor.name).toEqual("NoteCacheFlatTextExp");
|
||||||
expect(subs[0].tokens).toEqual(["hello", "hi"]);
|
expect(subs[0].tokens).toEqual(["hello", "hi"]);
|
||||||
@ -147,18 +146,20 @@ describe("Parser", () => {
|
|||||||
const rootExp = parse({
|
const rootExp = parse({
|
||||||
fulltextTokens: tokens(["hello"]),
|
fulltextTokens: tokens(["hello"]),
|
||||||
expressionTokens: tokens(["#mylabel", "=", "text"]),
|
expressionTokens: tokens(["#mylabel", "=", "text"]),
|
||||||
searchContext: new SearchContext()
|
searchContext: new SearchContext({excludeArchived: true})
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(rootExp.constructor.name).toEqual("AndExp");
|
expect(rootExp.constructor.name).toEqual("AndExp");
|
||||||
const [firstSub, secondSub] = rootExp.subExpressions;
|
const [firstSub, secondSub, thirdSub] = rootExp.subExpressions;
|
||||||
|
|
||||||
expect(firstSub.constructor.name).toEqual("AndExp");
|
expect(firstSub.constructor.name).toEqual("PropertyComparisonExp");
|
||||||
expect(firstSub.subExpressions[0].constructor.name).toEqual("NoteCacheFlatTextExp");
|
expect(firstSub.propertyName).toEqual('isArchived');
|
||||||
expect(firstSub.subExpressions[0].tokens).toEqual(["hello"]);
|
|
||||||
|
|
||||||
expect(secondSub.constructor.name).toEqual("LabelComparisonExp");
|
expect(secondSub.constructor.name).toEqual("NoteCacheFlatTextExp");
|
||||||
expect(secondSub.attributeName).toEqual("mylabel");
|
expect(secondSub.tokens).toEqual(["hello"]);
|
||||||
|
|
||||||
|
expect(thirdSub.constructor.name).toEqual("LabelComparisonExp");
|
||||||
|
expect(thirdSub.attributeName).toEqual("mylabel");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("label sub-expression", () => {
|
it("label sub-expression", () => {
|
||||||
@ -236,4 +237,16 @@ describe("Invalid expressions", () => {
|
|||||||
expect(rootExp.attributeName).toEqual("first");
|
expect(rootExp.attributeName).toEqual("first");
|
||||||
expect(rootExp.comparator).toBeTruthy();
|
expect(rootExp.comparator).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("searching by relation without note property", () => {
|
||||||
|
const searchContext = new SearchContext();
|
||||||
|
|
||||||
|
parse({
|
||||||
|
fulltextTokens: [],
|
||||||
|
expressionTokens: tokens(["~first", "=", "text", "-", "abc"]),
|
||||||
|
searchContext
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(searchContext.error).toEqual('Misplaced or incomplete expression "="')
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@ -601,7 +601,7 @@ describe("Search", () => {
|
|||||||
.child(note('Post Y')))
|
.child(note('Post Y')))
|
||||||
.child(note ('Reddit is bad'));
|
.child(note ('Reddit is bad'));
|
||||||
|
|
||||||
const searchContext = new SearchContext();
|
const searchContext = new SearchContext({excludeArchived: true});
|
||||||
|
|
||||||
let searchResults = searchService.findNotesWithQuery('reddit', searchContext);
|
let searchResults = searchService.findNotesWithQuery('reddit', searchContext);
|
||||||
expect(searchResults.length).toEqual(1);
|
expect(searchResults.length).toEqual(1);
|
||||||
|
@ -9,7 +9,6 @@ const SearchContext = require("../search_context.js");
|
|||||||
const noteCache = require('../../note_cache/note_cache.js');
|
const noteCache = require('../../note_cache/note_cache.js');
|
||||||
const noteCacheService = require('../../note_cache/note_cache_service.js');
|
const noteCacheService = require('../../note_cache/note_cache_service.js');
|
||||||
const hoistedNoteService = require('../../hoisted_note.js');
|
const hoistedNoteService = require('../../hoisted_note.js');
|
||||||
const repository = require('../../repository.js');
|
|
||||||
const utils = require('../../utils.js');
|
const utils = require('../../utils.js');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user