more tests

This commit is contained in:
zadam 2020-05-23 22:18:06 +02:00
parent a2e1fb35b8
commit 8ce2afff8a
2 changed files with 12 additions and 5 deletions

View File

@ -60,7 +60,7 @@ describe("Lexer expression", () => {
});
it("dot separated properties", () => {
expect(lexer(`# ~author.title = 'Hugh Howey' AND note.title = 'Silo'`).expressionTokens)
.toEqual(["#", "~author", ".", "title", "=", "hugh howey", "and", "note", ".", "title", "=", "silo"]);
expect(lexer(`# ~author.title = 'Hugh Howey' AND note.'book title' = 'Silo'`).expressionTokens)
.toEqual(["#", "~author", ".", "title", "=", "hugh howey", "and", "note", ".", "book title", "=", "silo"]);
});
});

View File

@ -106,6 +106,8 @@ describe("Search", () => {
});
it("numeric label comparison fallback to string comparison", async () => {
// dates should not be coerced into numbers which would then give wrong numbers
rootNote
.child(note("Europe")
.label('country', '', true)
@ -114,14 +116,19 @@ describe("Search", () => {
.child(note("Czech Republic")
.label('established', '1993-01-01'))
.child(note("Hungary")
.label('established', '..wrong..'))
.label('established', '1920-06-04'))
);
const parsingContext = new ParsingContext();
const searchResults = await searchService.findNotesWithQuery('#established < 1990', parsingContext);
let searchResults = await searchService.findNotesWithQuery('#established <= 1955-01-01', parsingContext);
expect(searchResults.length).toEqual(1);
expect(findNoteByTitle(searchResults, "Hungary")).toBeTruthy();
searchResults = await searchService.findNotesWithQuery('#established > 1955-01-01', parsingContext);
expect(searchResults.length).toEqual(2);
expect(findNoteByTitle(searchResults, "Austria")).toBeTruthy();
expect(findNoteByTitle(searchResults, "Czech Republic")).toBeTruthy();
});
it("logical or", async () => {
@ -389,7 +396,7 @@ describe("Search", () => {
await test("relationCount", "1", 1);
await test("relationCount", "2", 0);
})
});
});
/** @return {Note} */