forked from AlaSQL/alasql
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest168.js
86 lines (72 loc) · 2.63 KB
/
test168.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
if(typeof exports === 'object') {
var assert = require("assert");
var alasql = require('../alasql.js');
} else {
__dirname = '.';
};
//if(typeof exports === 'object' && false) {
describe('Test 168a - read XLSX', function() {
it("1. Read XLSX file", function(done) {
var res = alasql('select * from xlsx("'+__dirname+'/test168.xlsx")',[],function(res){
assert(res.length == 6);
// console.log(res);
done();
});
});
it("2. Read XLSX file with Headers", function(done) {
var res = alasql('select column City from xlsx("'+__dirname+'/test168.xlsx",{headers:true})\
where Population > 10000000 order by City',[],function(res){
assert.deepEqual(res,["Mexico","Moscow"])
done();
});
});
it("3. Read XLSX file with Headers and range", function(done) {
var res = alasql('select column City from xlsx("'+__dirname+'/test168.xlsx",{headers:true, range:"A1:B3"})\
where Population > 10000000 order by City',[],function(res){
// console.log(res);
assert.deepEqual(res,["Moscow"])
done();
});
});
it("4. Read XLSX file with Headers and sheet", function(done) {
var res = alasql('select column City from xlsx("'+__dirname+'/test168.xlsx",{headers:true, sheetid: "USA", range:"A1:B6"})\
where Population > 10000000 order by City',[],function(res){
// console.log(res);
assert.deepEqual(res,["New York"])
done();
});
});
});
describe('Test 168b - read XLS', function() {
it("1. Read XLS file", function(done) {
var res = alasql('select * from xls("'+__dirname+'/test168.xls")',[],function(res){
assert(res.length == 6);
// console.log(res);
done();
});
});
it("2. Read XLS file with Headers", function(done) {
var res = alasql('select column City from xls("'+__dirname+'/test168.xls",{headers:true})\
where Population > 10000000 order by City',[],function(res){
assert.deepEqual(res,["Mexico","Moscow"])
done();
});
});
it("3. Read XLS file with Headers and range", function(done) {
var res = alasql('select column City from xls("'+__dirname+'/test168.xls",{headers:true, range:"A1:B3"})\
where Population > 10000000 order by City',[],function(res){
// console.log(res);
assert.deepEqual(res,["Moscow"])
done();
});
});
it("4. Read XLS file with Headers and sheet", function(done) {
var res = alasql('select column City from xls("'+__dirname+'/test168.xls",{headers:true, sheetid: "USA", range:"A1:B6"})\
where Population > 10000000 order by City',[],function(res){
// console.log(res);
assert.deepEqual(res,["New York"])
done();
});
});
});
//}