mirror of
https://github.com/lrsjng/h5ai.git
synced 2025-08-11 16:34:01 +02:00
Update.
This commit is contained in:
@@ -4,7 +4,7 @@ if (!global.window) {
|
||||
}
|
||||
|
||||
const {test} = require('scar');
|
||||
const {pinHtml} = require('./util/pin');
|
||||
const {pin_html} = require('./util/pin');
|
||||
|
||||
require('./tests/premisses');
|
||||
require('./tests/unit/core/event');
|
||||
@@ -12,6 +12,6 @@ require('./tests/unit/core/format');
|
||||
require('./tests/unit/util/naturalCmp');
|
||||
require('./tests/unit/util/parsePatten');
|
||||
|
||||
pinHtml();
|
||||
pin_html();
|
||||
|
||||
test.cli({sync: true});
|
||||
|
@@ -1,5 +1,6 @@
|
||||
const {test, assert} = require('scar');
|
||||
const event = require('../../../../src/_h5ai/public/js/lib/core/event');
|
||||
const reqlib = require('../../../util/reqlib');
|
||||
const event = reqlib('core/event');
|
||||
|
||||
test('core.event', () => {
|
||||
assert.equal(typeof event, 'object', 'is object');
|
||||
|
@@ -1,5 +1,6 @@
|
||||
const {test, assert} = require('scar');
|
||||
const format = require('../../../../src/_h5ai/public/js/lib/core/format');
|
||||
const reqlib = require('../../../util/reqlib');
|
||||
const format = reqlib('core/format');
|
||||
|
||||
test('core.format', () => {
|
||||
assert.equal(typeof format, 'object');
|
||||
|
@@ -1,5 +1,6 @@
|
||||
const {test, assert, insp} = require('scar');
|
||||
const {naturalCmp} = require('../../../../src/_h5ai/public/js/lib/util');
|
||||
const reqlib = require('../../../util/reqlib');
|
||||
const {naturalCmp} = reqlib('util');
|
||||
|
||||
test('util.naturalCmp()', () => {
|
||||
assert.equal(typeof naturalCmp, 'function', 'is function');
|
||||
|
@@ -1,5 +1,6 @@
|
||||
const {test, assert, insp} = require('scar');
|
||||
const {parsePattern} = require('../../../../src/_h5ai/public/js/lib/util');
|
||||
const reqlib = require('../../../util/reqlib');
|
||||
const {parsePattern} = reqlib('util');
|
||||
|
||||
test('util.parsePattern()', () => {
|
||||
assert.equal(typeof parsePattern, 'function', 'is function');
|
||||
|
@@ -16,30 +16,30 @@ const attr = (el, name, value) => {
|
||||
return el.setAttribute(name, value);
|
||||
};
|
||||
|
||||
const rootChildren = () => {
|
||||
const root_children = () => {
|
||||
return [
|
||||
...doc.querySelector('head').childNodes,
|
||||
...doc.querySelector('body').childNodes
|
||||
];
|
||||
};
|
||||
|
||||
const pinHtml = () => {
|
||||
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 = rootChildren();
|
||||
pinned.els = root_children();
|
||||
// console.log('pinned', pinned);
|
||||
};
|
||||
|
||||
const restoreHtml = () => {
|
||||
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);
|
||||
rootChildren().forEach(el => {
|
||||
root_children().forEach(el => {
|
||||
if (pinned.els.indexOf(el) < 0) {
|
||||
el.remove();
|
||||
}
|
||||
@@ -48,6 +48,6 @@ const restoreHtml = () => {
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
pinHtml,
|
||||
restoreHtml
|
||||
pin_html,
|
||||
restore_html
|
||||
};
|
||||
|
3
test/util/reqlib.js
Normal file
3
test/util/reqlib.js
Normal file
@@ -0,0 +1,3 @@
|
||||
const reqlib = x => require(`../../src/_h5ai/public/js/lib/${x}`);
|
||||
|
||||
module.exports = reqlib;
|
Reference in New Issue
Block a user