From 0d1281cc9433ec0e72dad41a7c6f4a367de61701 Mon Sep 17 00:00:00 2001 From: Pieter Sheth-Voss Date: Tue, 11 Aug 2015 17:23:56 -0400 Subject: [PATCH] Added test files --- tests/test-acid.js | 20 ++ tests/test-csv.js | 43 +++ tests/test-min.js | 10 + tests/test-open.js | 8 + tests/test-style.js | 694 ++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 775 insertions(+) create mode 100644 tests/test-acid.js create mode 100644 tests/test-csv.js create mode 100644 tests/test-min.js create mode 100644 tests/test-open.js create mode 100644 tests/test-style.js diff --git a/tests/test-acid.js b/tests/test-acid.js new file mode 100644 index 0000000..4ac7f48 --- /dev/null +++ b/tests/test-acid.js @@ -0,0 +1,20 @@ +var X = require('./'); +var opts = { cellNF: true, + type: 'file', + cellHTML: true, + cellFormula: true, + cellStyles: false, + cellDates: false, + sheetStubs: false, + sheetRows: 0, + bookDeps: false, + bookSheets: false, + bookProps: false, + bookFiles: false, + bookVBA: false, + WTF: false } +; +var FILENAME = './test_files/number_format_entities-2.xlsx'; +wb = X.read(X.write(X.readFile(FILENAME,opts), {type:"buffer", bookType:'xlsx'}), {WTF:true, cellNF: true}) + +X.writeFile(wb,'/tmp/wb3.xlsx'); diff --git a/tests/test-csv.js b/tests/test-csv.js new file mode 100644 index 0000000..44f862f --- /dev/null +++ b/tests/test-csv.js @@ -0,0 +1,43 @@ +var argv = require('minimist')(process.argv.slice(2)); + +var XLSX = require('./'); +var fs = require('fs') +var INFILE = './test_files/pivot_table_test.xlsm'; +var TESTFILE = './test_files/pivot_table_test.xlsm.'; +//var INFILE = './test_files/formula_stress_test.xlsb'; +//var TESTFILE = './test_files/formula_stress_test.xls.'; +var INFILE ='./test_files/apachepoi_Tables.xlsx'; +var TESTFILE='./test_files/apachepoi_Tables.xlsx.'; +var INFILE = './test_files/apachepoi_45540_classic_Footer.xlsx'; +var TESTFILE = './test_files/apachepoi_45540_classic_Footer.xlsx.'; +var SHEET=argv.p || 0; + +function stripbom(x) { return x.replace(/^\ufeff/,""); } +function fixcsv(x) { return stripbom(x).replace(/\t/g,",").replace(/#{255}/g,"").replace(/"/g,"").replace(/[\n\r]+/g,"\n").replace(/\n*$/,""); } + + +wb = XLSX.readFile(INFILE, {cellNF: true}); + +//XLSX.writeFile(wb, '/tmp/test-csv.xlsx'); +//var wb = XLSX.readFile('/tmp/test-csv.xlsx', {cellNF: true}); + +wb = XLSX.read(XLSX.write(wb, {type:"buffer", bookType:'xlsx'}), {cellNF: true}) + + +var csv = fixcsv(XLSX.utils.make_csv(wb.Sheets[wb.SheetNames[SHEET]])) +console.log('==================') +console.log( csv); +console.log('------------') +var exp = fixcsv(fs.readFileSync(TESTFILE + SHEET+ '.csv','utf8')) +console.log(exp) +console.log('.............') +console.log(csv==exp); + +console.log(csv.length, exp.length) +if (argv.d) { +for (var i=0; i