From 13f1a25163468f929e2b29b6db8bd469b62d9377 Mon Sep 17 00:00:00 2001 From: Sam Thorogood Date: Fri, 6 Mar 2020 15:57:33 +1100 Subject: [PATCH] add local mocha test support --- .npmignore | 2 ++ suite.js | 2 +- test.html | 70 ------------------------------------------------------ test.js | 18 ++++++++++++++ 4 files changed, 21 insertions(+), 71 deletions(-) create mode 100644 .npmignore create mode 100644 test.js diff --git a/.npmignore b/.npmignore new file mode 100644 index 0000000..6ca4202 --- /dev/null +++ b/.npmignore @@ -0,0 +1,2 @@ +test.* +suite.* diff --git a/suite.js b/suite.js index 95d45db..7830e5a 100644 --- a/suite.js +++ b/suite.js @@ -102,7 +102,7 @@ function tests(isNative, TextEncoder, TextDecoder) { } -if (window.NativeTextEncoder && window.NativeTextDecoder) { +if (typeof NativeTextEncoder !== 'undefined' && typeof NativeTextDecoder !== 'undefined') { tests(true, NativeTextEncoder, NativeTextDecoder); } tests(false, TextEncoder, TextDecoder); diff --git a/test.html b/test.html index f8b9c9b..0833c89 100644 --- a/test.html +++ b/test.html @@ -43,73 +43,3 @@ - diff --git a/test.js b/test.js new file mode 100644 index 0000000..08accfd --- /dev/null +++ b/test.js @@ -0,0 +1,18 @@ +/** + * @fileoverview Test runner inside a Node environment. + */ + +const mocha = require('mocha'); +const chai = require('chai'); + +global.suite = mocha.suite; +global.test = mocha.test; +global.assert = chai.assert; + +global.NativeTextDecoder = global.TextDecoder; +global.NativeTextEncoder = global.TextEncoder; +global.TextDecoder = null; +global.TextEncoder = null; + +require('./text.js'); // include polyfill +require('./suite.js');