Add new tests, cleanup

This commit is contained in:
Sebastian Mayr 2013-05-18 02:12:10 +02:00 committed by SheetJS
parent c29004c408
commit 3d7b9c03c3
10 changed files with 80 additions and 1 deletions

1
.gitignore vendored Normal file

@ -0,0 +1 @@
node_modules

@ -6,3 +6,6 @@ xlsx.js: $(DEPS)
.PHONY: clean
clean:
rm xlsx.js
test:
npm test

@ -21,7 +21,8 @@
"jasmine-node": "x"
},
"scripts": {
"test": "jasmine-node tests/"
"pretest": "git submodule init && git submodule update",
"test": "jasmine-node --verbose tests/"
},
"engines": { "node": ">=0.6" }
}

25
tests/Common.js Normal file

@ -0,0 +1,25 @@
var XLSX = require('../');
var tests = {
'should be able to open workbook': function (file) {
var xlsx = XLSX.readFile('tests/files/' + file);
expect(xlsx).toBeTruthy();
expect(xlsx).toEqual(jasmine.any(Object));
},
'should define all api properties correctly': function (file) {
var xlsx = XLSX.readFile('tests/files/' + file);
expect(xlsx.Workbook).toEqual(jasmine.any(Object));
expect(xlsx.Props).toBeDefined();
expect(xlsx.Deps).toBeDefined();
expect(xlsx.Sheets).toEqual(jasmine.any(Object));
expect(xlsx.SheetNames).toEqual(jasmine.any(Array));
expect(xlsx.Strings).toBeDefined();
expect(xlsx.Styles).toBeDefined();
}
};
module.exports = function (file) {
for (var key in tests) {
it(key, tests[key].bind(undefined, file));
}
};

8
tests/EncodedSpec.js Normal file

@ -0,0 +1,8 @@
var XLSX = require('../');
var testCommon = require('./Common.js');
var file = ישוב_נקודות_זיכוי.xlsx';
describe(file, function () {
testCommon(file);
});

9
tests/FormulaSpec.js Normal file

@ -0,0 +1,9 @@
var XLSX = require('../');
var testCommon = require('./Common.js');
var file = 'formula_stress_test.xlsx';
describe(file, function () {
// Opening the file currently crashes node
//testCommon(file);
});

8
tests/InterviewSpec.js Normal file

@ -0,0 +1,8 @@
var XLSX = require('../');
var testCommon = require('./Common.js');
var file = 'interview.xlsx';
describe(file, function () {
testCommon(file);
});

8
tests/IssueSpec.js Normal file

@ -0,0 +1,8 @@
var XLSX = require('../');
var testCommon = require('./Common.js');
var file = 'issue.xlsx';
describe(file, function () {
testCommon(file);
});

8
tests/MixedSpec.js Normal file

@ -0,0 +1,8 @@
var XLSX = require('../');
var testCommon = require('./Common.js');
var file = 'mixed_sheets.xlsx';
describe(file, function () {
testCommon(file);
});

8
tests/NamedRangesSpec.js Normal file

@ -0,0 +1,8 @@
var XLSX = require('../');
var testCommon = require('./Common.js');
var file = 'named_ranges_2011.xlsx';
describe(file, function () {
testCommon(file);
});