diff --git a/ghu.js b/ghu.js index 5c45de1a..441b3c56 100644 --- a/ghu.js +++ b/ghu.js @@ -7,7 +7,6 @@ const { const ROOT = resolve(__dirname); const SRC = join(ROOT, 'src'); const TEST = join(ROOT, 'test'); -const TEST_SCAR = join(ROOT, 'test-scar'); const BUILD = join(ROOT, 'build'); const mapper = mapfn.p(SRC, BUILD).s('.less', '.css').s('.jade', ''); @@ -120,43 +119,12 @@ ghu.task('build:copy', runtime => { ]); }); -ghu.task('build:tests', ['build:scripts', 'build:styles'], 'build the test suite', runtime => { - return Promise.all([ - read(`${TEST}/scripts.js`) - .then(newerThan(`${BUILD}/test/scripts.js`)) - .then(includeit()) - .then(write(`${BUILD}/test/scripts.js`, {overwrite: true})), - - read(`${TEST}/styles.less`) - .then(newerThan(`${BUILD}/test/styles.css`)) - .then(includeit()) - .then(less()) - .then(autoprefixer()) - .then(write(`${BUILD}/test/styles.css`, {overwrite: true})), - - read(`${TEST}/index.html.jade`) - .then(newerThan(`${BUILD}/test/index.html`)) - .then(pug({pkg: runtime.pkg})) - .then(write(`${BUILD}/test/index.html`, {overwrite: true})), - - read(`${BUILD}/_h5ai/public/js/scripts.js`) - .then(newerThan(`${BUILD}/test/h5ai-scripts.js`)) - .then(write(`${BUILD}/test/h5ai-scripts.js`, {overwrite: true})), - - read(`${BUILD}/_h5ai/public/css/styles.css`) - .then(newerThan(`${BUILD}/test/h5ai-styles.css`)) - .then(write(`${BUILD}/test/h5ai-styles.css`, {overwrite: true})) - ]).then(() => { - console.log(`browse to file://${BUILD}/test/index.html to run the test suite`); - }); -}); - -ghu.task('build:tests-scar', ['build:scripts', 'build:styles'], 'build the test suite', () => { +ghu.task('build:tests', ['build:styles'], 'build the test suite', () => { const webpackConfig = { module: { loaders: [ { - include: [TEST_SCAR], + include: [TEST], loader: 'babel', query: {cacheDirectory: true} } @@ -165,27 +133,25 @@ ghu.task('build:tests-scar', ['build:scripts', 'build:styles'], 'build the test }; return Promise.all([ - read(`${BUILD}/_h5ai/public/js/scripts.js`) - .then(newerThan(`${BUILD}/test-scar/h5ai-scripts.js`)) - .then(write(`${BUILD}/test-scar/h5ai-scripts.js`, {overwrite: true})), - read(`${BUILD}/_h5ai/public/css/styles.css`) - .then(newerThan(`${BUILD}/test-scar/h5ai-styles.css`)) - .then(write(`${BUILD}/test-scar/h5ai-styles.css`, {overwrite: true})), + .then(newerThan(`${BUILD}/test/h5ai-styles.css`)) + .then(write(`${BUILD}/test/h5ai-styles.css`, {overwrite: true})), - read(`${TEST_SCAR}/tests.html`) - .then(newerThan(`${BUILD}/test-scar/tests.html`)) - .then(write(`${BUILD}/test-scar/tests.html`, {overwrite: true})), + read(`${TEST}/tests.html`) + .then(newerThan(`${BUILD}/test/tests.html`)) + .then(write(`${BUILD}/test/tests.html`, {overwrite: true})), - read(`${TEST_SCAR}: tests.js`) + read(`${TEST}: tests.js`) .then(webpack(webpackConfig, {showStats: false})) - .then(write(mapfn.p(TEST_SCAR, `${BUILD}/test-scar`), {overwrite: true})) + .then(wrap(`\n\n// @include "${SRC}/**/js/global.js"\n\n`)) + .then(includeit()) + .then(write(mapfn.p(TEST, `${BUILD}/test`), {overwrite: true})) ]).then(() => { - console.log(`browse to file://${BUILD}/test-scar/tests.html to run the test suite`); + console.log(`browse to file://${BUILD}/test/tests.html to run the test suite`); }); }); -ghu.task('build', ['build:scripts', 'build:styles', 'build:pages', 'build:copy', 'build:tests', 'build:tests-scar'], +ghu.task('build', ['build:scripts', 'build:styles', 'build:pages', 'build:copy', 'build:tests'], 'build all updated files, optionally use :production'); ghu.task('deploy', ['build'], 'deploy to a specified path with :dest=/some/path', runtime => { @@ -202,7 +168,7 @@ ghu.task('deploy', ['build'], 'deploy to a specified path with :dest=/some/path' }); ghu.task('watch', runtime => { - return watch([SRC, TEST, TEST_SCAR], () => ghu.run(runtime.sequence.filter(x => x !== 'watch'), runtime.args, true)); + return watch([SRC, TEST], () => ghu.run(runtime.sequence.filter(x => x !== 'watch'), runtime.args, true)); }); ghu.task('release', ['force-production', 'clean', 'build'], 'create a zipball', runtime => { diff --git a/test-scar/.eslintrc b/test-scar/.eslintrc deleted file mode 100644 index 34d009c4..00000000 --- a/test-scar/.eslintrc +++ /dev/null @@ -1,3 +0,0 @@ ---- - env: - browser: true diff --git a/test-scar/tests.js b/test-scar/tests.js deleted file mode 100644 index 2d3319f9..00000000 --- a/test-scar/tests.js +++ /dev/null @@ -1,16 +0,0 @@ -const {test} = require('scar'); -const {clearModulejs, mockConfigModule} = require('./util/modjs'); -const {pinHtml} = require('./util/pin'); - -mockConfigModule(); -clearModulejs(); - -require('./tests/premisses'); -require('./tests/unit/boot'); -require('./tests/unit/config'); -require('./tests/unit/libs'); -require('./tests/unit/modulejs'); - -pinHtml(); - -test.cli({sync: true}); diff --git a/test-scar/tests/premisses.js b/test-scar/tests/premisses.js deleted file mode 100644 index e5e25cf5..00000000 --- a/test-scar/tests/premisses.js +++ /dev/null @@ -1,21 +0,0 @@ -const {test, assert} = require('scar'); - -test('window is global object', () => { - assert.equal(typeof window, 'object'); - assert.equal(window, window.window); -}); - -test('document is global object', () => { - assert.equal(typeof window.document, 'object'); -}); - -test('jQuery and $ are global functions', () => { - assert.equal(typeof window.jQuery, 'function'); - assert.equal(window.jQuery.fn.jquery, '2.2.4'); - assert.equal(window.jQuery, window.$); -}); - -test('_ is global function', () => { - assert.equal(typeof window._, 'function'); - assert.equal(window._.VERSION, '4.13.1'); -}); diff --git a/test-scar/tests/unit/boot.js b/test-scar/tests/unit/boot.js deleted file mode 100644 index c49ed768..00000000 --- a/test-scar/tests/unit/boot.js +++ /dev/null @@ -1,33 +0,0 @@ -const {test, assert} = require('scar'); -const sinon = require('sinon'); - -const ID = 'boot'; -const DEPS = ['$', 'core/server']; - -const getDef = () => window.modulejs._private.definitions[ID]; -const createInst = () => getDef().fn.call(null, window.jQuery, {}); - -test(`module '${ID}' is defined`, () => { - assert.ok(getDef()); -}); - -test(`module '${ID}' has correct id`, () => { - assert.equal(getDef().id, ID); -}); - -test(`module '${ID}' has correct deps`, () => { - assert.deepEqual(getDef().deps, DEPS); -}); - -test(`module '${ID}' has args for each dependency`, () => { - const def = getDef(); - assert.deepEqual(def.deps.length, def.fn.length); -}); - -test(`module '${ID}' inits without errors`, () => { - createInst(); -}); - -test(`module '${ID}' instance is undefined`, () => { - assert.equal(createInst(), undefined); -}); diff --git a/test-scar/tests/unit/config.js b/test-scar/tests/unit/config.js deleted file mode 100644 index 6ac18eee..00000000 --- a/test-scar/tests/unit/config.js +++ /dev/null @@ -1,32 +0,0 @@ -const {test, assert} = require('scar'); - -const ID = 'config'; -const DEPS = []; - -const getDef = () => window.modulejs._private.definitions[ID]; -const createInst = () => getDef().fn(); - -test(`module '${ID}' is defined`, () => { - assert.ok(getDef()); -}); - -test(`module '${ID}' has correct id`, () => { - assert.equal(getDef().id, ID); -}); - -test(`module '${ID}' has correct deps`, () => { - assert.deepEqual(getDef().deps, DEPS); -}); - -test(`module '${ID}' has args for each dependency`, () => { - const def = getDef(); - assert.deepEqual(def.deps.length, def.fn.length); -}); - -test(`module '${ID}' inits without errors`, () => { - createInst(); -}); - -test(`module '${ID}' is only dummy definiton`, () => { - assert.deepEqual(createInst(), {_dummyConfig: true}); -}); diff --git a/test-scar/tests/unit/libs.js b/test-scar/tests/unit/libs.js deleted file mode 100644 index 0140d2e5..00000000 --- a/test-scar/tests/unit/libs.js +++ /dev/null @@ -1,25 +0,0 @@ -const {test, assert} = require('scar'); - -const libs = { - _: window._, - $: window.jQuery, - marked: window.marked, - prism: window.Prism -}; - -Object.keys(libs).forEach(id => { - test(`module '${id}' is defined`, () => { - assert.ok(window.modulejs._private.definitions[id]); - }); - - test(`module '${id}' has no instance`, () => { - assert.equal(window.modulejs._private.instances[id], undefined); - }); - - test(`module '${id}' returns global lib`, () => { - const definition = window.modulejs._private.definitions[id]; - const instance = definition.fn(); - assert.ok(instance); - assert.equal(instance, libs[id]); - }); -}); diff --git a/test-scar/tests/unit/modulejs.js b/test-scar/tests/unit/modulejs.js deleted file mode 100644 index 7fc11fba..00000000 --- a/test-scar/tests/unit/modulejs.js +++ /dev/null @@ -1,33 +0,0 @@ -const {test, assert} = require('scar'); - -test('modulejs is global object', () => { - assert.equal(typeof window.modulejs, 'object'); -}); - -test('modulejs.define() is function', () => { - assert.equal(typeof window.modulejs.define, 'function'); -}); - -test('modulejs.require() is function', () => { - assert.equal(typeof window.modulejs.require, 'function'); -}); - -test('modulejs.state() is function', () => { - assert.equal(typeof window.modulejs.state, 'function'); -}); - -test('modulejs.log() is function', () => { - assert.equal(typeof window.modulejs.log, 'function'); -}); - -test('modulejs._private is object', () => { - assert.equal(typeof window.modulejs._private, 'object'); -}); - -test('modulejs has definitions', () => { - assert.ok(Object.keys(window.modulejs._private.definitions).length >= 0); -}); - -test('modulejs has no instances', () => { - assert.equal(Object.keys(window.modulejs._private.instances).length, 0); -}); diff --git a/test-scar/util/modjs.js b/test-scar/util/modjs.js deleted file mode 100644 index 49de5244..00000000 --- a/test-scar/util/modjs.js +++ /dev/null @@ -1,17 +0,0 @@ -const lodash = window._; -const modjs = window.modulejs; - -function clearModulejs() { - lodash.each(modjs._private.instances, (val, key) => { - delete modjs._private.instances[key]; // eslint-disable-line prefer-reflect - }); -} - -function mockConfigModule() { - modjs.define('config', {_dummyConfig: true}); -} - -module.exports = { - clearModulejs, - mockConfigModule -}; diff --git a/test-scar/util/pin.js b/test-scar/util/pin.js deleted file mode 100644 index 1419ffca..00000000 --- a/test-scar/util/pin.js +++ /dev/null @@ -1,33 +0,0 @@ -const jq = window.jQuery; -let title; -let htmlId; -let htmlClasses; -let bodyId; -let bodyClasses; -let $pinnedElements; - -function pinHtml() { - title = document.title; - htmlId = jq('html').attr('id'); - htmlClasses = jq('html').attr('class'); - bodyId = jq('body').attr('id'); - bodyClasses = jq('body').attr('class'); - $pinnedElements = jq('head,body').children(); -} - -function restoreHtml() { - document.title = title; - jq('html').attr('id', htmlId); - jq('html').attr('class', htmlClasses); - jq('body').attr('id', bodyId); - jq('body').attr('class', bodyClasses); - jq('head,body').children().not($pinnedElements).remove(); - if (window.localStorage && window.localStorage.clear) { - window.localStorage.clear(); - } -} - -module.exports = { - pinHtml, - restoreHtml -}; diff --git a/test/.eslintrc b/test/.eslintrc deleted file mode 100644 index 65cfb122..00000000 --- a/test/.eslintrc +++ /dev/null @@ -1,30 +0,0 @@ ---- - env: - es6: false - node: false - browser: true - mocha: true - - globals: - modulejs: false - jQuery: false - $: false - _: false - util: false - assert: false - uniq: false - sinon: false - - parserOptions: - ecmaVersion: 6 - - rules: - consistent-this: 0 - func-names: 0 - max-nested-callbacks: [1, 5] - max-params: [1, 10] - no-invalid-this: 0 - no-var: 0 - object-shorthand: 0 - prefer-arrow-callback: 0 - prefer-reflect: 0 diff --git a/test/index.html.jade b/test/index.html.jade deleted file mode 100644 index f6137360..00000000 --- a/test/index.html.jade +++ /dev/null @@ -1,14 +0,0 @@ -doctype html -html - head - meta(charset="utf-8") - meta(http-equiv="x-ua-compatible", content="ie=edge") - title h5ai test suite - v#{pkg.version} - meta(name="viewport", content="width=device-width, initial-scale=1") - link(rel="stylesheet", href="h5ai-styles.css") - link(rel="stylesheet", href="styles.css") - script(src="h5ai-scripts.js") - script(src="scripts.js") - - body - div#mocha diff --git a/test/scripts.js b/test/scripts.js deleted file mode 100644 index 43b14689..00000000 --- a/test/scripts.js +++ /dev/null @@ -1,35 +0,0 @@ -// @include "vendor/*.js" - -(function () { - 'use strict'; // eslint-disable-line strict - // @include "util/*.js" -}()); - -jQuery(function () { - 'use strict'; // eslint-disable-line strict - - util.mockConfigModule(); - util.clearModulejs(); - util.setupMocha(); - - describe('all tests', function () { - // @include "tests/premisses.js" - - describe('unit tests', function () { - // @include "tests/unit/modulejs.js" - // @include "tests/unit/libs.js" - // @include "tests/unit/boot.js" - // @include "tests/unit/config.js" - - // @include "tests/unit/*/*.js" - }); - - describe('integration tests', function () { - // @include "tests/integration/*.js" - // @-include "tests/integration/*/*.js" - }); - }); - - util.pinHtml(); - util.runMocha(); -}); diff --git a/test/styles.less b/test/styles.less deleted file mode 100644 index 5f478833..00000000 --- a/test/styles.less +++ /dev/null @@ -1,230 +0,0 @@ -@charset 'utf-8'; - -@col-white: #ffffff; -@col-red-500: #f44336; -@col-red-800: #c62828; -@col-amber-800: #ff8f00; -@col-green-500: #4caf50; -@col-grey-200: #eeeeee; -@col-grey-800: #424242; - -@col-text: @col-grey-800; -@col-text-fail: @col-red-800; -@col-back-hover: @col-grey-200; -@col-pending: @col-grey-800; -@col-pass: @col-green-500; -@col-fail: @col-red-500; -@col-medium: @col-amber-800; -@col-slow: @col-red-800; -@col-progress: rgba(255,255,255,0.2); - -#mocha { - position: fixed; - left: 0; - top: 0; - right: 0; - bottom: 0; - z-index: 10000; - font-family: "Ubuntu", "Roboto", "Helvetica", "Arial", "sans-serif"; - background: @col-white; - - #mocha-bar { - position: absolute; - left: 0; - top: 0; - right: 0; - height: 32px; - color: @col-white; - background: @col-pending; - font-size: 14px; - font-weight: bold; - line-height: 32px; - padding: 0 8px; - text-shadow: 0 0 4px @col-text; - - &.pass { - background: @col-pass; - } - &.fail { - background: @col-fail; - } - .stats { - display: block; - position: absolute; - right: 8px; - top: 0; - cursor: pointer; - } - .progress { - display: block; - position: absolute; - right: 0; - top: 0; - height: 100%; - background: @col-progress; - } - } - - #mocha-stats { - display: none; - } - - #mocha-report { - position: absolute; - left: 0; - top: 32px; - right: 0; - bottom: 0; - overflow-x: auto; - overflow-y: scroll; - - > .suite { - margin: 0 auto; - padding: 32px; - max-width: 900px; - - > .toggle { - display: none; - } - } - } - - a, a:active, a:visited, a:hover { - display: block; - color: inherit; - text-decoration: none; - } - - ul, li, h1, h2 { - margin: 0; - padding: 0; - } - - ul { - list-style: none; - } - - h1 { - color: @col-text; - height: 24px; - line-height: 24px; - font-size: 16px; - font-weight: bold; - - &:hover { - background: @col-back-hover; - } - a, a:active, a:visited, a:hover { - padding: 0 8px; - } - .count { - font-size: 0.85em; - } - .passed { - color: @col-pass; - margin-left: 1em; - } - .failed { - color: @col-fail; - margin-left: 0.5em; - } - } - - h2 { - font-size: 12px; - font-weight: normal; - cursor: pointer; - } - - pre { - display: block; - font-family: "Ubuntu Mono", "Monaco", "Lucida Sans Typewriter", "monospace"; - font-size: 12px; - margin: 4px 0 16px 18px; - padding: 0 8px; - word-wrap: break-word; - border-left: 2px solid @col-text; - - &.error { - color: @col-text-fail; - } - } - - .suite { - position: relative; - margin: 16px 0 8px 24px; - - .toggle { - position: absolute; - left: -24px; - top: 0; - width: 24px; - height: 24px; - line-height: 24px; - color: @col-text; - font-size: 16px; - font-weight: bold; - text-align: center; - cursor: pointer; - - &:hover { - background: @col-back-hover; - } - } - } - - .test { - margin-left: 15px; - padding: 2px 4px; - overflow: hidden; - - &:hover { - background: @col-back-hover; - } - &.fail { - color: @col-text-fail; - } - - &::before { - content: ' '; - display: block; - width: 10px; - height: 10px; - float: left; - margin-right: 8px; - background: @col-pending; - border-radius: 20px; - position: relative; - top: 3px; - } - &.pass::before { - background: @col-pass; - } - &.fail::before { - background: @col-fail; - } - &.pending::before { - background: @col-pending; - } - - .duration { - display: inline-block; - color: @col-text; - border: none; - box-shadow: none; - font-size: 10px; - margin-left: 12px; - float: right; - } - &.medium .duration { - color: @col-medium; - } - &.slow .duration { - color: @col-slow; - } - } - - .replay { - display: none; - } -} diff --git a/test-scar/tests.html b/test/tests.html similarity index 66% rename from test-scar/tests.html rename to test/tests.html index 26434ba4..aeb9e917 100644 --- a/test-scar/tests.html +++ b/test/tests.html @@ -2,9 +2,8 @@ - h5ai test suite - scar + h5ai test suite - diff --git a/test/tests.js b/test/tests.js new file mode 100644 index 00000000..a9401423 --- /dev/null +++ b/test/tests.js @@ -0,0 +1,8 @@ +const {test} = require('scar'); +const {pinHtml} = require('./util/pin'); + +require('./tests/premisses'); + +pinHtml(); + +test.cli({sync: true}); diff --git a/test/tests/integration/view.js b/test/tests/integration/view.js deleted file mode 100644 index 98f6e02d..00000000 --- a/test/tests/integration/view.js +++ /dev/null @@ -1,106 +0,0 @@ -(function () { - describe('view', function () { - before(function () { - this.configBackup = modulejs._private.definitions.config; - this.storeKey = '_h5ai'; - this.xConfig = { - setup: { - PUBLIC_HREF: uniq.path('-PUBLIC/'), - ROOT_HREF: uniq.path('-ROOT/') - } - }; - }); - - after(function () { - modulejs._private.definitions.config = this.configBackup; - util.clearModulejs(); - util.restoreHtml(); - }); - - beforeEach(function () { - delete modulejs._private.definitions.config; - modulejs.define('config', this.xConfig); - util.clearModulejs(); - util.restoreHtml(); - $('
').appendTo('body'); - $('
').appendTo('body'); - }); - - describe('requiring \'view/viewmode\' sets up basic HTML', function () { - it('runs without errors', function () { - modulejs.require('view/viewmode'); - }); - - it('adds id root to body', function () { - modulejs.require('view/viewmode'); - assert.strictEqual($('body').attr('id'), 'root'); - }); - - it('removes HTML #fallback', function () { - modulejs.require('view/viewmode'); - assert.lengthOf($('#fallback'), 0); - }); - - it('removes HTML #fallback-hints', function () { - modulejs.require('view/viewmode'); - assert.lengthOf($('#fallback-hints'), 0); - }); - - it('adds HTML #mainrow to #root', function () { - modulejs.require('view/viewmode'); - assert.lengthOf($('#root > #mainrow'), 1); - }); - - it('adds HTML #content to #mainrow', function () { - modulejs.require('view/viewmode'); - assert.lengthOf($('#mainrow > #content'), 1); - }); - - it('adds HTML #view to #content', function () { - modulejs.require('view/viewmode'); - assert.lengthOf($('#content > #view'), 1); - }); - - it('adds HTML #items to #view', function () { - modulejs.require('view/viewmode'); - assert.lengthOf($('#view > #items'), 1); - }); - - it('adds HTML #topbar to #root', function () { - modulejs.require('view/viewmode'); - assert.lengthOf($('#root > #topbar'), 1); - }); - - it('adds HTML #toolbar to #topbar', function () { - modulejs.require('view/viewmode'); - assert.lengthOf($('#topbar > #toolbar'), 1); - }); - - it('adds HTML #flowbar to #topbar', function () { - modulejs.require('view/viewmode'); - assert.lengthOf($('#topbar > #flowbar'), 1); - }); - - it('adds HTML #backlink to #topbar', function () { - modulejs.require('view/viewmode'); - assert.lengthOf($('#topbar > #backlink'), 1); - }); - - it('adds HTML #sidebar-toggle to #toolbar', function () { - modulejs.require('view/viewmode'); - assert.lengthOf($('#toolbar > #sidebar-toggle'), 1); - }); - - it('adds HTML #viewmode-settings to #sidebar', function () { - modulejs.require('view/viewmode'); - assert.lengthOf($('#sidebar > #viewmode-settings'), 1); - }); - - it('adds style to head', function () { - var styleTagCount = $('head > style').length; - modulejs.require('view/viewmode'); - assert.lengthOf($('head > style'), styleTagCount + 1); - }); - }); - }); -}()); diff --git a/test/tests/premisses.js b/test/tests/premisses.js index 770f8ff7..43ba34d2 100644 --- a/test/tests/premisses.js +++ b/test/tests/premisses.js @@ -1,69 +1,21 @@ -(function () { - describe('premisses', function () { - it('window is global object', function () { - assert.isObject(window); - assert.strictEqual(window, window.window); - }); +const {test, assert} = require('scar'); - it('document is global object', function () { - assert.isObject(document); - assert.strictEqual(document, window.document); - }); +test('window is global object', () => { + assert.equal(typeof global, 'object'); + assert.equal(global, global.window); +}); - it('jQuery and $ are global functions', function () { - assert.isFunction(jQuery); - assert.strictEqual(jQuery, window.jQuery); - assert.strictEqual(jQuery.fn.jquery, '2.2.4'); +test('document is global object', () => { + assert.equal(typeof global.document, 'object'); +}); - assert.strictEqual($, jQuery); - assert.strictEqual($, window.$); - }); +test('jQuery and $ are global functions', () => { + assert.equal(typeof global.jQuery, 'function'); + assert.equal(global.jQuery.fn.jquery, '2.2.4'); + assert.equal(global.jQuery, global.$); +}); - it('_ is global function', function () { - assert.isFunction(_); - assert.strictEqual(_, window._); - assert.strictEqual(_.VERSION, '4.13.1'); - }); - - it('util is global object', function () { - assert.isPlainObject(util); - assert.strictEqual(util, window.util); - }); - - it('uniq is global object', function () { - assert.isPlainObject(uniq); - assert.strictEqual(uniq, window.uniq); - }); - - it('assert.isPlainObject() works', function () { - assert.isFunction(assert.isPlainObject); - - assert.isPlainObject({}); - assert.isPlainObject({a: 1}); - assert.isPlainObject(Object()); - assert.isPlainObject(new Object()); // eslint-disable-line no-new-object - - assert.throws(function () { assert.isPlainObject(); }); - assert.throws(function () { assert.isPlainObject(1); }); - assert.throws(function () { assert.isPlainObject('a'); }); - assert.throws(function () { assert.isPlainObject(new Date()); }); - assert.throws(function () { assert.isPlainObject(/a/); }); - assert.throws(function () { assert.isPlainObject(function () {}); }); - assert.throws(function () { assert.isPlainObject(new function A() {}); }); - }); - - it('assert.lengthOfKeys() works', function () { - assert.isFunction(assert.lengthOfKeys); - - assert.lengthOfKeys({}, 0); - assert.lengthOfKeys({a: true}, 1); - assert.lengthOfKeys({a: true, b: 0, c: undefined}, 3); - - assert.throws(function () { assert.lengthOfKeys(); }); - assert.throws(function () { assert.lengthOfKeys(1); }); - assert.throws(function () { assert.lengthOfKeys('a'); }); - assert.throws(function () { assert.lengthOfKeys({}); }); - assert.throws(function () { assert.lengthOfKeys({}, 1); }); - }); - }); -}()); +test('_ is global function', () => { + assert.equal(typeof global._, 'function'); + assert.equal(global._.VERSION, '4.13.1'); +}); diff --git a/test/tests/unit/boot.js b/test/tests/unit/boot.js deleted file mode 100644 index 2e0e684f..00000000 --- a/test/tests/unit/boot.js +++ /dev/null @@ -1,134 +0,0 @@ -(function () { - var ID = 'boot'; - var DEPS = ['$', 'core/server']; - - describe('module \'' + ID + '\'', function () { - before(function () { - this.definition = modulejs._private.definitions[ID]; - - this.xConfig = uniq.obj(); - this.xDefine = sinon.stub(modulejs, 'define'); - this.xRequire = sinon.stub(modulejs, 'require'); - this.xServer = { - request: sinon.stub().callsArgWith(1, this.xConfig) - }; - - this.applyFn = function () { - this.xDefine.reset(); - this.xRequire.reset(); - this.xServer.request.reset(); - - return this.definition.fn($, this.xServer); - }; - }); - - after(function () { - this.xDefine.restore(); - this.xRequire.restore(); - util.restoreHtml(); - }); - - beforeEach(function () { - util.restoreHtml(); - }); - - describe('definition', function () { - it('is defined', function () { - assert.isPlainObject(this.definition); - }); - - it('has correct id', function () { - assert.strictEqual(this.definition.id, ID); - }); - - it('requires correct', function () { - assert.deepEqual(this.definition.deps, DEPS); - }); - - it('args for each request', function () { - assert.strictEqual(this.definition.deps.length, this.definition.fn.length); - }); - - it('has no instance', function () { - assert.notProperty(modulejs._private.instances, ID); - }); - - it('inits without errors', function () { - this.applyFn(); - }); - }); - - describe('application', function () { - it('returns undefined', function () { - var instance = this.applyFn(); - assert.isUndefined(instance); - }); - - it('no data-module', function () { - this.applyFn(); - assert.isFalse(this.xServer.request.called); - assert.isFalse(this.xDefine.called); - assert.isFalse(this.xRequire.called); - }); - - it('data-module=\'test\'', function () { - $('