1
0
Fork 0
mirror of https://github.com/lrsjng/h5ai synced 2025-12-16 05:45:15 +01:00

Delete test directory

This commit is contained in:
removedporn 2021-07-21 20:04:38 +08:00 committed by GitHub
parent aa94de4945
commit c13bdbc872
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 0 additions and 196 deletions

View file

@ -1,11 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>h5ai test suite</title>
<link rel="stylesheet" href="h5ai-styles.css">
</head>
<body>
<script src="index.js"></script>
</body>
</html>

View file

@ -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});

View file

@ -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);
});

View file

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

View file

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

View file

@ -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)}`);
});
});

View file

@ -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)}`);
});
});

View file

@ -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
};

View file

@ -1,3 +0,0 @@
const reqlib = x => require(`../../src/_h5ai/public/js/lib/${x}`);
module.exports = reqlib;