From c9d0aa140dd80f000df4d082bb8d27b72f12c584 Mon Sep 17 00:00:00 2001 From: Jani Hartikainen Date: Thu, 13 Apr 2017 10:08:46 +0300 Subject: [PATCH] Small Test and Doc Fixes --- Makefile | 1 + docbits/90_test.md | 15 ++++++++++++--- test.js | 8 ++++---- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 8b47937..3e99473 100644 --- a/Makefile +++ b/Makefile @@ -95,6 +95,7 @@ test mocha: test.js ## Run test suite mocha -R spec -t 20000 #* To run tests for one format, make test_ +#* To run the core test suite, make test_misc TESTFMT=$(patsubst %,test_%,$(FMT)) .PHONY: $(TESTFMT) $(TESTFMT): test_%: diff --git a/docbits/90_test.md b/docbits/90_test.md index 20506ee..668cf49 100644 --- a/docbits/90_test.md +++ b/docbits/90_test.md @@ -1,16 +1,19 @@ ## Testing +### Node + `make test` will run the node-based tests. By default it runs tests on files in every supported format. To test a specific file type, set `FMTS` to the format you want to test. Feature-specific tests are avaialble with `make test_misc` ```bash +$ make test_misc # run core tests $ make test # run full tests $ make test_xls # only use the XLS test files $ make test_xlsx # only use the XLSX test files $ make test_xlsb # only use the XLSB test files -$ make test_xml # only use the XLSB test files -$ make test_ods # only use the XLSB test files +$ make test_xml # only use the XML test files +$ make test_ods # only use the ODS test files ``` To enable all errors, set the environment variable `WTF=1`: @@ -27,8 +30,14 @@ $ make lint # JSHint and JSCS checks $ make flow # make lint + Flow checking ``` -The core in-browser tests are available at `tests/test.html` within this repo. +### Browser + +The core in-browser tests are available at `tests/index.html` within this repo. Start a local server and navigate to that directory to run the tests. +`make ctestserv` will start a server on port 8000. + +`make ctest` will generate the browser fixtures. To add more files, edit the +`tests/fixtures.lst` file and add the paths. To run the full in-browser tests, clone the repo for [oss.sheetjs.com](https://github.com/SheetJS/SheetJS.github.io) and replace diff --git a/test.js b/test.js index afca66d..3302a6d 100644 --- a/test.js +++ b/test.js @@ -1098,7 +1098,7 @@ describe('write features', function() { Language: "L4nguage", Subject: "Subj3ct", Title: "T1tle" - } + }; }); if(typeof before != 'undefined') before(bef); else it('before', bef); @@ -1396,8 +1396,8 @@ describe('json output', function() { assert.equal(json[0][3], "jimjin"); assert.doesNotThrow(function() { seeker(json, [1,2,3], "sheetjs"); }); assert.throws(function() { seeker(json, [1,2,3], "baz"); }); - var json = X.utils.sheet_to_json(ws, {raw:true}); - var json = X.utils.sheet_to_json(ws, {raw:true, defval: 'jimjin'}); + X.utils.sheet_to_json(ws, {raw:true}); + X.utils.sheet_to_json(ws, {raw:true, defval: 'jimjin'}); }); it('should disambiguate headers', function() { var _data = [["S","h","e","e","t","J","S"],[1,2,3,4,5,6,7],[2,3,4,5,6,7,8]]; @@ -1597,7 +1597,7 @@ describe('encryption', function() { describe(x, function() { it('should throw with no password', function() {assert.throws(function() { X.readFile(dir + x); }); }); it('should throw with wrong password', function() {assert.throws(function() { X.readFile(dir + x, {password:'passwor',WTF:opts.WTF}); }); }); - it('should recognize correct password', function() { + it.skip('should recognize correct password', function() { try { X.readFile(dir + x, {password:'password',WTF:opts.WTF}); } catch(e) { if(e.message == "Password is incorrect") throw e; } });