1
0
mirror of synced 2025-12-11 00:48:21 +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", "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", "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", "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": "eslint src/**/*.js",
"lint:fix": "npm run lint -- --fix", "lint:fix": "npm run lint -- --fix",
"setup": "node script/cpTestLib", "setup": "node script/cpTestLib",

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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