forked from AlaSQL/alasql
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest157.js
58 lines (47 loc) · 1.68 KB
/
test157.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
57
58
if(typeof exports === 'object') {
var assert = require("assert");
var alasql = require('..');
} else {
__dirname = '.';
};
//if(typeof exports != 'object') {
describe('Test 157 - json()', function() {
it("1. Load text data from file async", function(done){
alasql('select * from json("test157.json")',[],function(res){
// console.log(13,res);
assert.deepEqual(res, [{a:1},{a:2}]);
done();
});
});
it("2. Load text file", function(done){
alasql('select column * from txt("test157.txt") where [0] like "M%" order by [0]',[],function(res){
// console.log(res);
assert.deepEqual(res, ["Madrid","Milano","Minsk","Moscow"]);
done();
});
});
it("3. Load tab-separated file", function(done){
alasql('select column * from tab("test157a.tab",{headers:false}) where [1] > 100 order by [0]',[],function(res){
assert.deepEqual(res, ["Astana","Tokyo","Vitebsk"]);
done();
});
});
it("4. Load tab-separated file", function(done){
alasql('select column city from tab("test157b.tab", {headers:true}) where population > 100 order by city',[],function(res){
assert.deepEqual(res, ["Astana","Tokyo","Vitebsk"]);
done();
});
});
it("5. Load CSV-file", function(done){
alasql('select column * from csv("test157a.csv",{headers:false}) where [1] > 100 order by [0]',[],function(res){
assert.deepEqual(res, ["Astana","Tokyo","Vitebsk"]);
done();
});
});
it("6. Load CSV-file with headers", function(done){
alasql('select column city from csv("test157b.csv",{headers:true}) where population > 100 order by city',[],function(res){
assert.deepEqual(res, ["Astana","Tokyo","Vitebsk"]);
done();
});
});
});