mirror of
https://github.com/zadam/trilium.git
synced 2025-12-21 23:59:59 +01:00
detect attempts to compare between labels (only with constants is possible)
This commit is contained in:
@@ -188,4 +188,41 @@ describe("Invalid tokens", () => {
|
||||
|
||||
expect(parsingContext.error).toEqual('Misplaced or incomplete expression "="')
|
||||
});
|
||||
|
||||
it("comparison between labels is impossible", () => {
|
||||
let parsingContext = new ParsingContext();
|
||||
|
||||
parser({
|
||||
fulltextTokens: [],
|
||||
expressionTokens: tokens("#first", "=", "#second"),
|
||||
parsingContext
|
||||
});
|
||||
|
||||
expect(parsingContext.error).toEqual(`Error near token "#second", it's possible to compare with constant only.`);
|
||||
|
||||
parsingContext = new ParsingContext();
|
||||
|
||||
parser({
|
||||
fulltextTokens: [],
|
||||
expressionTokens: tokens("#first", "=", "note", ".", "relations", "second"),
|
||||
parsingContext
|
||||
});
|
||||
|
||||
expect(parsingContext.error).toEqual(`Error near token "note", it's possible to compare with constant only.`);
|
||||
|
||||
const rootExp = parser({
|
||||
fulltextTokens: [],
|
||||
expressionTokens: [
|
||||
{ token: "#first", inQuotes: false },
|
||||
{ token: "=", inQuotes: false },
|
||||
{ token: "#second", inQuotes: true },
|
||||
],
|
||||
parsingContext: new ParsingContext()
|
||||
});
|
||||
|
||||
expect(rootExp.constructor.name).toEqual("LabelComparisonExp");
|
||||
expect(rootExp.attributeType).toEqual("label");
|
||||
expect(rootExp.attributeName).toEqual("first");
|
||||
expect(rootExp.comparator).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user