Fix: Container test file ignored

This commit is contained in:
surunzi
2017-11-05 11:51:26 +08:00
parent a38006fe49
commit 6b99b991e3
3 changed files with 104 additions and 1 deletions

17
test/eruda.html Normal file
View File

@@ -0,0 +1,17 @@
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<title>Features</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('eruda');</script>
</body>
</html>

83
test/eruda.js Normal file
View File

@@ -0,0 +1,83 @@
describe('init', function ()
{
it('destroy', function ()
{
eruda.destroy();
expect($('#eruda')).toHaveLength(0);
});
it('init', function ()
{
var container = document.createElement('div');
container.id = 'eruda';
document.body.appendChild(container);
eruda.init({
container: container,
tool: []
});
var $eruda = $('#eruda');
expect($eruda.find('.eruda-dev-tools')).toHaveLength(1);
});
});
describe('tool', function ()
{
it('add', function ()
{
eruda.add({
name: 'test',
init: function ($el)
{
this._$el = $el;
$el.html('Test Plugin');
}
});
expect($('.eruda-test')).toContainText('Test Plugin');
});
it('show', function ()
{
var $tool = $('.eruda-test');
expect($tool).toBeHidden();
eruda.show('test');
expect($tool).toHaveCss({display: 'block'});
});
it('remove', function ()
{
eruda.remove('test');
expect($('.eruda-test')).toHaveLength(0);
});
});
describe('display', function ()
{
it('show', function ()
{
eruda.show();
expect($('.eruda-dev-tools')).toHaveCss({display: 'block'});
});
it('hide', function (done)
{
eruda.hide();
setTimeout(function ()
{
expect($('.eruda-dev-tools')).toBeHidden();
done();
}, 500);
});
});
describe('scale', function ()
{
it('get', function ()
{
eruda.scale(1);
expect(eruda.scale()).toBe(1);
});
});