Use let instead of var
This commit is contained in:
@@ -96,7 +96,7 @@ under html root element.
|
|||||||
For more information, please check the [documentation](doc/API.md).
|
For more information, please check the [documentation](doc/API.md).
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
var el = document.createElement('div');
|
let el = document.createElement('div');
|
||||||
document.body.appendChild(el);
|
document.body.appendChild(el);
|
||||||
|
|
||||||
eruda.init({
|
eruda.init({
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ Initialize eruda.
|
|||||||
|useShadowDom=true|boolean |Use shadow dom for css encapsulation |
|
|useShadowDom=true|boolean |Use shadow dom for css encapsulation |
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
var el = document.createElement('div');
|
let el = document.createElement('div');
|
||||||
document.body.appendChild(el);
|
document.body.appendChild(el);
|
||||||
|
|
||||||
eruda.init({
|
eruda.init({
|
||||||
@@ -60,7 +60,7 @@ eruda.position(); // -> {x: 20, y: 20}
|
|||||||
Get tool, eg. console, elements panels.
|
Get tool, eg. console, elements panels.
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
var console = eruda.get('console');
|
let console = eruda.get('console');
|
||||||
console.log('eruda');
|
console.log('eruda');
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ Js文件对于移动端来说略重(gzip后大概100kb)。建议通过url参
|
|||||||
* tool:指定要初始化哪些面板,默认加载所有。
|
* tool:指定要初始化哪些面板,默认加载所有。
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
var el = document.createElement('div');
|
let el = document.createElement('div');
|
||||||
document.body.appendChild(el);
|
document.body.appendChild(el);
|
||||||
|
|
||||||
eruda.init({
|
eruda.init({
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ Display console logs. Implementation detail follows the [console api spec](https
|
|||||||
|maxLogNum |string |Max log number |
|
|maxLogNum |string |Max log number |
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
var console = eruda.get('console');
|
let console = eruda.get('console');
|
||||||
console.config.set('catchGlobalErr', true);
|
console.config.set('catchGlobalErr', true);
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -33,7 +33,7 @@ All these methods can be used in the same way as window.console object.
|
|||||||
Note: When called, a corresponding event is triggered.
|
Note: When called, a corresponding event is triggered.
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
var console = eruda.get('console');
|
let console = eruda.get('console');
|
||||||
console.log('eruda is a console for %s.', 'mobile browsers');
|
console.log('eruda is a console for %s.', 'mobile browsers');
|
||||||
console.table([{test: 1}, {test: 2}, {test2: 3}], 'test');
|
console.table([{test: 1}, {test: 2}, {test2: 3}], 'test');
|
||||||
console.error(new Error('eruda'));
|
console.error(new Error('eruda'));
|
||||||
@@ -295,7 +295,7 @@ Add color to select a color.
|
|||||||
Add a separator.
|
Add a separator.
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
var cfg = eruda.util.createCfg('test');
|
let cfg = eruda.util.createCfg('test');
|
||||||
|
|
||||||
cfg.set(eruda.util.defaults(cfg.get(), {
|
cfg.set(eruda.util.defaults(cfg.get(), {
|
||||||
testBool: true,
|
testBool: true,
|
||||||
|
|||||||
@@ -3,13 +3,13 @@
|
|||||||
|
|
||||||
_('toStr each filter')
|
_('toStr each filter')
|
||||||
|
|
||||||
var styleList = [],
|
let styleList = []
|
||||||
scale = 1
|
let scale = 1
|
||||||
|
|
||||||
function exports(css, container) {
|
function exports(css, container) {
|
||||||
css = toStr(css)
|
css = toStr(css)
|
||||||
|
|
||||||
for (var i = 0, len = styleList.length; i < len; i++) {
|
for (let i = 0, len = styleList.length; i < len; i++) {
|
||||||
if (styleList[i].css === css) return
|
if (styleList[i].css === css) return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
_('last trim')
|
_('last trim')
|
||||||
|
|
||||||
function exports(url) {
|
function exports(url) {
|
||||||
var ret = last(url.split('/'))
|
let ret = last(url.split('/'))
|
||||||
|
|
||||||
if (ret.indexOf('?') > -1) ret = trim(ret.split('?')[0])
|
if (ret.indexOf('?') > -1) ret = trim(ret.split('?')[0])
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
_('startWith')
|
_('startWith')
|
||||||
|
|
||||||
var origin = window.location.origin
|
let origin = window.location.origin
|
||||||
|
|
||||||
function exports(url) {
|
function exports(url) {
|
||||||
return !startWith(url, origin)
|
return !startWith(url, origin)
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
function exports(el) {
|
function exports(el) {
|
||||||
var parentNode = el.parentNode
|
let parentNode = el.parentNode
|
||||||
|
|
||||||
if (!parentNode) return false
|
if (!parentNode) return false
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ _('isUndef memStorage')
|
|||||||
function exports(type, memReplacement) {
|
function exports(type, memReplacement) {
|
||||||
if (isUndef(memReplacement)) memReplacement = true
|
if (isUndef(memReplacement)) memReplacement = true
|
||||||
|
|
||||||
var ret
|
let ret
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 'local':
|
case 'local':
|
||||||
@@ -19,9 +19,9 @@ function exports(type, memReplacement) {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
// Safari private browsing
|
// Safari private browsing
|
||||||
var x = 'test-localStorage-' + Date.now()
|
let x = 'test-localStorage-' + Date.now()
|
||||||
ret.setItem(x, x)
|
ret.setItem(x, x)
|
||||||
var y = ret.getItem(x)
|
let y = ret.getItem(x)
|
||||||
ret.removeItem(x)
|
ret.removeItem(x)
|
||||||
if (y !== x) throw new Error()
|
if (y !== x) throw new Error()
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
var webpackCfg = require('./script/webpack.dev')
|
const webpackCfg = require('./script/webpack.dev')
|
||||||
webpackCfg.devtool = 'inline-source-map'
|
webpackCfg.devtool = 'inline-source-map'
|
||||||
|
|
||||||
module.exports = function(config) {
|
module.exports = function(config) {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
module.exports = function(config) {
|
module.exports = function(config) {
|
||||||
var customLaunchers = {
|
let customLaunchers = {
|
||||||
sl_ios_safari_8: {
|
sl_ios_safari_8: {
|
||||||
base: 'SauceLabs',
|
base: 'SauceLabs',
|
||||||
browserName: 'iphone',
|
browserName: 'iphone',
|
||||||
|
|||||||
@@ -1,22 +1,22 @@
|
|||||||
var path = require('path'),
|
const path = require('path')
|
||||||
util = require('./util'),
|
const util = require('./util')
|
||||||
istanbul = require('istanbul')
|
const istanbul = require('istanbul')
|
||||||
|
|
||||||
var collector = new istanbul.Collector(),
|
let collector = new istanbul.Collector()
|
||||||
reporter = new istanbul.Reporter()
|
let reporter = new istanbul.Reporter()
|
||||||
|
|
||||||
var remappedJson = require('../coverage/coverage-remapped.json')
|
let remappedJson = require('../coverage/coverage-remapped.json')
|
||||||
|
|
||||||
var coverage = util.reduce(
|
let coverage = util.reduce(
|
||||||
util.keys(remappedJson),
|
util.keys(remappedJson),
|
||||||
function(result, source) {
|
function(result, source) {
|
||||||
if (isSrc()) {
|
if (isSrc()) {
|
||||||
var correctPath = source.replace(
|
let correctPath = source.replace(
|
||||||
path.resolve(__dirname, '../src'),
|
path.resolve(__dirname, '../src'),
|
||||||
path.resolve(__dirname, '../')
|
path.resolve(__dirname, '../')
|
||||||
)
|
)
|
||||||
|
|
||||||
var val = remappedJson[source]
|
let val = remappedJson[source]
|
||||||
val.path = correctPath
|
val.path = correctPath
|
||||||
result[correctPath] = val
|
result[correctPath] = val
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
var copy = require('copy'),
|
const copy = require('copy')
|
||||||
path = require('path'),
|
const path = require('path')
|
||||||
util = require('./util')
|
const util = require('./util')
|
||||||
|
|
||||||
util.mkdir(path.resolve(__dirname, '../test/lib'), function(err) {
|
util.mkdir(path.resolve(__dirname, '../test/lib'), function(err) {
|
||||||
if (err) return console.log(err)
|
if (err) return console.log(err)
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
var autoprefixer = require('autoprefixer'),
|
const autoprefixer = require('autoprefixer')
|
||||||
classPrefix = require('postcss-class-prefix'),
|
const classPrefix = require('postcss-class-prefix')
|
||||||
webpack = require('webpack'),
|
const webpack = require('webpack')
|
||||||
pkg = require('../package.json'),
|
const pkg = require('../package.json')
|
||||||
path = require('path')
|
const path = require('path')
|
||||||
|
|
||||||
process.traceDeprecation = true
|
process.traceDeprecation = true
|
||||||
|
|
||||||
var nodeModDir = path.resolve('./node_modules/') + '/',
|
let nodeModDir = path.resolve('./node_modules/') + '/'
|
||||||
banner = pkg.name + ' v' + pkg.version + ' ' + pkg.homepage
|
let banner = pkg.name + ' v' + pkg.version + ' ' + pkg.homepage
|
||||||
|
|
||||||
var postcssLoader = {
|
let postcssLoader = {
|
||||||
loader: 'postcss-loader',
|
loader: 'postcss-loader',
|
||||||
options: {
|
options: {
|
||||||
plugins: [classPrefix('eruda-'), autoprefixer]
|
plugins: [classPrefix('eruda-'), autoprefixer]
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
var webpack = require('webpack')
|
const webpack = require('webpack')
|
||||||
|
|
||||||
exports = require('./webpack.base')
|
exports = require('./webpack.base')
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
var webpack = require('webpack')
|
const webpack = require('webpack')
|
||||||
|
|
||||||
exports = require('./webpack.base')
|
exports = require('./webpack.base')
|
||||||
|
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ let callbacks = {},
|
|||||||
if (isWorkerSupported) {
|
if (isWorkerSupported) {
|
||||||
tryIt(function() {
|
tryIt(function() {
|
||||||
/* Some browsers like uc mobile doesn't destroy worker properly after refreshing.
|
/* Some browsers like uc mobile doesn't destroy worker properly after refreshing.
|
||||||
* After a few times of visiting, it reaches the maximum number of workers per site.
|
* After a few times of visiting, it reaches the maximum number of workers per site.
|
||||||
*/
|
*/
|
||||||
worker = new StringifyWorker()
|
worker = new StringifyWorker()
|
||||||
worker.onmessage = function(e) {
|
worker.onmessage = function(e) {
|
||||||
let [id, result] = e.data
|
let [id, result] = e.data
|
||||||
|
|||||||
@@ -287,8 +287,8 @@ class Visitor {
|
|||||||
}
|
}
|
||||||
visit(val) {
|
visit(val) {
|
||||||
/* Add 0 to distinguish stringify generated id from JsonViewer id.
|
/* Add 0 to distinguish stringify generated id from JsonViewer id.
|
||||||
* When used in web worker, they are not calling the same uniqId method, thus result may be repeated.
|
* When used in web worker, they are not calling the same uniqId method, thus result may be repeated.
|
||||||
*/
|
*/
|
||||||
let id = uniqId('erudaJson0')
|
let id = uniqId('erudaJson0')
|
||||||
|
|
||||||
this._visited.push({ id, val, abstract: {} })
|
this._visited.push({ id, val, abstract: {} })
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
function boot(name, cb) {
|
function boot(name, cb) {
|
||||||
// Need a little delay to make sure width and height of webpack dev server iframe are initialized.
|
// Need a little delay to make sure width and height of webpack dev server iframe are initialized.
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
var options = {
|
let options = {
|
||||||
useShadowDom: false
|
useShadowDom: false
|
||||||
}
|
}
|
||||||
if (name) {
|
if (name) {
|
||||||
@@ -34,7 +34,7 @@ function boot(name, cb) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function loadJs(src, cb) {
|
function loadJs(src, cb) {
|
||||||
var script = document.createElement('script')
|
let script = document.createElement('script')
|
||||||
script.src = src + '.js'
|
script.src = src + '.js'
|
||||||
script.onload = cb
|
script.onload = cb
|
||||||
document.body.appendChild(script)
|
document.body.appendChild(script)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
describe('console', function() {
|
describe('console', function() {
|
||||||
var tool = eruda.get('console'),
|
let tool = eruda.get('console')
|
||||||
$tool = $('.eruda-console')
|
let $tool = $('.eruda-console')
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
eruda.show('console')
|
eruda.show('console')
|
||||||
@@ -8,7 +8,7 @@ describe('console', function() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('string', function() {
|
it('string', function() {
|
||||||
var text = '<span>This is a log</span>'
|
let text = '<span>This is a log</span>'
|
||||||
|
|
||||||
tool.log(text)
|
tool.log(text)
|
||||||
expect($tool.find('.eruda-log')).toContainText(text)
|
expect($tool.find('.eruda-log')).toContainText(text)
|
||||||
@@ -26,7 +26,7 @@ describe('console', function() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('basic object', function() {
|
it('basic object', function() {
|
||||||
var obj = { a: 1 }
|
let obj = { a: 1 }
|
||||||
|
|
||||||
tool.log(obj)
|
tool.log(obj)
|
||||||
expect($tool.find('.eruda-log')).toContainText('Object { a: 1 }')
|
expect($tool.find('.eruda-log')).toContainText('Object { a: 1 }')
|
||||||
@@ -97,8 +97,8 @@ describe('console', function() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('Repeat log', function() {
|
it('Repeat log', function() {
|
||||||
for (var i = 0; i < 10; i++) tool.log(1)
|
for (let i = 0; i < 10; i++) tool.log(1)
|
||||||
var $log = $tool.find('.eruda-log-item')
|
let $log = $tool.find('.eruda-log-item')
|
||||||
expect($log).toHaveLength(1)
|
expect($log).toHaveLength(1)
|
||||||
expect($log.find('.eruda-count')).toContainText('10')
|
expect($log.find('.eruda-count')).toContainText('10')
|
||||||
})
|
})
|
||||||
@@ -136,7 +136,7 @@ describe('console', function() {
|
|||||||
return log.type !== 'error'
|
return log.type !== 'error'
|
||||||
})
|
})
|
||||||
|
|
||||||
var obj = {}
|
let obj = {}
|
||||||
Object.defineProperty(obj, 'a', {
|
Object.defineProperty(obj, 'a', {
|
||||||
get: function() {
|
get: function() {
|
||||||
tool.error('deprecated')
|
tool.error('deprecated')
|
||||||
@@ -191,11 +191,11 @@ describe('console', function() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
describe('config', function() {
|
describe('config', function() {
|
||||||
var config = tool.config
|
let config = tool.config
|
||||||
|
|
||||||
it('max number', function() {
|
it('max number', function() {
|
||||||
config.set('maxLogNum', '10')
|
config.set('maxLogNum', '10')
|
||||||
for (var i = 0; i < 20; i++) tool.log(i)
|
for (let i = 0; i < 20; i++) tool.log(i)
|
||||||
expect($tool.find('.eruda-log-item')).toHaveLength(10)
|
expect($tool.find('.eruda-log-item')).toHaveLength(10)
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -253,7 +253,7 @@ describe('console', function() {
|
|||||||
|
|
||||||
describe('events', function() {
|
describe('events', function() {
|
||||||
it('log', function() {
|
it('log', function() {
|
||||||
var sum = 0
|
let sum = 0
|
||||||
function add(num) {
|
function add(num) {
|
||||||
sum += num
|
sum += num
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
describe('elements', function() {
|
describe('elements', function() {
|
||||||
var tool = eruda.get('elements'),
|
let tool = eruda.get('elements')
|
||||||
$tool = $('.eruda-elements')
|
let $tool = $('.eruda-elements')
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
eruda.show('elements')
|
eruda.show('elements')
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ describe('devTools', function() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('init', function() {
|
it('init', function() {
|
||||||
var container = document.createElement('div')
|
let container = document.createElement('div')
|
||||||
container.id = 'eruda'
|
container.id = 'eruda'
|
||||||
document.body.appendChild(container)
|
document.body.appendChild(container)
|
||||||
|
|
||||||
@@ -17,7 +17,7 @@ describe('devTools', function() {
|
|||||||
useShadowDom: false
|
useShadowDom: false
|
||||||
})
|
})
|
||||||
|
|
||||||
var $eruda = $('#eruda')
|
let $eruda = $('#eruda')
|
||||||
expect($eruda.find('.eruda-dev-tools')).toHaveLength(1)
|
expect($eruda.find('.eruda-dev-tools')).toHaveLength(1)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@@ -36,7 +36,7 @@ describe('devTools', function() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('show', function() {
|
it('show', function() {
|
||||||
var $tool = $('.eruda-test')
|
let $tool = $('.eruda-test')
|
||||||
expect($tool).toBeHidden()
|
expect($tool).toBeHidden()
|
||||||
eruda.show('test')
|
eruda.show('test')
|
||||||
expect($tool).toHaveCss({ display: 'block' })
|
expect($tool).toHaveCss({ display: 'block' })
|
||||||
|
|||||||
@@ -45,7 +45,7 @@
|
|||||||
</nav>
|
</nav>
|
||||||
<script>
|
<script>
|
||||||
(function () {
|
(function () {
|
||||||
var el = document.createElement('div');
|
let el = document.createElement('div');
|
||||||
document.body.appendChild(el);
|
document.body.appendChild(el);
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
try
|
try
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
describe('info', function() {
|
describe('info', function() {
|
||||||
var tool = eruda.get('info'),
|
let tool = eruda.get('info')
|
||||||
$tool = $('.eruda-info')
|
let $tool = $('.eruda-info')
|
||||||
|
|
||||||
describe('default', function() {
|
describe('default', function() {
|
||||||
it('location', function() {
|
it('location', function() {
|
||||||
|
|||||||
@@ -49,13 +49,13 @@
|
|||||||
}
|
}
|
||||||
addClickEvent('issue17', function ()
|
addClickEvent('issue17', function ()
|
||||||
{
|
{
|
||||||
var B = function () {};
|
let B = function () {};
|
||||||
var A = function () { this._data = 'eruda' };
|
let A = function () { 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 }
|
||||||
});
|
});
|
||||||
var a = new A();
|
let a = new A();
|
||||||
console.log(a);
|
console.log(a);
|
||||||
});
|
});
|
||||||
addClickEvent('plugin', function ()
|
addClickEvent('plugin', function ()
|
||||||
@@ -72,7 +72,7 @@
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
var Tool = eruda.Tool;
|
let Tool = eruda.Tool;
|
||||||
eruda.add(new (Tool.extend({
|
eruda.add(new (Tool.extend({
|
||||||
name: 'test3',
|
name: 'test3',
|
||||||
init: function ($el)
|
init: function ($el)
|
||||||
@@ -89,7 +89,7 @@
|
|||||||
resolve();
|
resolve();
|
||||||
}).then(function (res)
|
}).then(function (res)
|
||||||
{
|
{
|
||||||
var a = res.a;
|
let a = res.a;
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
addClickEvent('issue31', function ()
|
addClickEvent('issue31', function ()
|
||||||
@@ -106,8 +106,8 @@
|
|||||||
});
|
});
|
||||||
addClickEvent('big-array', function ()
|
addClickEvent('big-array', function ()
|
||||||
{
|
{
|
||||||
var arr = [];
|
let arr = [];
|
||||||
for (var i = 0; i < 10000; i++) {
|
for (let i = 0; i < 10000; i++) {
|
||||||
arr.push(i);
|
arr.push(i);
|
||||||
}
|
}
|
||||||
console.log(arr);
|
console.log(arr);
|
||||||
|
|||||||
@@ -1,7 +1,4 @@
|
|||||||
describe('network', function() {
|
describe('network', function() {
|
||||||
var tool = eruda.get('network'),
|
|
||||||
$tool = $('.eruda-network')
|
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
eruda.show('network')
|
eruda.show('network')
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
describe('resources', function() {
|
describe('resources', function() {
|
||||||
var tool = eruda.get('resources'),
|
let $tool = $('.eruda-resources')
|
||||||
$tool = $('.eruda-resources')
|
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
eruda.show('resources')
|
eruda.show('resources')
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
describe('settings', function() {
|
describe('settings', function() {
|
||||||
var tool = eruda.get('settings'),
|
let tool = eruda.get('settings')
|
||||||
$tool = $('.eruda-settings')
|
let $tool = $('.eruda-settings')
|
||||||
|
|
||||||
var cfg = eruda.config.create('eruda-test')
|
let cfg = eruda.config.create('eruda-test')
|
||||||
cfg.set({
|
cfg.set({
|
||||||
testSwitch: false,
|
testSwitch: false,
|
||||||
testSelect: '1',
|
testSelect: '1',
|
||||||
@@ -15,7 +15,7 @@ describe('settings', function() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('switch', function() {
|
it('switch', function() {
|
||||||
var 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)
|
||||||
@@ -29,10 +29,10 @@ describe('settings', function() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('select', function() {
|
it('select', function() {
|
||||||
var text = 'Test Select'
|
let text = 'Test Select'
|
||||||
|
|
||||||
tool.select(cfg, 'testSelect', text, ['1', '2', '3'])
|
tool.select(cfg, 'testSelect', text, ['1', '2', '3'])
|
||||||
var $el = $tool.find('.eruda-select')
|
let $el = $tool.find('.eruda-select')
|
||||||
expect($el.find('ul li').length).toEqual(3)
|
expect($el.find('ul li').length).toEqual(3)
|
||||||
expect($el.find('.eruda-head')).toContainText(text)
|
expect($el.find('.eruda-head')).toContainText(text)
|
||||||
expect($el.find('.eruda-val')).toContainText('1')
|
expect($el.find('.eruda-val')).toContainText('1')
|
||||||
@@ -44,20 +44,20 @@ describe('settings', function() {
|
|||||||
expect(cfg.get('testSelect')).toBe('2')
|
expect(cfg.get('testSelect')).toBe('2')
|
||||||
})
|
})
|
||||||
it('range', function() {
|
it('range', function() {
|
||||||
var text = 'Test Range'
|
let text = 'Test Range'
|
||||||
|
|
||||||
tool.range(cfg, 'testRange', text, { min: 0, max: 1, step: 0.1 })
|
tool.range(cfg, 'testRange', text, { min: 0, max: 1, step: 0.1 })
|
||||||
var $el = $tool.find('.eruda-range')
|
let $el = $tool.find('.eruda-range')
|
||||||
expect($el.find('.eruda-head')).toContainText(text)
|
expect($el.find('.eruda-head')).toContainText(text)
|
||||||
expect($el.find('input').length).toEqual(1)
|
expect($el.find('input').length).toEqual(1)
|
||||||
$el.find('.eruda-head').click()
|
$el.find('.eruda-head').click()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('color', function() {
|
it('color', function() {
|
||||||
var text = 'Test Color'
|
let text = 'Test Color'
|
||||||
|
|
||||||
tool.color(cfg, 'testColor', text, ['#000', '#fff'])
|
tool.color(cfg, 'testColor', text, ['#000', '#fff'])
|
||||||
var $el = $tool.find('.eruda-color')
|
let $el = $tool.find('.eruda-color')
|
||||||
expect($el.find('.eruda-head')).toContainText(text)
|
expect($el.find('.eruda-head')).toContainText(text)
|
||||||
expect($el.find('ul li').length).toEqual(2)
|
expect($el.find('ul li').length).toEqual(2)
|
||||||
$el.find('.eruda-head').click()
|
$el.find('.eruda-head').click()
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
describe('snippets', function() {
|
describe('snippets', function() {
|
||||||
var tool = eruda.get('snippets'),
|
let tool = eruda.get('snippets')
|
||||||
$tool = $('.eruda-snippets')
|
let $tool = $('.eruda-snippets')
|
||||||
|
|
||||||
describe('default', function() {
|
describe('default', function() {
|
||||||
it('border all', function() {
|
it('border all', function() {
|
||||||
expect($tool.find('.eruda-name').eq(0)).toContainText('Border All')
|
expect($tool.find('.eruda-name').eq(0)).toContainText('Border All')
|
||||||
|
|
||||||
var $body = $('body'),
|
let $body = $('body')
|
||||||
$btn = $tool.find('.eruda-run').eq(0)
|
let $btn = $tool.find('.eruda-run').eq(0)
|
||||||
|
|
||||||
$btn.click()
|
$btn.click()
|
||||||
expect($body).toHaveCss({ outlineWidth: '2px' })
|
expect($body).toHaveCss({ outlineWidth: '2px' })
|
||||||
@@ -26,8 +26,8 @@ describe('snippets', function() {
|
|||||||
it('edit page', function() {
|
it('edit page', function() {
|
||||||
expect($tool.find('.eruda-name').eq(3)).toContainText('Edit Page')
|
expect($tool.find('.eruda-name').eq(3)).toContainText('Edit Page')
|
||||||
|
|
||||||
var $body = $('body'),
|
let $body = $('body')
|
||||||
$btn = $tool.find('.eruda-run').eq(3)
|
let $btn = $tool.find('.eruda-run').eq(3)
|
||||||
|
|
||||||
$btn.click()
|
$btn.click()
|
||||||
expect($body).toHaveAttr('contenteditable', 'true')
|
expect($body).toHaveAttr('contenteditable', 'true')
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
describe('sources', function() {
|
describe('sources', function() {
|
||||||
var tool = eruda.get('sources'),
|
let tool = eruda.get('sources')
|
||||||
$tool = $('.eruda-sources')
|
let $tool = $('.eruda-sources')
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
eruda.show('sources')
|
eruda.show('sources')
|
||||||
|
|||||||
Reference in New Issue
Block a user