-
-
Notifications
You must be signed in to change notification settings - Fork 597
Support for Full Text Search Query #541
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1864,4 +1864,68 @@ describe('ParseQuery', () => { | |
}); | ||
}); | ||
|
||
it('full text search', () => { | ||
const query = new ParseQuery('Item'); | ||
query.fullText('size', 'small'); | ||
|
||
expect(query.toJSON()).toEqual({ | ||
where: { | ||
size: { | ||
$text: { | ||
$search: { | ||
$term: "small" | ||
} | ||
} | ||
} | ||
} | ||
}); | ||
}); | ||
|
||
it('full text search sort', () => { | ||
const query = new ParseQuery('Item'); | ||
query.fullText('size', 'medium'); | ||
query.ascending('$score'); | ||
query.select('$score'); | ||
|
||
expect(query.toJSON()).toEqual({ | ||
where: { | ||
size: { | ||
$text: { | ||
$search: { | ||
$term: "medium", | ||
} | ||
} | ||
} | ||
}, | ||
keys : "$score", | ||
order : "$score" | ||
}); | ||
}); | ||
|
||
it('full text search key required', (done) => { | ||
try { | ||
const query = new ParseQuery('Item'); | ||
query.fullText(); | ||
} catch (e) { | ||
done(); | ||
} | ||
}); | ||
|
||
it('full text search value required', (done) => { | ||
try { | ||
const query = new ParseQuery('Item'); | ||
query.fullText('key'); | ||
} catch (e) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here. |
||
done(); | ||
} | ||
}); | ||
|
||
it('full text search value must be string', (done) => { | ||
try { | ||
const query = new ParseQuery('Item'); | ||
query.fullText('key', []); | ||
} catch (e) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And here |
||
done(); | ||
} | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,15 +13,6 @@ var ParseSchema = require('../ParseSchema').default; | |
var ParsePromise = require('../ParsePromise').default; | ||
var CoreManager = require('../CoreManager'); | ||
|
||
function generateSaveMock(prefix) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unused? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah I copied the jest test from another file when I added schema support. Forgot I left those in 😅 |
||
return function(name, payload) { | ||
return ParsePromise.as({ | ||
name: name, | ||
url: prefix + name | ||
}); | ||
}; | ||
} | ||
|
||
var defaultController = CoreManager.getSchemaController(); | ||
|
||
describe('ParseSchema', () => { | ||
|
@@ -388,11 +379,9 @@ describe('SchemaController', () => { | |
beforeEach(() => { | ||
CoreManager.setSchemaController(defaultController); | ||
var request = function(method, path, data, options) { | ||
var name = path.substr(path.indexOf('/') + 1); | ||
return ParsePromise.as([]); | ||
}; | ||
var ajax = function(method, path, data, headers) { | ||
var name = path.substr(path.indexOf('/') + 1); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unused here as well? |
||
return ParsePromise.as([]); | ||
}; | ||
CoreManager.setRESTController({ request: request, ajax: ajax }); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than just try/catching I would use
expect(...).toThrow('my error...')
, that would be much more explicit in terms of that we are expecting and what we are expecting to receive as the error. You can see an example in the parse-server tests.