diff --git a/test/index.html b/test/index.html deleted file mode 100644 index f51c817d..00000000 --- a/test/index.html +++ /dev/null @@ -1,11 +0,0 @@ - - - - - h5ai test suite - - - - - - diff --git a/test/index.js b/test/index.js deleted file mode 100644 index 7c05e229..00000000 --- a/test/index.js +++ /dev/null @@ -1,17 +0,0 @@ -if (!global.window) { - const JSDOM = require('jsdom').JSDOM; - global.window = new JSDOM('').window; -} - -const {test} = require('scar'); -const {pin_html} = require('./util/pin'); - -require('./tests/premisses'); -require('./tests/unit/core/event'); -require('./tests/unit/core/format'); -require('./tests/unit/util/naturalCmp'); -require('./tests/unit/util/parsePatten'); - -pin_html(); - -test.cli({sync: true}); diff --git a/test/tests/premisses.js b/test/tests/premisses.js deleted file mode 100644 index 92585c8f..00000000 --- a/test/tests/premisses.js +++ /dev/null @@ -1,7 +0,0 @@ -const {test, assert} = require('scar'); - -test('window is global object', () => { - assert.ok(global.window); - assert.equal(global.window, global.window.window); - assert.ok(global.window.document); -}); diff --git a/test/tests/unit/core/event.js b/test/tests/unit/core/event.js deleted file mode 100644 index 19318d45..00000000 --- a/test/tests/unit/core/event.js +++ /dev/null @@ -1,10 +0,0 @@ -const {test, assert} = require('scar'); -const reqlib = require('../../../util/reqlib'); -const event = reqlib('core/event'); - -test('core.event', () => { - assert.equal(typeof event, 'object', 'is object'); - assert.deepEqual(Object.keys(event).sort(), ['sub', 'pub'].sort()); - assert.equal(typeof event.sub, 'function'); - assert.equal(typeof event.pub, 'function'); -}); diff --git a/test/tests/unit/core/format.js b/test/tests/unit/core/format.js deleted file mode 100644 index b3ef8f0d..00000000 --- a/test/tests/unit/core/format.js +++ /dev/null @@ -1,12 +0,0 @@ -const {test, assert} = require('scar'); -const reqlib = require('../../../util/reqlib'); -const format = reqlib('core/format'); - -test('core.format', () => { - assert.equal(typeof format, 'object'); - assert.deepEqual(Object.keys(format).sort(), ['setDefaultMetric', 'formatSize', 'setDefaultDateFormat', 'formatDate'].sort()); - assert.equal(typeof format.setDefaultMetric, 'function'); - assert.equal(typeof format.formatSize, 'function'); - assert.equal(typeof format.setDefaultDateFormat, 'function'); - assert.equal(typeof format.formatDate, 'function'); -}); diff --git a/test/tests/unit/util/naturalCmp.js b/test/tests/unit/util/naturalCmp.js deleted file mode 100644 index f392ce10..00000000 --- a/test/tests/unit/util/naturalCmp.js +++ /dev/null @@ -1,42 +0,0 @@ -const {test, assert, insp} = require('scar'); -const reqlib = require('../../../util/reqlib'); -const {naturalCmp} = reqlib('util'); - -test('util.naturalCmp()', () => { - assert.equal(typeof naturalCmp, 'function', 'is function'); - - [ - '-1', - '0', - '00', - '000', - '001', - '01', - '02', - '1', - '3', - 'a0', - 'a00', - 'a1', - 'a2', - 'a 0', - 'a 00', - 'a 000', - 'a 01', - 'a 1', - 'a 2', - 'a 3', - 'a.1', - 'a.1.0', - 'a.1.1', - 'a.1.1.0', - 'a.1.10', - 'z' - ].forEach((b, idx, arr) => { - if (idx === 0) { - return; - } - const a = arr[idx - 1]; - assert.equal(naturalCmp(a, b), -1, `fix#${idx} - ${insp(a)} < ${insp(b)}`); - }); -}); diff --git a/test/tests/unit/util/parsePatten.js b/test/tests/unit/util/parsePatten.js deleted file mode 100644 index 506cf3dc..00000000 --- a/test/tests/unit/util/parsePatten.js +++ /dev/null @@ -1,41 +0,0 @@ -const {test, assert, insp} = require('scar'); -const reqlib = require('../../../util/reqlib'); -const {parsePattern} = reqlib('util'); - -test('util.parsePattern()', () => { - assert.equal(typeof parsePattern, 'function', 'is function'); - - [ - ['', false, ''], - [' ', false, '\\ '], - ['a', false, 'a'], - ['ä', false, 'ä'], - ['á', false, 'á'], - ['*', false, '\\*'], - ['ab', false, 'ab'], - ['rea', false, 'rea'], - ['re:', false, 're:'], - ['re:a', false, 're:a'], - ['a b', false, 'a\\ b'], - ['ab c', false, 'ab\\ c'], - [' a ', false, '\\ a\\ '], - - ['', true, ''], - [' ', true, ''], - ['a', true, 'a'], - ['ä', true, 'ä'], - ['á', true, 'á'], - ['*', true, '\\*'], - ['ab', true, 'a.*?b'], - ['rea', true, 'r.*?e.*?a'], - [' re:', true, 'r.*?e.*?:'], - ['are:', true, 'a.*?r.*?e.*?:'], - ['re:', true, ''], - ['re:a', true, 'a'], - ['a b', true, 'a|b'], - ['ab c', true, 'a.*?b|c'], - [' a ', true, 'a'] - ].forEach(([pattern, advanced, exp], idx) => { - assert.equal(parsePattern(pattern, advanced), exp, `fix#${idx} - (${insp(pattern)}, ${insp(advanced)}) -> ${insp(exp)}`); - }); -}); diff --git a/test/util/pin.js b/test/util/pin.js deleted file mode 100644 index 90349477..00000000 --- a/test/util/pin.js +++ /dev/null @@ -1,53 +0,0 @@ -const win = global.window; -const doc = win.document; - -const pinned = {}; - -const attr = (el, name, value) => { - if (typeof el === 'string') { - el = doc.querySelector(el); - } - if (value === undefined) { - return el.getAttribute(name); - } - if (value === null) { - return el.removeAttribute(name); - } - return el.setAttribute(name, value); -}; - -const root_children = () => { - return [ - ...doc.querySelector('head').childNodes, - ...doc.querySelector('body').childNodes - ]; -}; - -const pin_html = () => { - pinned.title = doc.title; - pinned.htmlId = attr('html', 'id'); - pinned.htmlClasses = attr('html', 'class'); - pinned.bodyId = attr('body', 'id'); - pinned.bodyClasses = attr('body', 'class'); - pinned.els = root_children(); - // console.log('pinned', pinned); -}; - -const restore_html = () => { - doc.title = pinned.title; - attr('html', 'id', pinned.htmlId); - attr('html', 'class', pinned.htmlClasses); - attr('body', 'id', pinned.bodyId); - attr('body', 'class', pinned.bodyClasses); - root_children().forEach(el => { - if (pinned.els.indexOf(el) < 0) { - el.remove(); - } - }); - // win.localStorage.clear(); -}; - -module.exports = { - pin_html, - restore_html -}; diff --git a/test/util/reqlib.js b/test/util/reqlib.js deleted file mode 100644 index 8c551123..00000000 --- a/test/util/reqlib.js +++ /dev/null @@ -1,3 +0,0 @@ -const reqlib = x => require(`../../src/_h5ai/public/js/lib/${x}`); - -module.exports = reqlib;