mirror of
https://github.com/liriliri/eruda.git
synced 2026-02-02 09:49:00 +08:00
Add: Settings test
This commit is contained in:
@@ -58,15 +58,15 @@ export default class Settings extends Tool
|
||||
}
|
||||
_bindEvent()
|
||||
{
|
||||
var self = this;
|
||||
let self = this;
|
||||
|
||||
this._$el.on('click', '.eruda-checkbox', function ()
|
||||
{
|
||||
var $input = util.$(this).find('input'),
|
||||
let $input = util.$(this).find('input'),
|
||||
idx = $input.data('idx'),
|
||||
val = $input.get(0).checked;
|
||||
|
||||
var setting = self._settings[idx];
|
||||
let setting = self._settings[idx];
|
||||
setting.config.set(setting.key, val);
|
||||
}).on('click', '.eruda-select .eruda-head', function ()
|
||||
{
|
||||
|
||||
@@ -3,7 +3,9 @@ function boot(name)
|
||||
// Need a little delay to make sure width and height of webpack dev server iframe are initialized.
|
||||
setTimeout(function ()
|
||||
{
|
||||
eruda.init({tool: name});
|
||||
eruda.init({
|
||||
tool: name === 'settings' ? [] : name
|
||||
});
|
||||
eruda.show().get().config.set('displaySize', '50%');
|
||||
loadJs('lib/boot', function ()
|
||||
{
|
||||
|
||||
16
test/settings.html
Normal file
16
test/settings.html
Normal file
@@ -0,0 +1,16 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Console</title>
|
||||
<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>
|
||||
</html>
|
||||
41
test/settings.js
Normal file
41
test/settings.js
Normal file
@@ -0,0 +1,41 @@
|
||||
var tool = eruda.get('settings'),
|
||||
$tool = $('.eruda-settings');
|
||||
|
||||
var cfg = eruda.config.create('eruda-test');
|
||||
cfg.set({
|
||||
testSwitch: false,
|
||||
testSelect: ['1']
|
||||
});
|
||||
|
||||
describe('switch', function ()
|
||||
{
|
||||
it('ui', function ()
|
||||
{
|
||||
var text = 'Test Switch';
|
||||
|
||||
tool.switch(cfg, 'testSwitch', text);
|
||||
expect($tool.find('.eruda-switch').eq(3)).toContainText(text);
|
||||
});
|
||||
});
|
||||
|
||||
describe('separator', function ()
|
||||
{
|
||||
it('ui', function ()
|
||||
{
|
||||
tool.separator();
|
||||
expect($tool.find('.eruda-separator').length).toEqual(4);
|
||||
});
|
||||
});
|
||||
|
||||
describe('select', function ()
|
||||
{
|
||||
it('ui', function ()
|
||||
{
|
||||
var text = 'Test Select';
|
||||
|
||||
tool.select(cfg, 'testSelect', text, ['1', '2', '3']);
|
||||
var $el = $tool.find('.eruda-select').eq(2);
|
||||
expect($el.find('ul li').length).toEqual(3);
|
||||
expect($el.find('.eruda-val')).toContainText('1');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user