| 
									
										
										
										
											2020-06-03 16:24:41 +02:00
										 |  |  | const ParsingContext = require("../../src/services/search/parsing_context.js"); | 
					
						
							| 
									
										
										
										
											2020-07-21 00:01:07 +02:00
										 |  |  | const parse = require('../../src/services/search/services/parse.js'); | 
					
						
							| 
									
										
										
										
											2020-05-20 00:03:33 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-22 22:52:15 +02:00
										 |  |  | function tokens(toks, cur = 0) { | 
					
						
							|  |  |  |     return toks.map(arg => { | 
					
						
							| 
									
										
										
										
											2020-07-19 23:19:45 +02:00
										 |  |  |         if (Array.isArray(arg)) { | 
					
						
							| 
									
										
										
										
											2020-07-22 22:52:15 +02:00
										 |  |  |             return tokens(arg, cur); | 
					
						
							| 
									
										
										
										
											2020-07-19 23:19:45 +02:00
										 |  |  |         } | 
					
						
							|  |  |  |         else { | 
					
						
							| 
									
										
										
										
											2020-07-22 22:52:15 +02:00
										 |  |  |             cur += arg.length; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-19 23:19:45 +02:00
										 |  |  |             return { | 
					
						
							|  |  |  |                 token: arg, | 
					
						
							| 
									
										
										
										
											2020-07-22 22:52:15 +02:00
										 |  |  |                 inQuotes: false, | 
					
						
							|  |  |  |                 startIndex: cur - arg.length, | 
					
						
							|  |  |  |                 endIndex: cur - 1 | 
					
						
							| 
									
										
										
										
											2020-07-19 23:19:45 +02:00
										 |  |  |             }; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-20 00:03:33 +02:00
										 |  |  | describe("Parser", () => { | 
					
						
							|  |  |  |     it("fulltext parser without content", () => { | 
					
						
							| 
									
										
										
										
											2020-07-21 00:01:07 +02:00
										 |  |  |         const rootExp = parse({ | 
					
						
							| 
									
										
										
										
											2020-07-22 22:52:15 +02:00
										 |  |  |             fulltextTokens: tokens(["hello", "hi"]), | 
					
						
							| 
									
										
										
										
											2020-05-21 11:18:15 +02:00
										 |  |  |             expressionTokens: [], | 
					
						
							| 
									
										
										
										
											2020-05-21 14:05:56 +02:00
										 |  |  |             parsingContext: new ParsingContext({includeNoteContent: false}) | 
					
						
							| 
									
										
										
										
											2020-05-21 11:18:15 +02:00
										 |  |  |         }); | 
					
						
							| 
									
										
										
										
											2020-05-20 00:03:33 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-08-20 00:15:08 +02:00
										 |  |  |         expect(rootExp.constructor.name).toEqual("AndExp"); | 
					
						
							|  |  |  |         expect(rootExp.subExpressions[0].constructor.name).toEqual("NoteCacheFlatTextExp"); | 
					
						
							|  |  |  |         expect(rootExp.subExpressions[0].tokens).toEqual(["hello", "hi"]); | 
					
						
							| 
									
										
										
										
											2020-05-20 23:20:39 +02:00
										 |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     it("fulltext parser with content", () => { | 
					
						
							| 
									
										
										
										
											2020-07-21 00:01:07 +02:00
										 |  |  |         const rootExp = parse({ | 
					
						
							| 
									
										
										
										
											2020-07-22 22:52:15 +02:00
										 |  |  |             fulltextTokens: tokens(["hello", "hi"]), | 
					
						
							| 
									
										
										
										
											2020-05-21 11:18:15 +02:00
										 |  |  |             expressionTokens: [], | 
					
						
							| 
									
										
										
										
											2020-05-21 14:05:56 +02:00
										 |  |  |             parsingContext: new ParsingContext({includeNoteContent: true}) | 
					
						
							| 
									
										
										
										
											2020-05-21 11:18:15 +02:00
										 |  |  |         }); | 
					
						
							| 
									
										
										
										
											2020-05-20 23:20:39 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-08-20 00:15:08 +02:00
										 |  |  |         expect(rootExp.constructor.name).toEqual("AndExp"); | 
					
						
							|  |  |  |         expect(rootExp.subExpressions[0].constructor.name).toEqual("OrExp"); | 
					
						
							|  |  |  |         expect(rootExp.subExpressions[1].constructor.name).toEqual("PropertyComparisonExp"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         const subs = rootExp.subExpressions[0].subExpressions; | 
					
						
							| 
									
										
										
										
											2020-07-19 15:25:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-08-19 23:00:51 +02:00
										 |  |  |         expect(subs[0].constructor.name).toEqual("NoteCacheFlatTextExp"); | 
					
						
							| 
									
										
										
										
											2020-07-19 15:25:24 +02:00
										 |  |  |         expect(subs[0].tokens).toEqual(["hello", "hi"]); | 
					
						
							| 
									
										
										
										
											2020-05-20 23:20:39 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-19 15:25:24 +02:00
										 |  |  |         expect(subs[1].constructor.name).toEqual("NoteContentProtectedFulltextExp"); | 
					
						
							|  |  |  |         expect(subs[1].tokens).toEqual(["hello", "hi"]); | 
					
						
							| 
									
										
										
										
											2020-05-20 23:20:39 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-19 15:25:24 +02:00
										 |  |  |         expect(subs[2].constructor.name).toEqual("NoteContentUnprotectedFulltextExp"); | 
					
						
							|  |  |  |         expect(subs[2].tokens).toEqual(["hello", "hi"]); | 
					
						
							| 
									
										
										
										
											2020-05-20 23:20:39 +02:00
										 |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     it("simple label comparison", () => { | 
					
						
							| 
									
										
										
										
											2020-07-21 00:01:07 +02:00
										 |  |  |         const rootExp = parse({ | 
					
						
							| 
									
										
										
										
											2020-05-21 11:18:15 +02:00
										 |  |  |             fulltextTokens: [], | 
					
						
							| 
									
										
										
										
											2020-07-22 22:52:15 +02:00
										 |  |  |             expressionTokens: tokens(["#mylabel", "=", "text"]), | 
					
						
							| 
									
										
										
										
											2020-05-21 14:05:56 +02:00
										 |  |  |             parsingContext: new ParsingContext() | 
					
						
							| 
									
										
										
										
											2020-05-21 11:18:15 +02:00
										 |  |  |         }); | 
					
						
							| 
									
										
										
										
											2020-05-20 23:20:39 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-23 10:25:22 +02:00
										 |  |  |         expect(rootExp.constructor.name).toEqual("LabelComparisonExp"); | 
					
						
							| 
									
										
										
										
											2020-05-20 23:20:39 +02:00
										 |  |  |         expect(rootExp.attributeType).toEqual("label"); | 
					
						
							|  |  |  |         expect(rootExp.attributeName).toEqual("mylabel"); | 
					
						
							|  |  |  |         expect(rootExp.comparator).toBeTruthy(); | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-19 15:25:24 +02:00
										 |  |  |     it("simple attribute negation", () => { | 
					
						
							| 
									
										
										
										
											2020-07-21 00:01:07 +02:00
										 |  |  |         let rootExp = parse({ | 
					
						
							| 
									
										
										
										
											2020-07-19 15:25:24 +02:00
										 |  |  |             fulltextTokens: [], | 
					
						
							| 
									
										
										
										
											2020-07-22 22:52:15 +02:00
										 |  |  |             expressionTokens: tokens(["#!mylabel"]), | 
					
						
							| 
									
										
										
										
											2020-07-19 15:25:24 +02:00
										 |  |  |             parsingContext: new ParsingContext() | 
					
						
							|  |  |  |         }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         expect(rootExp.constructor.name).toEqual("NotExp"); | 
					
						
							|  |  |  |         expect(rootExp.subExpression.constructor.name).toEqual("AttributeExistsExp"); | 
					
						
							|  |  |  |         expect(rootExp.subExpression.attributeType).toEqual("label"); | 
					
						
							|  |  |  |         expect(rootExp.subExpression.attributeName).toEqual("mylabel"); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-21 00:01:07 +02:00
										 |  |  |         rootExp = parse({ | 
					
						
							| 
									
										
										
										
											2020-07-19 15:25:24 +02:00
										 |  |  |             fulltextTokens: [], | 
					
						
							| 
									
										
										
										
											2020-07-22 22:52:15 +02:00
										 |  |  |             expressionTokens: tokens(["~!myrelation"]), | 
					
						
							| 
									
										
										
										
											2020-07-19 15:25:24 +02:00
										 |  |  |             parsingContext: new ParsingContext() | 
					
						
							|  |  |  |         }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         expect(rootExp.constructor.name).toEqual("NotExp"); | 
					
						
							|  |  |  |         expect(rootExp.subExpression.constructor.name).toEqual("AttributeExistsExp"); | 
					
						
							|  |  |  |         expect(rootExp.subExpression.attributeType).toEqual("relation"); | 
					
						
							|  |  |  |         expect(rootExp.subExpression.attributeName).toEqual("myrelation"); | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-20 23:20:39 +02:00
										 |  |  |     it("simple label AND", () => { | 
					
						
							| 
									
										
										
										
											2020-07-21 00:01:07 +02:00
										 |  |  |         const rootExp = parse({ | 
					
						
							| 
									
										
										
										
											2020-05-21 11:18:15 +02:00
										 |  |  |             fulltextTokens: [], | 
					
						
							| 
									
										
										
										
											2020-07-22 22:52:15 +02:00
										 |  |  |             expressionTokens: tokens(["#first", "=", "text", "and", "#second", "=", "text"]), | 
					
						
							| 
									
										
										
										
											2020-05-21 11:46:01 +02:00
										 |  |  |             parsingContext: new ParsingContext(true) | 
					
						
							| 
									
										
										
										
											2020-05-21 11:18:15 +02:00
										 |  |  |         }); | 
					
						
							| 
									
										
										
										
											2020-05-20 23:20:39 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |         expect(rootExp.constructor.name).toEqual("AndExp"); | 
					
						
							|  |  |  |         const [firstSub, secondSub] = rootExp.subExpressions; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-23 10:25:22 +02:00
										 |  |  |         expect(firstSub.constructor.name).toEqual("LabelComparisonExp"); | 
					
						
							| 
									
										
										
										
											2020-05-20 23:20:39 +02:00
										 |  |  |         expect(firstSub.attributeName).toEqual("first"); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-23 10:25:22 +02:00
										 |  |  |         expect(secondSub.constructor.name).toEqual("LabelComparisonExp"); | 
					
						
							| 
									
										
										
										
											2020-05-20 23:20:39 +02:00
										 |  |  |         expect(secondSub.attributeName).toEqual("second"); | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     it("simple label AND without explicit AND", () => { | 
					
						
							| 
									
										
										
										
											2020-07-21 00:01:07 +02:00
										 |  |  |         const rootExp = parse({ | 
					
						
							| 
									
										
										
										
											2020-05-21 11:18:15 +02:00
										 |  |  |             fulltextTokens: [], | 
					
						
							| 
									
										
										
										
											2020-07-22 22:52:15 +02:00
										 |  |  |             expressionTokens: tokens(["#first", "=", "text", "#second", "=", "text"]), | 
					
						
							| 
									
										
										
										
											2020-05-21 14:05:56 +02:00
										 |  |  |             parsingContext: new ParsingContext() | 
					
						
							| 
									
										
										
										
											2020-05-21 11:18:15 +02:00
										 |  |  |         }); | 
					
						
							| 
									
										
										
										
											2020-05-20 23:20:39 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |         expect(rootExp.constructor.name).toEqual("AndExp"); | 
					
						
							|  |  |  |         const [firstSub, secondSub] = rootExp.subExpressions; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-23 10:25:22 +02:00
										 |  |  |         expect(firstSub.constructor.name).toEqual("LabelComparisonExp"); | 
					
						
							| 
									
										
										
										
											2020-05-20 23:20:39 +02:00
										 |  |  |         expect(firstSub.attributeName).toEqual("first"); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-23 10:25:22 +02:00
										 |  |  |         expect(secondSub.constructor.name).toEqual("LabelComparisonExp"); | 
					
						
							| 
									
										
										
										
											2020-05-20 23:20:39 +02:00
										 |  |  |         expect(secondSub.attributeName).toEqual("second"); | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     it("simple label OR", () => { | 
					
						
							| 
									
										
										
										
											2020-07-21 00:01:07 +02:00
										 |  |  |         const rootExp = parse({ | 
					
						
							| 
									
										
										
										
											2020-05-21 11:18:15 +02:00
										 |  |  |             fulltextTokens: [], | 
					
						
							| 
									
										
										
										
											2020-07-22 22:52:15 +02:00
										 |  |  |             expressionTokens: tokens(["#first", "=", "text", "or", "#second", "=", "text"]), | 
					
						
							| 
									
										
										
										
											2020-05-21 14:05:56 +02:00
										 |  |  |             parsingContext: new ParsingContext() | 
					
						
							| 
									
										
										
										
											2020-05-21 11:18:15 +02:00
										 |  |  |         }); | 
					
						
							| 
									
										
										
										
											2020-05-20 23:20:39 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |         expect(rootExp.constructor.name).toEqual("OrExp"); | 
					
						
							|  |  |  |         const [firstSub, secondSub] = rootExp.subExpressions; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-23 10:25:22 +02:00
										 |  |  |         expect(firstSub.constructor.name).toEqual("LabelComparisonExp"); | 
					
						
							| 
									
										
										
										
											2020-05-20 23:20:39 +02:00
										 |  |  |         expect(firstSub.attributeName).toEqual("first"); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-23 10:25:22 +02:00
										 |  |  |         expect(secondSub.constructor.name).toEqual("LabelComparisonExp"); | 
					
						
							| 
									
										
										
										
											2020-05-20 23:20:39 +02:00
										 |  |  |         expect(secondSub.attributeName).toEqual("second"); | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     it("fulltext and simple label", () => { | 
					
						
							| 
									
										
										
										
											2020-07-21 00:01:07 +02:00
										 |  |  |         const rootExp = parse({ | 
					
						
							| 
									
										
										
										
											2020-07-22 22:52:15 +02:00
										 |  |  |             fulltextTokens: tokens(["hello"]), | 
					
						
							|  |  |  |             expressionTokens: tokens(["#mylabel", "=", "text"]), | 
					
						
							| 
									
										
										
										
											2020-05-21 14:05:56 +02:00
										 |  |  |             parsingContext: new ParsingContext() | 
					
						
							| 
									
										
										
										
											2020-05-21 11:18:15 +02:00
										 |  |  |         }); | 
					
						
							| 
									
										
										
										
											2020-05-20 23:20:39 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |         expect(rootExp.constructor.name).toEqual("AndExp"); | 
					
						
							|  |  |  |         const [firstSub, secondSub] = rootExp.subExpressions; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-08-20 00:15:08 +02:00
										 |  |  |         expect(firstSub.constructor.name).toEqual("AndExp"); | 
					
						
							|  |  |  |         expect(firstSub.subExpressions[0].constructor.name).toEqual("NoteCacheFlatTextExp"); | 
					
						
							|  |  |  |         expect(firstSub.subExpressions[0].tokens).toEqual(["hello"]); | 
					
						
							| 
									
										
										
										
											2020-05-20 23:20:39 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-23 10:25:22 +02:00
										 |  |  |         expect(secondSub.constructor.name).toEqual("LabelComparisonExp"); | 
					
						
							| 
									
										
										
										
											2020-05-20 23:20:39 +02:00
										 |  |  |         expect(secondSub.attributeName).toEqual("mylabel"); | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     it("label sub-expression", () => { | 
					
						
							| 
									
										
										
										
											2020-07-21 00:01:07 +02:00
										 |  |  |         const rootExp = parse({ | 
					
						
							| 
									
										
										
										
											2020-05-21 11:18:15 +02:00
										 |  |  |             fulltextTokens: [], | 
					
						
							| 
									
										
										
										
											2020-07-22 22:52:15 +02:00
										 |  |  |             expressionTokens: tokens(["#first", "=", "text", "or", ["#second", "=", "text", "and", "#third", "=", "text"]]), | 
					
						
							| 
									
										
										
										
											2020-05-21 14:05:56 +02:00
										 |  |  |             parsingContext: new ParsingContext() | 
					
						
							| 
									
										
										
										
											2020-05-21 11:18:15 +02:00
										 |  |  |         }); | 
					
						
							| 
									
										
										
										
											2020-05-20 23:20:39 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |         expect(rootExp.constructor.name).toEqual("OrExp"); | 
					
						
							|  |  |  |         const [firstSub, secondSub] = rootExp.subExpressions; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-23 10:25:22 +02:00
										 |  |  |         expect(firstSub.constructor.name).toEqual("LabelComparisonExp"); | 
					
						
							| 
									
										
										
										
											2020-05-20 23:20:39 +02:00
										 |  |  |         expect(firstSub.attributeName).toEqual("first"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         expect(secondSub.constructor.name).toEqual("AndExp"); | 
					
						
							|  |  |  |         const [firstSubSub, secondSubSub] = secondSub.subExpressions; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-23 10:25:22 +02:00
										 |  |  |         expect(firstSubSub.constructor.name).toEqual("LabelComparisonExp"); | 
					
						
							| 
									
										
										
										
											2020-05-20 23:20:39 +02:00
										 |  |  |         expect(firstSubSub.attributeName).toEqual("second"); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-23 10:25:22 +02:00
										 |  |  |         expect(secondSubSub.constructor.name).toEqual("LabelComparisonExp"); | 
					
						
							| 
									
										
										
										
											2020-05-20 23:20:39 +02:00
										 |  |  |         expect(secondSubSub.attributeName).toEqual("third"); | 
					
						
							| 
									
										
										
										
											2020-05-20 00:03:33 +02:00
										 |  |  |     }); | 
					
						
							|  |  |  | }); | 
					
						
							| 
									
										
										
										
											2020-07-19 23:19:45 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-21 00:01:07 +02:00
										 |  |  | describe("Invalid expressions", () => { | 
					
						
							| 
									
										
										
										
											2020-07-19 23:19:45 +02:00
										 |  |  |     it("incomplete comparison", () => { | 
					
						
							|  |  |  |         const parsingContext = new ParsingContext(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-21 00:01:07 +02:00
										 |  |  |         parse({ | 
					
						
							| 
									
										
										
										
											2020-07-19 23:19:45 +02:00
										 |  |  |             fulltextTokens: [], | 
					
						
							| 
									
										
										
										
											2020-07-22 22:52:15 +02:00
										 |  |  |             expressionTokens: tokens(["#first", "="]), | 
					
						
							| 
									
										
										
										
											2020-07-19 23:19:45 +02:00
										 |  |  |             parsingContext | 
					
						
							|  |  |  |         }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         expect(parsingContext.error).toEqual('Misplaced or incomplete expression "="') | 
					
						
							|  |  |  |     }); | 
					
						
							| 
									
										
										
										
											2020-07-20 23:27:30 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     it("comparison between labels is impossible", () => { | 
					
						
							|  |  |  |         let parsingContext = new ParsingContext(); | 
					
						
							| 
									
										
										
										
											2020-07-22 22:52:15 +02:00
										 |  |  |         parsingContext.originalQuery = "#first = #second"; | 
					
						
							| 
									
										
										
										
											2020-07-20 23:27:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-21 00:01:07 +02:00
										 |  |  |         parse({ | 
					
						
							| 
									
										
										
										
											2020-07-20 23:27:30 +02:00
										 |  |  |             fulltextTokens: [], | 
					
						
							| 
									
										
										
										
											2020-07-22 22:52:15 +02:00
										 |  |  |             expressionTokens: tokens(["#first", "=", "#second"]), | 
					
						
							| 
									
										
										
										
											2020-07-20 23:27:30 +02:00
										 |  |  |             parsingContext | 
					
						
							|  |  |  |         }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-22 22:52:15 +02:00
										 |  |  |         expect(parsingContext.error).toEqual(`Error near token "#second" in "#first = #second", it's possible to compare with constant only.`); | 
					
						
							| 
									
										
										
										
											2020-07-20 23:27:30 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |         parsingContext = new ParsingContext(); | 
					
						
							| 
									
										
										
										
											2020-07-22 22:52:15 +02:00
										 |  |  |         parsingContext.originalQuery = "#first = note.relations.second"; | 
					
						
							| 
									
										
										
										
											2020-07-20 23:27:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-21 00:01:07 +02:00
										 |  |  |         parse({ | 
					
						
							| 
									
										
										
										
											2020-07-20 23:27:30 +02:00
										 |  |  |             fulltextTokens: [], | 
					
						
							| 
									
										
										
										
											2020-07-22 22:52:15 +02:00
										 |  |  |             expressionTokens: tokens(["#first", "=", "note", ".", "relations", "second"]), | 
					
						
							| 
									
										
										
										
											2020-07-20 23:27:30 +02:00
										 |  |  |             parsingContext | 
					
						
							|  |  |  |         }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-22 22:52:15 +02:00
										 |  |  |         expect(parsingContext.error).toEqual(`Error near token "note" in "#first = note.relations.s...", it's possible to compare with constant only.`); | 
					
						
							| 
									
										
										
										
											2020-07-20 23:27:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-21 00:01:07 +02:00
										 |  |  |         const rootExp = parse({ | 
					
						
							| 
									
										
										
										
											2020-07-20 23:27:30 +02:00
										 |  |  |             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(); | 
					
						
							|  |  |  |     }); | 
					
						
							| 
									
										
										
										
											2020-07-19 23:19:45 +02:00
										 |  |  | }); |