mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 09:58:32 +02:00
more tests
This commit is contained in:
parent
ae772288e2
commit
bb03a8714a
@ -188,7 +188,9 @@ describe("Search", () => {
|
||||
rootNote
|
||||
.child(note("Europe")
|
||||
.child(note("Austria"))
|
||||
.child(note("Czech Republic")))
|
||||
.child(note("Czech Republic")
|
||||
.child(note("Prague")))
|
||||
)
|
||||
.child(note("Asia")
|
||||
.child(note('Taiwan')));
|
||||
|
||||
@ -202,13 +204,19 @@ describe("Search", () => {
|
||||
searchResults = await searchService.findNotesWithQuery('# note.parents.title = Asia', parsingContext);
|
||||
expect(searchResults.length).toEqual(1);
|
||||
expect(findNoteByTitle(searchResults, "Taiwan")).toBeTruthy();
|
||||
|
||||
searchResults = await searchService.findNotesWithQuery('# note.parents.parents.title = Europe', parsingContext);
|
||||
expect(searchResults.length).toEqual(1);
|
||||
expect(findNoteByTitle(searchResults, "Prague")).toBeTruthy();
|
||||
});
|
||||
|
||||
it("filter by note's child", async () => {
|
||||
rootNote
|
||||
.child(note("Europe")
|
||||
.child(note("Austria"))
|
||||
.child(note("Czech Republic")))
|
||||
.child(note("Austria")
|
||||
.child(note("Vienna")))
|
||||
.child(note("Czech Republic")
|
||||
.child(note("Prague"))))
|
||||
.child(note("Oceania")
|
||||
.child(note('Australia')));
|
||||
|
||||
@ -222,6 +230,10 @@ describe("Search", () => {
|
||||
searchResults = await searchService.findNotesWithQuery('# note.children.title =* Aust AND note.children.title *= republic', parsingContext);
|
||||
expect(searchResults.length).toEqual(1);
|
||||
expect(findNoteByTitle(searchResults, "Europe")).toBeTruthy();
|
||||
|
||||
searchResults = await searchService.findNotesWithQuery('# note.children.children.title = Prague', parsingContext);
|
||||
expect(searchResults.length).toEqual(1);
|
||||
expect(findNoteByTitle(searchResults, "Europe")).toBeTruthy();
|
||||
});
|
||||
|
||||
it("filter by relation's note properties using short syntax", async () => {
|
||||
@ -269,6 +281,37 @@ describe("Search", () => {
|
||||
expect(searchResults.length).toEqual(1);
|
||||
expect(findNoteByTitle(searchResults, "Czech Republic")).toBeTruthy();
|
||||
});
|
||||
|
||||
it("filter by multiple level relation", async () => {
|
||||
const austria = note("Austria");
|
||||
const slovakia = note("Slovakia");
|
||||
const italy = note("Italy");
|
||||
const ukraine = note("Ukraine");
|
||||
|
||||
rootNote
|
||||
.child(note("Europe")
|
||||
.child(austria
|
||||
.relation('neighbor', italy.note)
|
||||
.relation('neighbor', slovakia.note))
|
||||
.child(note("Czech Republic")
|
||||
.relation('neighbor', austria.note)
|
||||
.relation('neighbor', slovakia.note))
|
||||
.child(slovakia
|
||||
.relation('neighbor', ukraine.note))
|
||||
.child(ukraine)
|
||||
);
|
||||
|
||||
const parsingContext = new ParsingContext();
|
||||
|
||||
let searchResults = await searchService.findNotesWithQuery('# note.relations.neighbor.relations.neighbor.title = Italy', parsingContext);
|
||||
expect(searchResults.length).toEqual(1);
|
||||
expect(findNoteByTitle(searchResults, "Czech Republic")).toBeTruthy();
|
||||
|
||||
searchResults = await searchService.findNotesWithQuery('# note.relations.neighbor.relations.neighbor.title = Ukraine', parsingContext);
|
||||
expect(searchResults.length).toEqual(2);
|
||||
expect(findNoteByTitle(searchResults, "Czech Republic")).toBeTruthy();
|
||||
expect(findNoteByTitle(searchResults, "Austria")).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
||||
/** @return {Note} */
|
||||
|
Loading…
x
Reference in New Issue
Block a user