1
0
mirror of synced 2025-12-09 07:08:17 +08:00

style: tests

This commit is contained in:
surunzi
2019-12-16 17:55:59 +08:00
parent b1f4157f10
commit 07404492db
15 changed files with 438 additions and 395 deletions

View File

@@ -8,7 +8,7 @@
"build": "webpack --config script/webpack.release.js && shx rm stringifyWorker.js.map",
"dev": "webpack-dev-server --config script/webpack.dev.js --host 0.0.0.0",
"test": "karma start && remap-istanbul -i coverage/coverage-final.json -o coverage/coverage-remapped.json -t json && node script/coverage && shx rm src/index.js.map",
"format": "prettier *.js eustia/*.js src/**/*.{js,scss,css} script/*.js test/*.{js} --write",
"format": "prettier *.js eustia/*.js src/**/*.{js,scss,css} script/*.js test/*.{js,html} --write",
"lint": "eslint src/**/*.js",
"lint:fix": "npm run lint -- --fix",
"setup": "node script/cpTestLib",

View File

@@ -1,17 +1,22 @@
<!doctype html>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<head>
<meta charset="UTF-8" />
<meta
name="viewport"
content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"
/>
<title>Console</title>
<link rel="stylesheet" href="lib/jasmine.css">
<link rel="stylesheet" href="lib/jasmine.css" />
<script src="lib/jquery.js"></script>
<script src="lib/jasmine.js"></script>
<script src="lib/jasmine-html.js"></script>
<script src="assets/eruda.js"></script>
<script src="boot.js"></script>
</head>
<body>
<script>boot('console');</script>
</body>
</head>
<body>
<script>
boot('console')
</script>
</body>
</html>

View File

@@ -103,9 +103,7 @@ describe('console', function() {
it('style', function() {
tool.log('%cblue%cgreen', 'color:blue', 'color:green')
expect($(log(0))).toContainText(
'bluegreen'
)
expect($(log(0))).toContainText('bluegreen')
})
it('Repeat log', function() {

View File

@@ -1,17 +1,22 @@
<!doctype html>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<head>
<meta charset="UTF-8" />
<meta
name="viewport"
content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"
/>
<title>Elements</title>
<link rel="stylesheet" href="lib/jasmine.css">
<link rel="stylesheet" href="lib/jasmine.css" />
<script src="lib/jquery.js"></script>
<script src="lib/jasmine.js"></script>
<script src="lib/jasmine-html.js"></script>
<script src="assets/eruda.js"></script>
<script src="boot.js"></script>
</head>
<body>
<script>boot('elements');</script>
</body>
</head>
<body>
<script>
boot('elements')
</script>
</body>
</html>

View File

@@ -1,17 +1,22 @@
<!doctype html>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<head>
<meta charset="UTF-8" />
<meta
name="viewport"
content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"
/>
<title>Features</title>
<link rel="stylesheet" href="lib/jasmine.css">
<link rel="stylesheet" href="lib/jasmine.css" />
<script src="lib/jquery.js"></script>
<script src="lib/jasmine.js"></script>
<script src="lib/jasmine-html.js"></script>
<script src="assets/eruda.js"></script>
<script src="boot.js"></script>
</head>
<body>
<script>boot('eruda');</script>
</body>
</head>
<body>
<script>
boot('eruda')
</script>
</body>
</html>

View File

@@ -1,15 +1,18 @@
<!doctype html>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<head>
<meta charset="UTF-8" />
<meta
name="viewport"
content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"
/>
<title>Eruda Test Page</title>
<link rel="stylesheet" href="style.css">
<link rel="stylesheet" href="style.css" />
<script src="assets/eruda.js"></script>
</head>
<body>
<header>ERUDA TEST PAGE</header>
<nav id="test-list">
</head>
<body>
<header>ERUDA TEST PAGE</header>
<nav id="test-list">
<ul>
<li>
<a href="eruda.html">eruda</a>
@@ -42,25 +45,26 @@
<a href="manual.html">manual</a>
</li>
</ul>
</nav>
<script>
(function () {
let el = document.createElement('div');
document.body.appendChild(el);
setTimeout(function () {
try
{
</nav>
<script>
;(function() {
let el = document.createElement('div')
document.body.appendChild(el)
setTimeout(function() {
try {
eruda.init({
container: el,
useShadowDom: false
});
} catch (e)
{
alert(e);
})
} catch (e) {
alert(e)
}
eruda.show().get().config.set('displaySize', 50);
}, 1000);
})();
</script>
</body>
eruda
.show()
.get()
.config.set('displaySize', 50)
}, 1000)
})()
</script>
</body>
</html>

View File

@@ -1,17 +1,22 @@
<!doctype html>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<head>
<meta charset="UTF-8" />
<meta
name="viewport"
content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"
/>
<title>Info</title>
<link rel="stylesheet" href="lib/jasmine.css">
<link rel="stylesheet" href="lib/jasmine.css" />
<script src="lib/jquery.js"></script>
<script src="lib/jasmine.js"></script>
<script src="lib/jasmine-html.js"></script>
<script src="assets/eruda.js"></script>
<script src="boot.js"></script>
</head>
<body>
<script>boot('info');</script>
</body>
</head>
<body>
<script>
boot('info')
</script>
</body>
</html>

View File

@@ -1,16 +1,19 @@
<!doctype html>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<head>
<meta charset="UTF-8" />
<meta
name="viewport"
content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"
/>
<title>Manual</title>
<link rel="stylesheet" href="style.css">
<link rel="stylesheet" href="style.css" />
<script src="assets/eruda.js"></script>
<script src="util.js"></script>
</head>
<body id="body" class="test">
<header>Manual Test</header>
<nav>
</head>
<body id="body" class="test">
<header>Manual Test</header>
<nav>
<ul>
<li>
<a href="#" id="issue17">#17</a>
@@ -49,139 +52,134 @@
<a href="#" id="log-1000">Log 1000</a>
</li>
</ul>
</nav>
<script>
function addClickEvent(id, listener)
{
document.getElementById(id).addEventListener('click', function (e)
{
e.preventDefault();
listener();
}, false);
</nav>
<script>
function addClickEvent(id, listener) {
document.getElementById(id).addEventListener(
'click',
function(e) {
e.preventDefault()
listener()
},
false
)
}
addClickEvent('issue17', function ()
{
let B = function () {};
let A = function () { this._data = 'eruda' };
A.prototype = Object.create(B.prototype);
addClickEvent('issue17', function() {
let B = function() {}
let A = function() {
this._data = 'eruda'
}
A.prototype = Object.create(B.prototype)
Object.defineProperty(A.prototype, 'data', {
get: function () { return this._data }
});
let a = new A();
console.log(a);
});
addClickEvent('plugin', function ()
{
eruda.add({name: 'test'});
eruda.add(function (eruda)
{
get: function() {
return this._data
}
})
let a = new A()
console.log(a)
})
addClickEvent('plugin', function() {
eruda.add({ name: 'test' })
eruda.add(function(eruda) {
return {
name: 'test2',
init: function ($el)
{
this._$el = $el;
this._$el.html('This is the new plugin');
init: function($el) {
this._$el = $el
this._$el.html('This is the new plugin')
}
};
});
let Tool = eruda.Tool;
eruda.add(new (Tool.extend({
name: 'test3',
init: function ($el)
{
this.callSuper(Tool, 'init', arguments);
this._$el.html('This is another new plugin');
}
})));
});
addClickEvent('issue29', function ()
{
new Promise(function (resolve, reject)
{
resolve();
}).then(function (res)
{
let a = res.a;
})
});
addClickEvent('issue31', function ()
{
addEventListener('resize', function () {});
});
addClickEvent('issue33', function ()
{
util.evalCss(':root {--test: 10px;}');
});
addClickEvent('trigger-error', function ()
{
triggerError();
});
addClickEvent('big-array', function ()
{
let arr = [];
for (let i = 0; i < 10000; i++) {
arr.push(i);
let Tool = eruda.Tool
eruda.add(
new (Tool.extend({
name: 'test3',
init: function($el) {
this.callSuper(Tool, 'init', arguments)
this._$el.html('This is another new plugin')
}
console.log(arr);
});
addClickEvent('override-style', function ()
{
util.evalCss('.eruda-nav-bar {background: red !important;}');
});
addClickEvent('stringify-timing', function () {
}))()
)
})
addClickEvent('issue29', function() {
new Promise(function(resolve, reject) {
resolve()
}).then(function(res) {
let a = res.a
})
})
addClickEvent('issue31', function() {
addEventListener('resize', function() {})
})
addClickEvent('issue33', function() {
util.evalCss(':root {--test: 10px;}')
})
addClickEvent('trigger-error', function() {
triggerError()
})
addClickEvent('big-array', function() {
let arr = []
for (let i = 0; i < 10000; i++) {
arr.push(i)
}
console.log(arr)
})
addClickEvent('override-style', function() {
util.evalCss('.eruda-nav-bar {background: red !important;}')
})
addClickEvent('stringify-timing', function() {
console.time('stringify window')
eruda.util.stringifyAll(window)
console.timeEnd('stringify window')
});
})
addClickEvent('log', () => {
console.clear();
console.log('log');
console.warn('warn');
console.error(Error('test'));
console.info('info');
console.debug('debug');
console.dir(document.createElement('div'));
console.time('test');
console.timeEnd('test');
console.count('eruda');
console.count('eruda');
console.assert(true, 'assert msg');
var site1 = { name: 'Runoob', site: 'www.runoob.com' };
var site2 = { name: 'Google', site: 'www.google.com' };
var site3 = { name: 'Taobao', site: 'www.taobao.com' };
console.table([site1, site2, site3], ['site']);
console.log('%c Oh my heavens!', 'background: #222; color: #bada55');
console.log('This is the outer level');
console.group();
console.log('Level 2');
console.group();
console.log('Level 3');
console.warn('More of level 3');
console.groupEnd();
console.log('Back to level 2');
console.groupEnd();
console.log('Back to the outer level');
console.log(navigator);
console.log(location);
console.log(performance);
var arr = [];
for (var i = 0; i < 10000; i++) arr.push(i);
console.log(arr);
});
console.clear()
console.log('log')
console.warn('warn')
console.error(Error('test'))
console.info('info')
console.debug('debug')
console.dir(document.createElement('div'))
console.time('test')
console.timeEnd('test')
console.count('eruda')
console.count('eruda')
console.assert(true, 'assert msg')
var site1 = { name: 'Runoob', site: 'www.runoob.com' }
var site2 = { name: 'Google', site: 'www.google.com' }
var site3 = { name: 'Taobao', site: 'www.taobao.com' }
console.table([site1, site2, site3], ['site'])
console.log('%c Oh my heavens!', 'background: #222; color: #bada55')
console.log('This is the outer level')
console.group()
console.log('Level 2')
console.group()
console.log('Level 3')
console.warn('More of level 3')
console.groupEnd()
console.log('Back to level 2')
console.groupEnd()
console.log('Back to the outer level')
console.log(navigator)
console.log(location)
console.log(performance)
var arr = []
for (var i = 0; i < 10000; i++) arr.push(i)
console.log(arr)
})
addClickEvent('log-10000', () => {
for (let i = 0; i < 10000; i++) {
console.log(location, i);
console.log(location, i)
}
});
})
addClickEvent('log-1000', () => {
for (let i = 0; i < 1000; i++) {
console.log(location, i);
console.log(location, i)
}
});
</script>
<script>
eruda.init();
eruda.show();
</script>
</body>
})
</script>
<script>
eruda.init()
eruda.show()
</script>
</body>
</html>

View File

@@ -1,18 +1,23 @@
<!doctype html>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<head>
<meta charset="UTF-8" />
<meta
name="viewport"
content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"
/>
<title>Network</title>
<link rel="stylesheet" href="lib/jasmine.css">
<link rel="stylesheet" href="lib/jasmine.css" />
<script src="lib/jquery.js"></script>
<script src="lib/jasmine.js"></script>
<script src="lib/jasmine-html.js"></script>
<script src="assets/eruda.js"></script>
<script src="boot.js"></script>
<script src="util.js"></script>
</head>
<body>
<script>boot('network');</script>
</body>
</head>
<body>
<script>
boot('network')
</script>
</body>
</html>

View File

@@ -1,18 +1,23 @@
<!doctype html>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<head>
<meta charset="UTF-8" />
<meta
name="viewport"
content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"
/>
<title>Resources</title>
<link rel="stylesheet" href="lib/jasmine.css">
<link rel="stylesheet" href="lib/jasmine.css" />
<script src="lib/jquery.js"></script>
<script src="lib/jasmine.js"></script>
<script src="lib/jasmine-html.js"></script>
<script src="assets/eruda.js"></script>
<script src="boot.js"></script>
<script src="util.js"></script>
</head>
<body>
<script>boot('resources');</script>
</body>
</head>
<body>
<script>
boot('resources')
</script>
</body>
</html>

View File

@@ -1,17 +1,22 @@
<!doctype html>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<head>
<meta charset="UTF-8" />
<meta
name="viewport"
content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"
/>
<title>Settings</title>
<link rel="stylesheet" href="lib/jasmine.css">
<link rel="stylesheet" href="lib/jasmine.css" />
<script src="lib/jquery.js"></script>
<script src="lib/jasmine.js"></script>
<script src="lib/jasmine-html.js"></script>
<script src="assets/eruda.js"></script>
<script src="boot.js"></script>
</head>
<body>
<script>boot('settings');</script>
</body>
</head>
<body>
<script>
boot('settings')
</script>
</body>
</html>

View File

@@ -68,7 +68,7 @@ describe('settings', function() {
expect(cfg.get('testColor')).toBe('rgb(0, 0, 0)')
})
it('remove', function () {
it('remove', function() {
let text = 'Test Switch'
tool.switch(cfg, 'testSwitch', text)
expect($tool.find('.eruda-switch')).toContainText(text)

View File

@@ -1,17 +1,22 @@
<!doctype html>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<head>
<meta charset="UTF-8" />
<meta
name="viewport"
content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"
/>
<title>Snippets</title>
<link rel="stylesheet" href="lib/jasmine.css">
<link rel="stylesheet" href="lib/jasmine.css" />
<script src="lib/jquery.js"></script>
<script src="lib/jasmine.js"></script>
<script src="lib/jasmine-html.js"></script>
<script src="assets/eruda.js"></script>
<script src="boot.js"></script>
</head>
<body>
<script>boot('snippets');</script>
</body>
</head>
<body>
<script>
boot('snippets')
</script>
</body>
</html>

View File

@@ -1,17 +1,22 @@
<!doctype html>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<head>
<meta charset="UTF-8" />
<meta
name="viewport"
content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"
/>
<title>Sources</title>
<link rel="stylesheet" href="lib/jasmine.css">
<link rel="stylesheet" href="lib/jasmine.css" />
<script src="lib/jquery.js"></script>
<script src="lib/jasmine.js"></script>
<script src="lib/jasmine-html.js"></script>
<script src="assets/eruda.js"></script>
<script src="boot.js"></script>
</head>
<body>
<script>boot('sources');</script>
</body>
</head>
<body>
<script>
boot('sources')
</script>
</body>
</html>

View File

@@ -9,9 +9,7 @@ describe('sources', function() {
describe('js', function() {
it('highlight', function() {
tool.set('js', '/* test */')
expect($tool.find('.eruda-content')).toContainHtml(
'/* test */'
)
expect($tool.find('.eruda-content')).toContainHtml('/* test */')
})
})
})