jshint didn't like the "e" variable, because of some possible problem in
IE8; so I renamed it to "elem".
This commit is contained in:
parent
1e314cba57
commit
bb69485b9f
1 changed files with 22 additions and 22 deletions
44
test/test.js
44
test/test.js
|
@ -2,19 +2,19 @@ suite('Bärneruhr', function () {
|
||||||
'use strict';
|
'use strict';
|
||||||
var assert = chai.assert;
|
var assert = chai.assert;
|
||||||
var $ = jQuery;
|
var $ = jQuery;
|
||||||
var e;
|
var elem;
|
||||||
|
|
||||||
setup(function () {
|
setup(function () {
|
||||||
e = $('#u');
|
elem = $('#u');
|
||||||
});
|
});
|
||||||
|
|
||||||
teardown(function () {
|
teardown(function () {
|
||||||
var uhr = e.uhr('instance');
|
var uhr = elem.uhr('instance');
|
||||||
if (uhr !== undefined) {
|
if (uhr !== undefined) {
|
||||||
cleanupCookies(uhr.id);
|
cleanupCookies(uhr.id);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
e.uhr('destroy');
|
elem.uhr('destroy');
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// just TRY to clean up, but don't DIE trying.
|
// just TRY to clean up, but don't DIE trying.
|
||||||
}
|
}
|
||||||
|
@ -29,16 +29,16 @@ suite('Bärneruhr', function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
test('create and destroy widget', function () {
|
test('create and destroy widget', function () {
|
||||||
var uhr = e.uhr('instance');
|
var uhr = elem.uhr('instance');
|
||||||
var id;
|
var id;
|
||||||
assert.isUndefined(uhr);
|
assert.isUndefined(uhr);
|
||||||
e.uhr();
|
elem.uhr();
|
||||||
uhr = e.uhr('instance');
|
uhr = elem.uhr('instance');
|
||||||
assert.isNotNull(uhr);
|
assert.isNotNull(uhr);
|
||||||
assert.isDefined(uhr);
|
assert.isDefined(uhr);
|
||||||
id = uhr.id;
|
id = uhr.id;
|
||||||
e.uhr('destroy');
|
elem.uhr('destroy');
|
||||||
uhr = e.uhr('instance');
|
uhr = elem.uhr('instance');
|
||||||
assert.isUndefined(uhr);
|
assert.isUndefined(uhr);
|
||||||
// cookies need to be cleaned up separately in this case, because in teardown(), the uhr widget doesn't exist anymore
|
// cookies need to be cleaned up separately in this case, because in teardown(), the uhr widget doesn't exist anymore
|
||||||
cleanupCookies(id);
|
cleanupCookies(id);
|
||||||
|
@ -46,8 +46,8 @@ suite('Bärneruhr', function () {
|
||||||
|
|
||||||
test('default config', function () {
|
test('default config', function () {
|
||||||
var options;
|
var options;
|
||||||
e.uhr();
|
elem.uhr();
|
||||||
options = e.uhr('instance').options;
|
options = elem.uhr('instance').options;
|
||||||
assert.isTrue(options.autoresize);
|
assert.isTrue(options.autoresize);
|
||||||
assert.isTrue(options.controls);
|
assert.isTrue(options.controls);
|
||||||
assert.isUndefined(options.cookiePath);
|
assert.isUndefined(options.cookiePath);
|
||||||
|
@ -73,8 +73,8 @@ suite('Bärneruhr', function () {
|
||||||
theme: 'red',
|
theme: 'red',
|
||||||
width: myWidth + 'px'
|
width: myWidth + 'px'
|
||||||
};
|
};
|
||||||
e.uhr(myOptions);
|
elem.uhr(myOptions);
|
||||||
options = e.uhr('instance').options;
|
options = elem.uhr('instance').options;
|
||||||
assert.equal(options.autoresize, myOptions.autoresize);
|
assert.equal(options.autoresize, myOptions.autoresize);
|
||||||
assert.equal(options.controls, myOptions.controls);
|
assert.equal(options.controls, myOptions.controls);
|
||||||
assert.equal(options.cookiePath, myOptions.cookiePath);
|
assert.equal(options.cookiePath, myOptions.cookiePath);
|
||||||
|
@ -85,26 +85,26 @@ suite('Bärneruhr', function () {
|
||||||
assert.equal(options.theme, myOptions.theme);
|
assert.equal(options.theme, myOptions.theme);
|
||||||
assert.equal(options.width, myOptions.width);
|
assert.equal(options.width, myOptions.width);
|
||||||
|
|
||||||
realWidth = e.width();
|
realWidth = elem.width();
|
||||||
assert.equal(myWidth, realWidth);
|
assert.equal(myWidth, realWidth);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('unknown language', function () {
|
test('unknown language', function () {
|
||||||
var uhr;
|
var uhr;
|
||||||
e.uhr({
|
elem.uhr({
|
||||||
language: 'klingon'
|
language: 'klingon'
|
||||||
});
|
});
|
||||||
uhr = e.uhr('instance');
|
uhr = elem.uhr('instance');
|
||||||
// NB: 'de' is just the first language that is included in the page. that may change!
|
// NB: 'de' is just the first language that is included in the page. that may change!
|
||||||
assert.equal(uhr.options.language, 'de');
|
assert.equal(uhr.options.language, 'de');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('unknown theme', function () {
|
test('unknown theme', function () {
|
||||||
var uhr;
|
var uhr;
|
||||||
e.uhr({
|
elem.uhr({
|
||||||
theme: 'klingon'
|
theme: 'klingon'
|
||||||
});
|
});
|
||||||
uhr = e.uhr('instance');
|
uhr = elem.uhr('instance');
|
||||||
// NB: 'black' is the first theme that is included in the test page.
|
// NB: 'black' is the first theme that is included in the test page.
|
||||||
assert.equal(uhr.options.theme, 'black');
|
assert.equal(uhr.options.theme, 'black');
|
||||||
});
|
});
|
||||||
|
@ -114,8 +114,8 @@ suite('Bärneruhr', function () {
|
||||||
|
|
||||||
window.location.hash = '#t=red&l=dk&m=seconds&s=on';
|
window.location.hash = '#t=red&l=dk&m=seconds&s=on';
|
||||||
|
|
||||||
e.uhr();
|
elem.uhr();
|
||||||
options = e.uhr('instance').options;
|
options = elem.uhr('instance').options;
|
||||||
assert.isTrue(options.force);
|
assert.isTrue(options.force);
|
||||||
assert.equal(options.language, 'dk');
|
assert.equal(options.language, 'dk');
|
||||||
assert.equal(options.mode, 'seconds');
|
assert.equal(options.mode, 'seconds');
|
||||||
|
@ -128,8 +128,8 @@ suite('Bärneruhr', function () {
|
||||||
|
|
||||||
window.location.hash = '#theme=pink&language=de_CH&mode=normal&status=off';
|
window.location.hash = '#theme=pink&language=de_CH&mode=normal&status=off';
|
||||||
|
|
||||||
e.uhr();
|
elem.uhr();
|
||||||
options = e.uhr('instance').options;
|
options = elem.uhr('instance').options;
|
||||||
assert.isTrue(options.force);
|
assert.isTrue(options.force);
|
||||||
assert.equal(options.language, 'de_CH');
|
assert.equal(options.language, 'de_CH');
|
||||||
assert.equal(options.mode, 'normal');
|
assert.equal(options.mode, 'normal');
|
||||||
|
|
Loading…
Reference in a new issue