mirror of
https://github.com/TriliumNext/Notes.git
synced 2026-05-06 20:29:12 -05:00
lexer impl WIP + test
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
const lexerSpec = require('../src/services/search/lexer.js');
|
||||
|
||||
describe("Lexer", function() {
|
||||
it("simple lexing", () => {
|
||||
expect(lexerSpec("hello world").fulltextTokens)
|
||||
.toEqual(["hello", "world"]);
|
||||
});
|
||||
|
||||
it("use quotes to keep words together", () => {
|
||||
expect(lexerSpec("'hello world' my friend").fulltextTokens)
|
||||
.toEqual(["hello world", "my", "friend"]);
|
||||
|
||||
expect(lexerSpec('"hello world" my friend').fulltextTokens)
|
||||
.toEqual(["hello world", "my", "friend"]);
|
||||
|
||||
expect(lexerSpec('`hello world` my friend').fulltextTokens)
|
||||
.toEqual(["hello world", "my", "friend"]);
|
||||
});
|
||||
|
||||
it("you can use different quotes and other special characters inside quotes", () => {
|
||||
expect(lexerSpec("'I can use \" or ` or #@=*' without problem").fulltextTokens)
|
||||
.toEqual(["I can use \" or ` or #@=*", "without", "problem"]);
|
||||
});
|
||||
|
||||
it("if quote is not ended then it's just one long token", () => {
|
||||
expect(lexerSpec("'unfinished quote").fulltextTokens)
|
||||
.toEqual(["unfinished quote"]);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"spec_dir": "spec",
|
||||
"spec_files": [
|
||||
"**/*[sS]pec.js"
|
||||
],
|
||||
"helpers": [
|
||||
"helpers/**/*.js"
|
||||
],
|
||||
"stopSpecOnExpectationFailure": false,
|
||||
"random": true
|
||||
}
|
||||
Reference in New Issue
Block a user