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:
Manuel Friedli 2015-01-18 21:40:36 +01:00
parent 1e314cba57
commit bb69485b9f
1 changed files with 22 additions and 22 deletions

View File

@ -2,19 +2,19 @@ suite('Bärneruhr', function () {
'use strict';
var assert = chai.assert;
var $ = jQuery;
var e;
var elem;
setup(function () {
e = $('#u');
elem = $('#u');
});
teardown(function () {
var uhr = e.uhr('instance');
var uhr = elem.uhr('instance');
if (uhr !== undefined) {
cleanupCookies(uhr.id);
}
try {
e.uhr('destroy');
elem.uhr('destroy');
} catch (e) {
// just TRY to clean up, but don't DIE trying.
}
@ -29,16 +29,16 @@ suite('Bärneruhr', function () {
}
test('create and destroy widget', function () {
var uhr = e.uhr('instance');
var uhr = elem.uhr('instance');
var id;
assert.isUndefined(uhr);
e.uhr();
uhr = e.uhr('instance');
elem.uhr();
uhr = elem.uhr('instance');
assert.isNotNull(uhr);
assert.isDefined(uhr);
id = uhr.id;
e.uhr('destroy');
uhr = e.uhr('instance');
elem.uhr('destroy');
uhr = elem.uhr('instance');
assert.isUndefined(uhr);
// cookies need to be cleaned up separately in this case, because in teardown(), the uhr widget doesn't exist anymore
cleanupCookies(id);
@ -46,8 +46,8 @@ suite('Bärneruhr', function () {
test('default config', function () {
var options;
e.uhr();
options = e.uhr('instance').options;
elem.uhr();
options = elem.uhr('instance').options;
assert.isTrue(options.autoresize);
assert.isTrue(options.controls);
assert.isUndefined(options.cookiePath);
@ -73,8 +73,8 @@ suite('Bärneruhr', function () {
theme: 'red',
width: myWidth + 'px'
};
e.uhr(myOptions);
options = e.uhr('instance').options;
elem.uhr(myOptions);
options = elem.uhr('instance').options;
assert.equal(options.autoresize, myOptions.autoresize);
assert.equal(options.controls, myOptions.controls);
assert.equal(options.cookiePath, myOptions.cookiePath);
@ -85,26 +85,26 @@ suite('Bärneruhr', function () {
assert.equal(options.theme, myOptions.theme);
assert.equal(options.width, myOptions.width);
realWidth = e.width();
realWidth = elem.width();
assert.equal(myWidth, realWidth);
});
test('unknown language', function () {
var uhr;
e.uhr({
elem.uhr({
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!
assert.equal(uhr.options.language, 'de');
});
test('unknown theme', function () {
var uhr;
e.uhr({
elem.uhr({
theme: 'klingon'
});
uhr = e.uhr('instance');
uhr = elem.uhr('instance');
// NB: 'black' is the first theme that is included in the test page.
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';
e.uhr();
options = e.uhr('instance').options;
elem.uhr();
options = elem.uhr('instance').options;
assert.isTrue(options.force);
assert.equal(options.language, 'dk');
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';
e.uhr();
options = e.uhr('instance').options;
elem.uhr();
options = elem.uhr('instance').options;
assert.isTrue(options.force);
assert.equal(options.language, 'de_CH');
assert.equal(options.mode, 'normal');