mirror of
https://github.com/liriliri/eruda.git
synced 2026-03-20 09:38:37 +08:00
Dev: Use prettier to format code
This commit is contained in:
34
test/boot.js
34
test/boot.js
@@ -1,36 +1,31 @@
|
||||
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.
|
||||
setTimeout(function ()
|
||||
{
|
||||
setTimeout(function() {
|
||||
var options = {
|
||||
useShadowDom: false
|
||||
};
|
||||
if (name)
|
||||
{
|
||||
if (name) {
|
||||
options.tool = name === 'settings' ? [] : name;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
eruda.init(options);
|
||||
} catch (e)
|
||||
{
|
||||
} catch (e) {
|
||||
alert(e);
|
||||
}
|
||||
eruda.show().get().config.set('displaySize', 50);
|
||||
eruda
|
||||
.show()
|
||||
.get()
|
||||
.config.set('displaySize', 50);
|
||||
|
||||
cb && cb();
|
||||
|
||||
if (name == null) return;
|
||||
|
||||
loadJs('lib/boot', function ()
|
||||
{
|
||||
loadJs('lib/jasmine-jquery', function ()
|
||||
{
|
||||
loadJs('lib/boot', function() {
|
||||
loadJs('lib/jasmine-jquery', function() {
|
||||
// This is needed to trigger jasmine initialization.
|
||||
loadJs(name, function ()
|
||||
{
|
||||
loadJs(name, function() {
|
||||
window.onload();
|
||||
});
|
||||
});
|
||||
@@ -38,10 +33,9 @@ function boot(name, cb)
|
||||
}, 500);
|
||||
}
|
||||
|
||||
function loadJs(src, cb)
|
||||
{
|
||||
function loadJs(src, cb) {
|
||||
var script = document.createElement('script');
|
||||
script.src = src + '.js';
|
||||
script.onload = cb;
|
||||
document.body.appendChild(script);
|
||||
}
|
||||
}
|
||||
|
||||
171
test/console.js
171
test/console.js
@@ -1,64 +1,56 @@
|
||||
describe('console', function ()
|
||||
{
|
||||
describe('console', function() {
|
||||
var tool = eruda.get('console'),
|
||||
$tool = $('.eruda-console');
|
||||
|
||||
beforeEach(function ()
|
||||
{
|
||||
beforeEach(function() {
|
||||
eruda.show('console');
|
||||
tool.clear();
|
||||
});
|
||||
|
||||
it('string', function ()
|
||||
{
|
||||
it('string', function() {
|
||||
var text = '<span>This is a log</span>';
|
||||
|
||||
tool.log(text);
|
||||
expect($tool.find('.eruda-log')).toContainText(text);
|
||||
});
|
||||
|
||||
it('clear', function ()
|
||||
{
|
||||
it('clear', function() {
|
||||
expect($tool.find('.eruda-logs li')).toHaveLength(0);
|
||||
});
|
||||
|
||||
it('recognize url', function ()
|
||||
{
|
||||
it('recognize url', function() {
|
||||
tool.log('http://liriliri.github.io/eruda/?plugin=fps');
|
||||
expect($tool.find('.eruda-log')).toContainHtml('<a href="http://liriliri.github.io/eruda/?plugin=fps" target="_blank">http://liriliri.github.io/eruda/?plugin=fps</a>');
|
||||
expect($tool.find('.eruda-log')).toContainHtml(
|
||||
'<a href="http://liriliri.github.io/eruda/?plugin=fps" target="_blank">http://liriliri.github.io/eruda/?plugin=fps</a>'
|
||||
);
|
||||
});
|
||||
|
||||
it('basic object', function ()
|
||||
{
|
||||
var obj = {a: 1};
|
||||
it('basic object', function() {
|
||||
var obj = { a: 1 };
|
||||
|
||||
tool.log(obj);
|
||||
expect($tool.find('.eruda-log')).toContainText('Object { a: 1 }');
|
||||
$tool.find('.eruda-log').click();
|
||||
});
|
||||
|
||||
it('html', function ()
|
||||
{
|
||||
it('html', function() {
|
||||
tool.html('<span class="color-blue">Blue</span>');
|
||||
expect($tool.find('.eruda-html')).toContainElement('span.color-blue');
|
||||
});
|
||||
|
||||
it('timing', function ()
|
||||
{
|
||||
it('timing', function() {
|
||||
tool.time('eruda');
|
||||
tool.timeEnd('eruda');
|
||||
expect($tool.find('.eruda-html')).toHaveText(/eruda: [.\d]+ms/);
|
||||
});
|
||||
|
||||
it('error', function ()
|
||||
{
|
||||
it('error', function() {
|
||||
tool.error(new Error('error test'));
|
||||
expect($tool.find('.eruda-error')).toContainElement('.eruda-stack');
|
||||
expect($tool.find('.eruda-error')).toContainText('error test');
|
||||
});
|
||||
|
||||
it('assert', function ()
|
||||
{
|
||||
it('assert', function() {
|
||||
tool.assert(true, 'assert');
|
||||
expect($tool.find('.eruda-log-item')).toHaveLength(0);
|
||||
|
||||
@@ -66,19 +58,18 @@ describe('console', function ()
|
||||
expect($tool.find('.eruda-error')).toHaveLength(1);
|
||||
});
|
||||
|
||||
it('count', function ()
|
||||
{
|
||||
it('count', function() {
|
||||
tool.count('test').clear();
|
||||
tool.count('test');
|
||||
expect($tool.find('.eruda-html')).toContainText('test: 2');
|
||||
});
|
||||
|
||||
describe('substitution', function ()
|
||||
{
|
||||
it('number', function ()
|
||||
{
|
||||
describe('substitution', function() {
|
||||
it('number', function() {
|
||||
tool.log('Eruda is %d', 1.2, 'year old');
|
||||
expect($tool.find('.eruda-log')).toContainText('Eruda is 1 year old');
|
||||
expect($tool.find('.eruda-log')).toContainText(
|
||||
'Eruda is 1 year old'
|
||||
);
|
||||
|
||||
tool.log('%i', 1.2, 'year old');
|
||||
expect($tool.find('.eruda-log')).toContainText('1 year old');
|
||||
@@ -87,29 +78,31 @@ describe('console', function ()
|
||||
expect($tool.find('.eruda-log')).toContainText('1.2 year old');
|
||||
});
|
||||
|
||||
it('string', function ()
|
||||
{
|
||||
it('string', function() {
|
||||
tool.log('My name is %s', 'eruda');
|
||||
expect($tool.find('.eruda-log')).toContainText('My name is eruda');
|
||||
});
|
||||
|
||||
it('object', function ()
|
||||
{
|
||||
tool.log('Object is %O', {a: 1});
|
||||
expect($tool.find('.eruda-log')).toContainText('Object is { a: 1 }');
|
||||
it('object', function() {
|
||||
tool.log('Object is %O', { a: 1 });
|
||||
expect($tool.find('.eruda-log')).toContainText(
|
||||
'Object is { a: 1 }'
|
||||
);
|
||||
|
||||
tool.log('Dom is %o', document.createElement('script'));
|
||||
expect($tool.find('.eruda-log')).toContainText('Dom is <script></script>');
|
||||
expect($tool.find('.eruda-log')).toContainText(
|
||||
'Dom is <script></script>'
|
||||
);
|
||||
});
|
||||
|
||||
it('style', function ()
|
||||
{
|
||||
it('style', function() {
|
||||
tool.log('%cblue%cgreen', 'color:blue', 'color:green');
|
||||
expect($tool.find('.eruda-log')).toContainHtml('<span style="color:blue">blue</span><span style="color:green">green</span>');
|
||||
expect($tool.find('.eruda-log')).toContainHtml(
|
||||
'<span style="color:blue">blue</span><span style="color:green">green</span>'
|
||||
);
|
||||
});
|
||||
|
||||
it('Repeat log', function ()
|
||||
{
|
||||
it('Repeat log', function() {
|
||||
for (var i = 0; i < 10; i++) tool.log(1);
|
||||
var $log = $tool.find('.eruda-log-item');
|
||||
expect($log).toHaveLength(1);
|
||||
@@ -117,48 +110,41 @@ describe('console', function ()
|
||||
});
|
||||
});
|
||||
|
||||
describe('table', function ()
|
||||
{
|
||||
it('wrong args', function ()
|
||||
{
|
||||
describe('table', function() {
|
||||
it('wrong args', function() {
|
||||
tool.table('test');
|
||||
expect($tool.find('.eruda-table')).not.toContainElement('table');
|
||||
});
|
||||
|
||||
it('sort keys', function ()
|
||||
{
|
||||
tool.table([{a: 1}, {d: 2, a: 2}, {c: 1}]);
|
||||
expect($tool.find('.eruda-table thead tr')).toContainHtml('<th>(index)</th><th>a</th><th>c</th><th>d</th>');
|
||||
it('sort keys', function() {
|
||||
tool.table([{ a: 1 }, { d: 2, a: 2 }, { c: 1 }]);
|
||||
expect($tool.find('.eruda-table thead tr')).toContainHtml(
|
||||
'<th>(index)</th><th>a</th><th>c</th><th>d</th>'
|
||||
);
|
||||
});
|
||||
|
||||
it('basic', function ()
|
||||
{
|
||||
tool.table([{test: 1}, {test: 2, test2: 3}]);
|
||||
it('basic', function() {
|
||||
tool.table([{ test: 1 }, { test: 2, test2: 3 }]);
|
||||
expect($tool.find('.eruda-table tbody tr')).toHaveLength(2);
|
||||
expect($tool.find('.eruda-table thead th')).toHaveLength(3);
|
||||
});
|
||||
|
||||
it('filter', function ()
|
||||
{
|
||||
tool.table([{test: 1}, {test: 2, test2: 3}], 'test');
|
||||
it('filter', function() {
|
||||
tool.table([{ test: 1 }, { test: 2, test2: 3 }], 'test');
|
||||
expect($tool.find('.eruda-table thead th')).toHaveLength(2);
|
||||
});
|
||||
});
|
||||
|
||||
describe('filter', function ()
|
||||
{
|
||||
describe('filter', function() {
|
||||
// Test case from https://github.com/liriliri/eruda/issues/14
|
||||
it('function', function ()
|
||||
{
|
||||
tool.filter(function (log)
|
||||
{
|
||||
it('function', function() {
|
||||
tool.filter(function(log) {
|
||||
return log.type !== 'error';
|
||||
});
|
||||
|
||||
var obj = {};
|
||||
Object.defineProperty(obj, 'a', {
|
||||
get: function ()
|
||||
{
|
||||
get: function() {
|
||||
tool.error('deprecated');
|
||||
|
||||
return 1;
|
||||
@@ -170,9 +156,12 @@ describe('console', function ()
|
||||
tool.filter('all');
|
||||
});
|
||||
|
||||
it('all info error warn log', function ()
|
||||
{
|
||||
tool.log('log').info('info').error('error').warn('warn').debug('debug');
|
||||
it('all info error warn log', function() {
|
||||
tool.log('log')
|
||||
.info('info')
|
||||
.error('error')
|
||||
.warn('warn')
|
||||
.debug('debug');
|
||||
expect($tool.find('.eruda-log-item')).toHaveLength(5);
|
||||
|
||||
tool.filter('info');
|
||||
@@ -194,8 +183,7 @@ describe('console', function ()
|
||||
tool.filter('all');
|
||||
});
|
||||
|
||||
it('regex', function ()
|
||||
{
|
||||
it('regex', function() {
|
||||
tool.log('test').log('test2');
|
||||
expect($tool.find('.eruda-log-item')).toHaveLength(2);
|
||||
|
||||
@@ -207,43 +195,38 @@ describe('console', function ()
|
||||
});
|
||||
});
|
||||
|
||||
describe('config', function ()
|
||||
{
|
||||
describe('config', function() {
|
||||
var config = tool.config;
|
||||
|
||||
it('max number', function ()
|
||||
{
|
||||
it('max number', function() {
|
||||
config.set('maxLogNum', '10');
|
||||
for (var i = 0; i < 20; i++) tool.log(i);
|
||||
expect($tool.find('.eruda-log-item')).toHaveLength(10);
|
||||
});
|
||||
|
||||
it('override console', function ()
|
||||
{
|
||||
it('override console', function() {
|
||||
config.set('overrideConsole', true);
|
||||
console.log('test');
|
||||
expect($tool.find('.eruda-log-item')).toContainText('test');
|
||||
});
|
||||
|
||||
it('display extra info', function ()
|
||||
{
|
||||
it('display extra info', function() {
|
||||
config.set('displayExtraInfo', true);
|
||||
tool.log('test');
|
||||
expect($tool.find('.eruda-logs li')).toContainElement('.eruda-header');
|
||||
expect($tool.find('.eruda-logs li')).toContainElement(
|
||||
'.eruda-header'
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('ui', function ()
|
||||
{
|
||||
it('clear', function ()
|
||||
{
|
||||
describe('ui', function() {
|
||||
it('clear', function() {
|
||||
tool.log('test');
|
||||
$('.eruda-clear-console').click();
|
||||
expect($tool.find('.eruda-logs li')).toHaveLength(0);
|
||||
});
|
||||
|
||||
it('filter', function ()
|
||||
{
|
||||
it('filter', function() {
|
||||
tool.log('test');
|
||||
tool.warn('test');
|
||||
expect($tool.find('.eruda-logs li')).toHaveLength(2);
|
||||
@@ -252,24 +235,20 @@ describe('console', function ()
|
||||
$('.eruda-filter[data-filter="all"]').click();
|
||||
});
|
||||
|
||||
it('help', function ()
|
||||
{
|
||||
it('help', function() {
|
||||
$tool.find('.eruda-help').click();
|
||||
expect($tool.find('.eruda-html')).toHaveLength(1);
|
||||
});
|
||||
});
|
||||
|
||||
describe('execute', function ()
|
||||
{
|
||||
it('js', function ()
|
||||
{
|
||||
describe('execute', function() {
|
||||
it('js', function() {
|
||||
$tool.find('textarea').val('1+2');
|
||||
$('.eruda-execute').click();
|
||||
expect($tool.find('.eruda-output')).toContainText('3');
|
||||
});
|
||||
|
||||
it('filter', function ()
|
||||
{
|
||||
it('filter', function() {
|
||||
tool.log('test');
|
||||
tool.log('eruda');
|
||||
expect($tool.find('.eruda-logs li')).toHaveLength(2);
|
||||
@@ -279,12 +258,12 @@ describe('console', function ()
|
||||
});
|
||||
});
|
||||
|
||||
describe('events', function ()
|
||||
{
|
||||
it('log', function ()
|
||||
{
|
||||
describe('events', function() {
|
||||
it('log', function() {
|
||||
var sum = 0;
|
||||
function add(num) { sum += num; }
|
||||
function add(num) {
|
||||
sum += num;
|
||||
}
|
||||
tool.on('log', add);
|
||||
tool.log(5);
|
||||
expect(sum).toBe(5);
|
||||
|
||||
@@ -1,17 +1,13 @@
|
||||
describe('elements', function ()
|
||||
{
|
||||
describe('elements', function() {
|
||||
var tool = eruda.get('elements'),
|
||||
$tool = $('.eruda-elements');
|
||||
|
||||
beforeEach(function ()
|
||||
{
|
||||
beforeEach(function() {
|
||||
eruda.show('elements');
|
||||
});
|
||||
|
||||
describe('api', function ()
|
||||
{
|
||||
it('set element', function ()
|
||||
{
|
||||
describe('api', function() {
|
||||
it('set element', function() {
|
||||
tool.set(document.body);
|
||||
expect($tool.find('.eruda-parent')).toContainText('html');
|
||||
expect($tool.find('.eruda-breadcrumb')).toContainText('body');
|
||||
|
||||
@@ -1,16 +1,12 @@
|
||||
describe('devTools', function ()
|
||||
{
|
||||
describe('init', function ()
|
||||
{
|
||||
it('destroy', function ()
|
||||
{
|
||||
describe('devTools', function() {
|
||||
describe('init', function() {
|
||||
it('destroy', function() {
|
||||
eruda.destroy();
|
||||
|
||||
|
||||
expect($('#eruda')).toHaveLength(0);
|
||||
});
|
||||
|
||||
it('init', function ()
|
||||
{
|
||||
it('init', function() {
|
||||
var container = document.createElement('div');
|
||||
container.id = 'eruda';
|
||||
document.body.appendChild(container);
|
||||
@@ -26,14 +22,11 @@ describe('devTools', function ()
|
||||
});
|
||||
});
|
||||
|
||||
describe('tool', function ()
|
||||
{
|
||||
it('add', function ()
|
||||
{
|
||||
describe('tool', function() {
|
||||
it('add', function() {
|
||||
eruda.add({
|
||||
name: 'test',
|
||||
init: function ($el)
|
||||
{
|
||||
init: function($el) {
|
||||
this._$el = $el;
|
||||
$el.html('Test Plugin');
|
||||
}
|
||||
@@ -42,44 +35,36 @@ describe('devTools', function ()
|
||||
expect($('.eruda-test')).toContainText('Test Plugin');
|
||||
});
|
||||
|
||||
it('show', function ()
|
||||
{
|
||||
it('show', function() {
|
||||
var $tool = $('.eruda-test');
|
||||
expect($tool).toBeHidden();
|
||||
eruda.show('test');
|
||||
expect($tool).toHaveCss({display: 'block'});
|
||||
expect($tool).toHaveCss({ display: 'block' });
|
||||
});
|
||||
|
||||
it('remove', function ()
|
||||
{
|
||||
it('remove', function() {
|
||||
eruda.remove('test');
|
||||
expect($('.eruda-test')).toHaveLength(0);
|
||||
});
|
||||
});
|
||||
|
||||
describe('display', function ()
|
||||
{
|
||||
it('show', function ()
|
||||
{
|
||||
describe('display', function() {
|
||||
it('show', function() {
|
||||
eruda.show();
|
||||
expect($('.eruda-dev-tools')).toHaveCss({display: 'block'});
|
||||
expect($('.eruda-dev-tools')).toHaveCss({ display: 'block' });
|
||||
});
|
||||
|
||||
it('hide', function (done)
|
||||
{
|
||||
it('hide', function(done) {
|
||||
eruda.hide();
|
||||
setTimeout(function ()
|
||||
{
|
||||
setTimeout(function() {
|
||||
expect($('.eruda-dev-tools')).toBeHidden();
|
||||
done();
|
||||
}, 500);
|
||||
});
|
||||
});
|
||||
|
||||
describe('scale', function ()
|
||||
{
|
||||
it('get', function ()
|
||||
{
|
||||
describe('scale', function() {
|
||||
it('get', function() {
|
||||
eruda.scale(1);
|
||||
expect(eruda.scale()).toBe(1);
|
||||
});
|
||||
|
||||
48
test/info.js
48
test/info.js
@@ -1,52 +1,50 @@
|
||||
describe('info', function ()
|
||||
{
|
||||
describe('info', function() {
|
||||
var tool = eruda.get('info'),
|
||||
$tool = $('.eruda-info');
|
||||
|
||||
describe('default', function ()
|
||||
{
|
||||
it('location', function ()
|
||||
{
|
||||
expect($tool.find('.eruda-content').eq(0)).toContainText(location.href);
|
||||
describe('default', function() {
|
||||
it('location', function() {
|
||||
expect($tool.find('.eruda-content').eq(0)).toContainText(
|
||||
location.href
|
||||
);
|
||||
});
|
||||
|
||||
it('user agent', function ()
|
||||
{
|
||||
expect($tool.find('.eruda-content').eq(1)).toContainText(navigator.userAgent);
|
||||
it('user agent', function() {
|
||||
expect($tool.find('.eruda-content').eq(1)).toContainText(
|
||||
navigator.userAgent
|
||||
);
|
||||
});
|
||||
|
||||
it('device', function ()
|
||||
{
|
||||
expect($tool.find('.eruda-content').eq(2)).toContainText(window.innerWidth);
|
||||
it('device', function() {
|
||||
expect($tool.find('.eruda-content').eq(2)).toContainText(
|
||||
window.innerWidth
|
||||
);
|
||||
});
|
||||
|
||||
it('system', function ()
|
||||
{
|
||||
it('system', function() {
|
||||
expect($tool.find('.eruda-content').eq(3)).toContainText('os');
|
||||
});
|
||||
|
||||
it('about', function ()
|
||||
{
|
||||
expect($tool.find('.eruda-content').eq(4)).toHaveText(/Eruda v[\d.]+/);
|
||||
it('about', function() {
|
||||
expect($tool.find('.eruda-content').eq(4)).toHaveText(
|
||||
/Eruda v[\d.]+/
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('clear', function ()
|
||||
{
|
||||
it('clear', function() {
|
||||
tool.clear();
|
||||
expect($tool.find('li')).toHaveLength(0);
|
||||
});
|
||||
|
||||
it('add', function ()
|
||||
{
|
||||
it('add', function() {
|
||||
tool.add('test', 'eruda');
|
||||
expect($tool.find('.eruda-title')).toContainText('test');
|
||||
expect($tool.find('.eruda-content')).toContainText('eruda');
|
||||
});
|
||||
|
||||
it('remove', function ()
|
||||
{
|
||||
it('remove', function() {
|
||||
tool.remove('test');
|
||||
expect($tool.find('li')).toHaveLength(0);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
eruda.init({
|
||||
useShadowDom: false
|
||||
eruda.init({
|
||||
useShadowDom: false
|
||||
});
|
||||
|
||||
@@ -1,23 +1,18 @@
|
||||
describe('network', function ()
|
||||
{
|
||||
describe('network', function() {
|
||||
var tool = eruda.get('network'),
|
||||
$tool = $('.eruda-network');
|
||||
|
||||
beforeEach(function ()
|
||||
{
|
||||
beforeEach(function() {
|
||||
eruda.show('network');
|
||||
});
|
||||
|
||||
describe('request', function ()
|
||||
{
|
||||
it('xhr', function (done)
|
||||
{
|
||||
describe('request', function() {
|
||||
it('xhr', function(done) {
|
||||
$('.eruda-clear-xhr').click();
|
||||
util.ajax.get(window.location.toString(), function ()
|
||||
{
|
||||
util.ajax.get(window.location.toString(), function() {
|
||||
expect($('.eruda-requests li')).toHaveLength(1);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,60 +1,51 @@
|
||||
describe('resources', function ()
|
||||
{
|
||||
describe('resources', function() {
|
||||
var tool = eruda.get('resources'),
|
||||
$tool = $('.eruda-resources');
|
||||
|
||||
beforeEach(function ()
|
||||
{
|
||||
beforeEach(function() {
|
||||
eruda.show('resources');
|
||||
});
|
||||
|
||||
describe('localStorage', function ()
|
||||
{
|
||||
it('show', function ()
|
||||
{
|
||||
describe('localStorage', function() {
|
||||
it('show', function() {
|
||||
localStorage.clear();
|
||||
localStorage.setItem('testKey', 'testVal');
|
||||
$tool.find('.eruda-refresh-local-storage').click();
|
||||
expect($tool.find('.eruda-local-storage')).toContainText('testKey');
|
||||
});
|
||||
|
||||
it('clear', function ()
|
||||
{
|
||||
it('clear', function() {
|
||||
$tool.find('.eruda-clear-storage[data-type="local"]').click();
|
||||
expect($tool.find('.eruda-local-storage')).toContainText('Empty');
|
||||
});
|
||||
});
|
||||
|
||||
describe('sessionStorage', function ()
|
||||
{
|
||||
it('show', function ()
|
||||
{
|
||||
describe('sessionStorage', function() {
|
||||
it('show', function() {
|
||||
sessionStorage.clear();
|
||||
sessionStorage.setItem('testKey', 'testVal');
|
||||
$tool.find('.eruda-refresh-session-storage').click();
|
||||
expect($tool.find('.eruda-session-storage')).toContainText('testKey');
|
||||
expect($tool.find('.eruda-session-storage')).toContainText(
|
||||
'testKey'
|
||||
);
|
||||
});
|
||||
|
||||
it('clear', function ()
|
||||
{
|
||||
it('clear', function() {
|
||||
$tool.find('.eruda-clear-storage[data-type="session"]').click();
|
||||
expect($tool.find('.eruda-session-storage')).toContainText('Empty');
|
||||
});
|
||||
});
|
||||
|
||||
describe('cookie', function ()
|
||||
{
|
||||
it('show', function ()
|
||||
{
|
||||
describe('cookie', function() {
|
||||
it('show', function() {
|
||||
util.cookie.set('testKey', 'testVal');
|
||||
$tool.find('.eruda-refresh-cookie').click();
|
||||
expect($tool.find('.eruda-cookie')).toContainText('testKey');
|
||||
});
|
||||
|
||||
it('clear', function ()
|
||||
{
|
||||
it('clear', function() {
|
||||
$tool.find('.eruda-clear-cookie').click();
|
||||
expect($tool.find('.eruda-cookie')).toContainText('Empty');
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
describe('settings', function ()
|
||||
{
|
||||
describe('settings', function() {
|
||||
var tool = eruda.get('settings'),
|
||||
$tool = $('.eruda-settings');
|
||||
|
||||
@@ -11,13 +10,11 @@ describe('settings', function ()
|
||||
testColor: '#fff'
|
||||
});
|
||||
|
||||
beforeEach(function ()
|
||||
{
|
||||
beforeEach(function() {
|
||||
tool.clear();
|
||||
});
|
||||
|
||||
it('switch', function ()
|
||||
{
|
||||
it('switch', function() {
|
||||
var text = 'Test Switch';
|
||||
|
||||
tool.switch(cfg, 'testSwitch', text);
|
||||
@@ -26,14 +23,12 @@ describe('settings', function ()
|
||||
expect(cfg.get('testSwitch')).toBe(true);
|
||||
});
|
||||
|
||||
it('separator', function ()
|
||||
{
|
||||
it('separator', function() {
|
||||
tool.separator();
|
||||
expect($tool.find('.eruda-separator').length).toEqual(1);
|
||||
});
|
||||
|
||||
it('select', function ()
|
||||
{
|
||||
it('select', function() {
|
||||
var text = 'Test Select';
|
||||
|
||||
tool.select(cfg, 'testSelect', text, ['1', '2', '3']);
|
||||
@@ -42,22 +37,22 @@ describe('settings', function ()
|
||||
expect($el.find('.eruda-head')).toContainText(text);
|
||||
expect($el.find('.eruda-val')).toContainText('1');
|
||||
$el.find('.eruda-head').click();
|
||||
$el.find('ul li').eq(1).click();
|
||||
$el.find('ul li')
|
||||
.eq(1)
|
||||
.click();
|
||||
expect(cfg.get('testSelect')).toBe('2');
|
||||
});
|
||||
it('range', function ()
|
||||
{
|
||||
it('range', function() {
|
||||
var 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');
|
||||
expect($el.find('.eruda-head')).toContainText(text);
|
||||
expect($el.find('input').length).toEqual(1);
|
||||
$el.find('.eruda-head').click();
|
||||
});
|
||||
|
||||
it('color', function ()
|
||||
{
|
||||
it('color', function() {
|
||||
var text = 'Test Color';
|
||||
|
||||
tool.color(cfg, 'testColor', text, ['#000', '#fff']);
|
||||
@@ -65,7 +60,9 @@ describe('settings', function ()
|
||||
expect($el.find('.eruda-head')).toContainText(text);
|
||||
expect($el.find('ul li').length).toEqual(2);
|
||||
$el.find('.eruda-head').click();
|
||||
$el.find('ul li').eq(0).click();
|
||||
$el.find('ul li')
|
||||
.eq(0)
|
||||
.click();
|
||||
expect(cfg.get('testColor')).toBe('rgb(0, 0, 0)');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,35 +1,33 @@
|
||||
describe('snippets', function ()
|
||||
{
|
||||
describe('snippets', function() {
|
||||
var tool = eruda.get('snippets'),
|
||||
$tool = $('.eruda-snippets');
|
||||
|
||||
describe('default', function ()
|
||||
{
|
||||
it('border all', function ()
|
||||
{
|
||||
describe('default', function() {
|
||||
it('border all', function() {
|
||||
expect($tool.find('.eruda-name').eq(0)).toContainText('Border All');
|
||||
|
||||
var $body = $('body'),
|
||||
$btn = $tool.find('.eruda-run').eq(0);
|
||||
|
||||
$btn.click();
|
||||
expect($body).toHaveCss({outlineWidth: '2px'});
|
||||
expect($body).toHaveCss({ outlineWidth: '2px' });
|
||||
$btn.click();
|
||||
expect($body).toHaveCss({outlineWidth: '0px'});
|
||||
expect($body).toHaveCss({ outlineWidth: '0px' });
|
||||
});
|
||||
|
||||
it('refresh page', function ()
|
||||
{
|
||||
expect($tool.find('.eruda-name').eq(1)).toContainText('Refresh Page');
|
||||
it('refresh page', function() {
|
||||
expect($tool.find('.eruda-name').eq(1)).toContainText(
|
||||
'Refresh Page'
|
||||
);
|
||||
});
|
||||
|
||||
it('search text', function ()
|
||||
{
|
||||
expect($tool.find('.eruda-name').eq(2)).toContainText('Search Text');
|
||||
it('search text', function() {
|
||||
expect($tool.find('.eruda-name').eq(2)).toContainText(
|
||||
'Search Text'
|
||||
);
|
||||
});
|
||||
|
||||
it('edit page', function ()
|
||||
{
|
||||
it('edit page', function() {
|
||||
expect($tool.find('.eruda-name').eq(3)).toContainText('Edit Page');
|
||||
|
||||
var $body = $('body'),
|
||||
@@ -42,25 +40,27 @@ describe('snippets', function ()
|
||||
});
|
||||
});
|
||||
|
||||
it('clear', function ()
|
||||
{
|
||||
it('clear', function() {
|
||||
tool.clear();
|
||||
expect($tool.find('.eruda-name')).toHaveLength(0);
|
||||
});
|
||||
|
||||
it('add', function ()
|
||||
{
|
||||
tool.add('Test', function ()
|
||||
{
|
||||
console.log('eruda');
|
||||
}, 'This is the description');
|
||||
it('add', function() {
|
||||
tool.add(
|
||||
'Test',
|
||||
function() {
|
||||
console.log('eruda');
|
||||
},
|
||||
'This is the description'
|
||||
);
|
||||
expect($tool.find('.eruda-name')).toContainText('Test');
|
||||
expect($tool.find('.eruda-description')).toContainText('This is the description');
|
||||
expect($tool.find('.eruda-description')).toContainText(
|
||||
'This is the description'
|
||||
);
|
||||
});
|
||||
|
||||
it('remove', function ()
|
||||
{
|
||||
it('remove', function() {
|
||||
tool.remove('Test');
|
||||
expect($tool.find('.eruda-name')).toHaveLength(0);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,19 +1,17 @@
|
||||
describe('sources', function ()
|
||||
{
|
||||
describe('sources', function() {
|
||||
var tool = eruda.get('sources'),
|
||||
$tool = $('.eruda-sources');
|
||||
|
||||
beforeEach(function ()
|
||||
{
|
||||
beforeEach(function() {
|
||||
eruda.show('sources');
|
||||
});
|
||||
});
|
||||
|
||||
describe('js', function ()
|
||||
{
|
||||
it('highlight', function ()
|
||||
{
|
||||
describe('js', function() {
|
||||
it('highlight', function() {
|
||||
tool.set('js', '/* test */');
|
||||
expect($tool.find('.eruda-content')).toContainHtml('<span style="color:#63a35c;">/* test */</span>');
|
||||
});
|
||||
});
|
||||
});
|
||||
expect($tool.find('.eruda-content')).toContainHtml(
|
||||
'<span style="color:#63a35c;">/* test */</span>'
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
997
test/util.js
997
test/util.js
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user