-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
2 changed files
with
36 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -118,6 +118,35 @@ describe('Search query syntax parser', function () { | |
parsedAfterStringifySearchQuery.should.be.eql(parsedSearchQuery); | ||
}); | ||
|
||
it('should return a tokenized string without empty text terms', function () { | ||
var searchQuery = "fancy pyjama wear ''"; | ||
var options = { tokenize: true }; | ||
var parsedSearchQuery = searchquery.parse(searchQuery, options); | ||
|
||
parsedSearchQuery.should.be.an.Object; | ||
parsedSearchQuery.should.have.property('text', ['fancy', 'pyjama', 'wear']); | ||
|
||
var parsedAfterStringifySearchQuery = searchquery.parse(searchquery.stringify(parsedSearchQuery, options), options); | ||
parsedAfterStringifySearchQuery.offsets = undefined; | ||
parsedSearchQuery.offsets = undefined; | ||
parsedAfterStringifySearchQuery.should.be.eql(parsedSearchQuery); | ||
}); | ||
|
||
it('should return a simple string without empty text terms', function () { | ||
var searchQuery = "key:value fancy pyjama wear ''"; | ||
var options = { keywords: ['key'] }; | ||
var parsedSearchQuery = searchquery.parse(searchQuery, options); | ||
|
||
parsedSearchQuery.should.be.an.Object; | ||
parsedSearchQuery.should.have.property('text', 'fancy pyjama wear'); | ||
parsedSearchQuery.should.have.property('key', 'value'); | ||
|
||
var parsedAfterStringifySearchQuery = searchquery.parse(searchquery.stringify(parsedSearchQuery, options), options); | ||
parsedAfterStringifySearchQuery.offsets = undefined; | ||
parsedSearchQuery.offsets = undefined; | ||
parsedAfterStringifySearchQuery.should.be.eql(parsedSearchQuery); | ||
}); | ||
|
||
it('should parse a single keyword with no text', function () { | ||
var searchQuery = 'from:[email protected]'; | ||
var options = {keywords: ['from']}; | ||
|