-
Notifications
You must be signed in to change notification settings - Fork 664
/
Copy pathtest300.js
56 lines (49 loc) · 1.29 KB
/
test300.js
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
54
55
56
if (typeof exports === 'object') {
var assert = require('assert');
var alasql = require('..');
} else {
__dirname = '.';
}
describe('Test 300 SEARCH', function () {
var catalog = {
Europe: {
fruits: [{fruit: 'Apple'}, {fruit: 'Peach'}],
},
Asia: {
fruit: 'Pineapple',
},
Africa: {
fruit: 'Banana',
},
};
it('1. Search fruits', function (done) {
var res = alasql('SEARCH Europe FROM ?', [catalog]);
assert.deepEqual(res, [
{
fruits: [{fruit: 'Apple'}, {fruit: 'Peach'}],
},
]);
done();
});
it('2. Search fruits 2', function (done) {
var res = alasql('SEARCH /fruits/ FROM ?', [catalog]);
assert.deepEqual(res, [{fruit: 'Apple'}, {fruit: 'Peach'}]);
var res = alasql('SEARCH /fruits/fruit FROM ?', [catalog]);
assert.deepEqual(res, ['Apple', 'Peach']);
done();
});
it('3. Search fruits', function (done) {
var res = alasql('SEARCH /fruits/WHERE(fruit="Apple") FROM ?', [catalog]);
assert.deepEqual(res, [{fruit: 'Apple'}]);
var res = alasql('SEARCH ///WHERE(fruit="Apple") FROM ?', [catalog]);
assert.deepEqual(res, [{fruit: 'Apple'}]);
done();
});
if (false) {
it('4. Search fruits', function (done) {
var res = alasql('SEARCH /// WHERE(fruit="Apple") FROM ?', [catalog]);
assert.deepEqual(res, [{fruit: 'Apple'}]);
done();
});
}
});