From 07404492db075e8aa2f1c96f1087e44888f97598 Mon Sep 17 00:00:00 2001 From: surunzi Date: Mon, 16 Dec 2019 17:55:59 +0800 Subject: [PATCH] style: tests --- package.json | 2 +- test/console.html | 35 +++-- test/console.js | 4 +- test/elements.html | 35 +++-- test/eruda.html | 35 +++-- test/index.html | 134 ++++++++-------- test/info.html | 35 +++-- test/manual.html | 366 ++++++++++++++++++++++---------------------- test/network.html | 37 +++-- test/resources.html | 37 +++-- test/settings.html | 35 +++-- test/settings.js | 4 +- test/snippets.html | 35 +++-- test/sources.html | 35 +++-- test/sources.js | 4 +- 15 files changed, 438 insertions(+), 395 deletions(-) diff --git a/package.json b/package.json index e047fc3..d934d79 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/test/console.html b/test/console.html index 676411e..5ee51d1 100644 --- a/test/console.html +++ b/test/console.html @@ -1,17 +1,22 @@ - + - - - - Console - - - - - - - - - - + + + + Console + + + + + + + + + + diff --git a/test/console.js b/test/console.js index 3b16a54..74966ea 100644 --- a/test/console.js +++ b/test/console.js @@ -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() { diff --git a/test/elements.html b/test/elements.html index 2eb711c..275deb0 100644 --- a/test/elements.html +++ b/test/elements.html @@ -1,17 +1,22 @@ - + - - - - Elements - - - - - - - - - - + + + + Elements + + + + + + + + + + diff --git a/test/eruda.html b/test/eruda.html index bc43777..dd17862 100644 --- a/test/eruda.html +++ b/test/eruda.html @@ -1,17 +1,22 @@ - + - - - - Features - - - - - - - - - - + + + + Features + + + + + + + + + + diff --git a/test/index.html b/test/index.html index 42c3fc1..5e18716 100644 --- a/test/index.html +++ b/test/index.html @@ -1,66 +1,70 @@ - + - - - - Eruda Test Page - - - - -
ERUDA TEST PAGE
- - - - \ No newline at end of file + + + + Eruda Test Page + + + + +
ERUDA TEST PAGE
+ + + + diff --git a/test/info.html b/test/info.html index ded2943..89166f6 100644 --- a/test/info.html +++ b/test/info.html @@ -1,17 +1,22 @@ - + - - - - Info - - - - - - - - - - + + + + Info + + + + + + + + + + diff --git a/test/manual.html b/test/manual.html index 1d64a09..bef4bc7 100644 --- a/test/manual.html +++ b/test/manual.html @@ -1,187 +1,185 @@ - + - - - - Manual - - - - - -
Manual Test
- - + + + +
Manual Test
+ + - - + 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) { + return { + name: 'test2', + 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) + } + 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) + }) + addClickEvent('log-10000', () => { + for (let i = 0; i < 10000; i++) { + console.log(location, i) + } + }) + addClickEvent('log-1000', () => { + for (let i = 0; i < 1000; i++) { + console.log(location, i) + } + }) + + + diff --git a/test/network.html b/test/network.html index 8fc1843..5adbffc 100644 --- a/test/network.html +++ b/test/network.html @@ -1,18 +1,23 @@ - + - - - - Network - - - - - - - - - - - + + + + Network + + + + + + + + + + + diff --git a/test/resources.html b/test/resources.html index cf7337f..a6b15a7 100644 --- a/test/resources.html +++ b/test/resources.html @@ -1,18 +1,23 @@ - + - - - - Resources - - - - - - - - - - - + + + + Resources + + + + + + + + + + + diff --git a/test/settings.html b/test/settings.html index 549824f..c68dde4 100644 --- a/test/settings.html +++ b/test/settings.html @@ -1,17 +1,22 @@ - + - - - - Settings - - - - - - - - - - + + + + Settings + + + + + + + + + + diff --git a/test/settings.js b/test/settings.js index 3047fe4..a643581 100644 --- a/test/settings.js +++ b/test/settings.js @@ -68,10 +68,10 @@ 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) + expect($tool.find('.eruda-switch')).toContainText(text) tool.remove(cfg, 'testSwitch') expect($tool.find('.eruda-switch')).toHaveLength(0) }) diff --git a/test/snippets.html b/test/snippets.html index 21d4d44..323003f 100644 --- a/test/snippets.html +++ b/test/snippets.html @@ -1,17 +1,22 @@ - + - - - - Snippets - - - - - - - - - - + + + + Snippets + + + + + + + + + + diff --git a/test/sources.html b/test/sources.html index fb4ab18..98adaa3 100644 --- a/test/sources.html +++ b/test/sources.html @@ -1,17 +1,22 @@ - + - - - - Sources - - - - - - - - - - + + + + Sources + + + + + + + + + + diff --git a/test/sources.js b/test/sources.js index 048dde8..f3dc85f 100644 --- a/test/sources.js +++ b/test/sources.js @@ -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 */') }) }) })