mirror of
https://github.com/liriliri/eruda.git
synced 2026-03-24 09:48:37 +08:00
Add: Settings test
This commit is contained in:
@@ -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