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');