This repository has been archived by the owner on Aug 19, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5643068
commit ec5707d
Showing
8 changed files
with
172 additions
and
33 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
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
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
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 |
---|---|---|
@@ -0,0 +1,60 @@ | ||
const Lab = require('lab') | ||
const lab = exports.lab = Lab.script() | ||
const expect = require('code').expect | ||
const utils = require('../../lib/ops/utils.js') | ||
|
||
lab.describe('tsquery tests', () => { | ||
lab.test('empty string', done => { | ||
const query = utils.toTsQuery('') | ||
expect(query).to.equal(``) | ||
done() | ||
}) | ||
|
||
lab.test('single space', done => { | ||
const query = utils.toTsQuery(' ') | ||
expect(query).to.equal(``) | ||
done() | ||
}) | ||
|
||
lab.test('single phrase', done => { | ||
const query = utils.toTsQuery('test') | ||
expect(query).to.equal(`'test':*`) | ||
done() | ||
}) | ||
|
||
lab.test('multiple phrases', done => { | ||
const query = utils.toTsQuery('this is a test') | ||
expect(query).to.equal(`'this':* & 'is':* & 'a':* & 'test':*`) | ||
done() | ||
}) | ||
|
||
lab.test('multiple phrases with extra whitespace', done => { | ||
const query = utils.toTsQuery('this is a test') | ||
expect(query).to.equal(`'this':* & 'is':* & 'a':* & 'test':*`) | ||
done() | ||
}) | ||
|
||
lab.test('multiple phrases with in need of trim', done => { | ||
const query = utils.toTsQuery(' this is a test ') | ||
expect(query).to.equal(`'this':* & 'is':* & 'a':* & 'test':*`) | ||
done() | ||
}) | ||
|
||
lab.test('multiple phrases with quotes', done => { | ||
const query = utils.toTsQuery("it's got quotes") | ||
expect(query).to.equal(`'it''s':* & 'got':* & 'quotes':*`) | ||
done() | ||
}) | ||
|
||
lab.test('multiple phrases with backslash', done => { | ||
const query = utils.toTsQuery('yes\\no maybe') | ||
expect(query).to.equal(`'yes\\\\no':* & 'maybe':*`) | ||
done() | ||
}) | ||
|
||
lab.test('sql injection', done => { | ||
const query = utils.toTsQuery('Wonka\'); drop database authorization;') | ||
expect(query).to.equal(`'Wonka'');':* & 'drop':* & 'database':* & 'authorization;':*`) | ||
done() | ||
}) | ||
}) |
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