From 18381352fc93933c3444d78cfd40d35d2d02ab79 Mon Sep 17 00:00:00 2001 From: Nikolay Emrikh Date: Sun, 23 Sep 2018 22:25:20 +0300 Subject: [PATCH] Adds more tests and fixes problems (#37) * Adds more tests and fixes problems * more tests and more bug fixes * more promise tests * moore tests * escape key and value values * implemented printer & logger from whatwg spec * temp version of format specifiers --- gulpfile.js | 37 ++-- index-silent.html | 5 +- index.html | 6 +- js/array/array-view.js | 3 + js/console.js | 133 ++++++++++---- js/enums.js | 20 --- js/function/function-view.js | 7 +- js/index.js | 2 +- js/object/map-entry-view.js | 2 +- js/object/object-view.js | 34 ++-- js/object/promise-view.js | 2 +- js/object/string-number-view.js | 5 +- js/tests/common.test.js | 26 +++ js/tests/configuration.test.js | 79 ++++----- js/tests/markup.test.js | 3 +- js/tests/object/number-string.test.js | 57 ++++++ js/tests/object/object-literal.test.js | 67 +++++++ js/tests/object/promise.test.js | 237 +++++++++++++++++++++++++ js/tests/test-helpers.js | 30 ++++ js/type-view.js | 29 ++- jsconsole.html | 6 +- karma-chai-adapter.js | 4 + karma.conf.js | 10 +- package-lock.json | 6 - package.json | 1 - sass/entry-container.scss | 13 +- sass/style.scss | 7 +- test.html | 1 + 28 files changed, 650 insertions(+), 182 deletions(-) create mode 100644 js/tests/common.test.js create mode 100644 js/tests/object/number-string.test.js create mode 100644 js/tests/object/object-literal.test.js create mode 100644 js/tests/object/promise.test.js create mode 100644 js/tests/test-helpers.js create mode 100644 karma-chai-adapter.js diff --git a/gulpfile.js b/gulpfile.js index de95e1e..ff5c601 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -82,15 +82,13 @@ gulp.task(`build-scripts`, () => { jsnext: true, browser: true }), - commonjs({ - include: `node_modules/**` - }), + commonjs(), json(), babel({ babelrc: false, exclude: [`node_modules/**`, `js/tests/**`], presets: [ - [`@babel/preset-env`, {modules: false}] + [`@babel/preset-env`, {modules: false, useBuiltIns: `entry`}] ] }) ] @@ -111,9 +109,7 @@ gulp.task(`build-prompt`, () => { jsnext: true, browser: true }), - commonjs({ - include: `node_modules/**` - }), + commonjs(), json(), babel({ babelrc: false, @@ -168,18 +164,25 @@ gulp.task(`build-tests`, () => { }); gulp.task(`test`, function (done) { - // return gulp - // .src([`js/**/*.test.js`], { - // read: false - // }) - // .pipe(mocha({ - // compilers: [`js:babel-register`], - // reporter: `spec` - // })); + let testOnlyFiles; + if (process.env.TEST_ONLY_FILES) { + testOnlyFiles = process.env.TEST_ONLY_FILES + .trim() + .split(/\s*\,\s*|\s+/) + .join(`|`); + } + const testsGlob = `build/js/tests/**/${testOnlyFiles ? `+(${testOnlyFiles})` : `*`}.test.js`; + new KarmaServer({ configFile: __dirname + `/karma.conf.js`, - // singleRun: true, - debug: true + singleRun: process.env.TEST_DEBUG !== `true`, + debug: true, + files: [ + `node_modules/chai/chai.js`, + `karma-chai-adapter.js`, + `build/js/index.js`, + testsGlob + ] }, done).start(); }); diff --git a/index-silent.html b/index-silent.html index 34bad4a..c578faf 100644 --- a/index-silent.html +++ b/index-silent.html @@ -21,13 +21,14 @@