-
Notifications
You must be signed in to change notification settings - Fork 121
Expand file tree
/
Copy pathsearch.js
More file actions
53 lines (49 loc) · 1.78 KB
/
search.js
File metadata and controls
53 lines (49 loc) · 1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
'use strict';
describe.skip('App Searching', function() {
describe('#AV.SearchSortBuilder', function() {
it('should build sort string.', function() {
var builder = new AV.SearchSortBuilder();
var s = builder
.ascending('a')
.descending('b', 'max')
.whereNear('location', new AV.GeoPoint(10, 20), {
order: 'desc',
})
.build();
expect(s).to.be(
'[{"a":{"order":"asc","mode":"avg","missing":"_last"}},{"b":{"order":"desc","mode":"max","missing":"_last"}},{"_geo_distance":{"order":"desc","mode":"avg","unit":"km","location":{"lat":10,"lon":20}}}]'
);
});
});
describe('#AV.SearchQuery', function() {
it('should find something.', function() {
var q = new AV.SearchQuery('GameScore');
q.queryString('*');
return q.find().then(function(results) {
expect(q.hits()).to.be.greaterThan(0);
expect(results[0]).to.be.an(AV.Object);
});
});
it('should sort by score.', function() {
var q = new AV.SearchQuery('GameScore');
q.descending('score');
q.queryString('*');
return q.find().then(function(results) {
expect(q.hits()).to.be.greaterThan(0);
console.dir(results);
expect(results[0].appURL).to.be.ok();
expect(results[0].get('score') >= results[1].get('score')).to.be.ok();
});
});
it('should sort by score with sort builder.', function() {
var q = new AV.SearchQuery('GameScore');
q.sortBy(new AV.SearchSortBuilder().descending('score'));
q.queryString('*');
return q.find().then(function(results) {
expect(q.hits()).to.be.greaterThan(0);
console.dir(results);
expect(results[0].get('score') >= results[1].get('score')).to.be.ok();
});
});
});
});