added the first two test methods that actually work!
This commit is contained in:
parent
51d21d8ff6
commit
0c7aebc200
15 changed files with 248 additions and 305 deletions
29
Gruntfile.js
29
Gruntfile.js
|
@ -58,7 +58,7 @@ module.exports = function (grunt) {
|
||||||
options: {
|
options: {
|
||||||
banner: '<%= banner %>'
|
banner: '<%= banner %>'
|
||||||
},
|
},
|
||||||
libs:{
|
libs: {
|
||||||
src: '<%= concat.libs.dest %>',
|
src: '<%= concat.libs.dest %>',
|
||||||
dest: 'dist/libs.min.js'
|
dest: 'dist/libs.min.js'
|
||||||
},
|
},
|
||||||
|
@ -83,10 +83,10 @@ module.exports = function (grunt) {
|
||||||
dest: 'dist/jquery.<%= pkg.name %>.langs.min.js'
|
dest: 'dist/jquery.<%= pkg.name %>.langs.min.js'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
qunit: {
|
mocha_phantomjs: {
|
||||||
all: {
|
all:{
|
||||||
options: {
|
options: {
|
||||||
urls: ['http://localhost:9000/test/<%= pkg.name %>.html']
|
urls: ['http://localhost:9000/test/test.html']
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -105,12 +105,9 @@ module.exports = function (grunt) {
|
||||||
jshintrc: '.jshintrc'
|
jshintrc: '.jshintrc'
|
||||||
},
|
},
|
||||||
src: ['src/**/*.js']
|
src: ['src/**/*.js']
|
||||||
// },
|
},
|
||||||
// test: {
|
test: {
|
||||||
// options: {
|
src: ['test/*.js']
|
||||||
// jshintrc: 'test/.jshintrc'
|
|
||||||
// },
|
|
||||||
// src: ['test/**/*.js']
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
|
@ -120,11 +117,11 @@ module.exports = function (grunt) {
|
||||||
},
|
},
|
||||||
src: {
|
src: {
|
||||||
files: '<%= jshint.src.src %>',
|
files: '<%= jshint.src.src %>',
|
||||||
tasks: ['jshint:src', 'qunit']
|
tasks: ['jshint:src', 'mocha_phantomjs']
|
||||||
},
|
},
|
||||||
test: {
|
test: {
|
||||||
files: '<%= jshint.test.src %>',
|
files: ['test/test.html', '<%= jshint.test.src %>'],
|
||||||
tasks: ['jshint:test', 'qunit']
|
tasks: ['jshint:test', 'mocha_phantomjs']
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
connect: {
|
connect: {
|
||||||
|
@ -137,14 +134,14 @@ module.exports = function (grunt) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
grunt.loadNpmTasks('grunt-mocha-phantomjs');
|
||||||
// Default task.
|
// Default task.
|
||||||
// grunt.registerTask('default', ['jshint', 'connect', 'qunit', 'clean', 'concat', 'uglify']);
|
grunt.registerTask('default', ['jshint', 'connect', 'mocha_phantomjs', 'clean', 'concat', 'uglify']);
|
||||||
grunt.registerTask('default', ['jshint', 'connect', /*'qunit', */'clean', 'concat', 'uglify']);
|
|
||||||
grunt.registerTask('buildonly', ['clean', 'concat', 'uglify']);
|
grunt.registerTask('buildonly', ['clean', 'concat', 'uglify']);
|
||||||
grunt.registerTask('server', function () {
|
grunt.registerTask('server', function () {
|
||||||
grunt.log.warn('The `server` task has been deprecated. Use `grunt serve` to start a server.');
|
grunt.log.warn('The `server` task has been deprecated. Use `grunt serve` to start a server.');
|
||||||
grunt.task.run(['serve']);
|
grunt.task.run(['serve']);
|
||||||
});
|
});
|
||||||
grunt.registerTask('serve', ['connect', 'watch']);
|
grunt.registerTask('serve', ['connect', 'watch']);
|
||||||
grunt.registerTask('test', ['jshint', 'connect', 'qunit']);
|
grunt.registerTask('test', ['jshint', 'connect', 'mocha_phantomjs']);
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
{
|
{
|
||||||
"name": "uhr",
|
"name": "uhr",
|
||||||
"version": "0.0.1",
|
"version": "7.0.0-next",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"jquery": "~2.1.3",
|
||||||
"jquery-ui": "~1.11.2",
|
"jquery-ui": "~1.11.2",
|
||||||
"jquery-cookie": "~1.4.1"
|
"jquery-cookie": "~1.4.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"qunit": "~1.12.0",
|
"mocha": "~2.1.0",
|
||||||
"jquery": "~2.1.3"
|
"chai": "~1.10.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
14
dist/jquery.uhr.base.js
vendored
14
dist/jquery.uhr.base.js
vendored
|
@ -333,6 +333,16 @@
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
var destroy = function destroy() {
|
||||||
|
this.timer = null;
|
||||||
|
$(this.element)
|
||||||
|
.removeAttr('style')
|
||||||
|
.removeAttr('class')
|
||||||
|
.empty();
|
||||||
|
$('#uhr-configlink' + this.id).remove();
|
||||||
|
$('#uhr-controlpanel' + this.id).remove();
|
||||||
|
|
||||||
|
};
|
||||||
var setCookie = function setCookie(cookieName, cookieValue) {
|
var setCookie = function setCookie(cookieName, cookieValue) {
|
||||||
var options = {};
|
var options = {};
|
||||||
if (this.options.cookiePath !== undefined) {
|
if (this.options.cookiePath !== undefined) {
|
||||||
|
@ -446,7 +456,9 @@
|
||||||
"mode": setMode,
|
"mode": setMode,
|
||||||
"width": setWidth,
|
"width": setWidth,
|
||||||
// constructor method
|
// constructor method
|
||||||
"_create": create
|
"_create": create,
|
||||||
|
// destructor method
|
||||||
|
"_destroy": destroy
|
||||||
});
|
});
|
||||||
$.fritteli.uhr.register = uhrGlobals.registerLanguage;
|
$.fritteli.uhr.register = uhrGlobals.registerLanguage;
|
||||||
/**
|
/**
|
||||||
|
|
2
dist/jquery.uhr.base.min.js
vendored
2
dist/jquery.uhr.base.min.js
vendored
File diff suppressed because one or more lines are too long
14
dist/jquery.uhr.complete.js
vendored
14
dist/jquery.uhr.complete.js
vendored
|
@ -333,6 +333,16 @@
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
var destroy = function destroy() {
|
||||||
|
this.timer = null;
|
||||||
|
$(this.element)
|
||||||
|
.removeAttr('style')
|
||||||
|
.removeAttr('class')
|
||||||
|
.empty();
|
||||||
|
$('#uhr-configlink' + this.id).remove();
|
||||||
|
$('#uhr-controlpanel' + this.id).remove();
|
||||||
|
|
||||||
|
};
|
||||||
var setCookie = function setCookie(cookieName, cookieValue) {
|
var setCookie = function setCookie(cookieName, cookieValue) {
|
||||||
var options = {};
|
var options = {};
|
||||||
if (this.options.cookiePath !== undefined) {
|
if (this.options.cookiePath !== undefined) {
|
||||||
|
@ -446,7 +456,9 @@
|
||||||
"mode": setMode,
|
"mode": setMode,
|
||||||
"width": setWidth,
|
"width": setWidth,
|
||||||
// constructor method
|
// constructor method
|
||||||
"_create": create
|
"_create": create,
|
||||||
|
// destructor method
|
||||||
|
"_destroy": destroy
|
||||||
});
|
});
|
||||||
$.fritteli.uhr.register = uhrGlobals.registerLanguage;
|
$.fritteli.uhr.register = uhrGlobals.registerLanguage;
|
||||||
/**
|
/**
|
||||||
|
|
2
dist/jquery.uhr.complete.min.js
vendored
2
dist/jquery.uhr.complete.min.js
vendored
File diff suppressed because one or more lines are too long
14
dist/jquery.uhr.main.js
vendored
14
dist/jquery.uhr.main.js
vendored
|
@ -333,6 +333,16 @@
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
var destroy = function destroy() {
|
||||||
|
this.timer = null;
|
||||||
|
$(this.element)
|
||||||
|
.removeAttr('style')
|
||||||
|
.removeAttr('class')
|
||||||
|
.empty();
|
||||||
|
$('#uhr-configlink' + this.id).remove();
|
||||||
|
$('#uhr-controlpanel' + this.id).remove();
|
||||||
|
|
||||||
|
};
|
||||||
var setCookie = function setCookie(cookieName, cookieValue) {
|
var setCookie = function setCookie(cookieName, cookieValue) {
|
||||||
var options = {};
|
var options = {};
|
||||||
if (this.options.cookiePath !== undefined) {
|
if (this.options.cookiePath !== undefined) {
|
||||||
|
@ -446,7 +456,9 @@
|
||||||
"mode": setMode,
|
"mode": setMode,
|
||||||
"width": setWidth,
|
"width": setWidth,
|
||||||
// constructor method
|
// constructor method
|
||||||
"_create": create
|
"_create": create,
|
||||||
|
// destructor method
|
||||||
|
"_destroy": destroy
|
||||||
});
|
});
|
||||||
$.fritteli.uhr.register = uhrGlobals.registerLanguage;
|
$.fritteli.uhr.register = uhrGlobals.registerLanguage;
|
||||||
/**
|
/**
|
||||||
|
|
2
dist/jquery.uhr.main.min.js
vendored
2
dist/jquery.uhr.main.min.js
vendored
File diff suppressed because one or more lines are too long
4
lib/jquery-2.1.0.min.js
vendored
4
lib/jquery-2.1.0.min.js
vendored
File diff suppressed because one or more lines are too long
|
@ -1,117 +0,0 @@
|
||||||
/*!
|
|
||||||
* jQuery Cookie Plugin v1.4.0
|
|
||||||
* https://github.com/carhartl/jquery-cookie
|
|
||||||
*
|
|
||||||
* Copyright 2013 Klaus Hartl
|
|
||||||
* Released under the MIT license
|
|
||||||
*/
|
|
||||||
(function (factory) {
|
|
||||||
if (typeof define === 'function' && define.amd) {
|
|
||||||
// AMD. Register as anonymous module.
|
|
||||||
define(['jquery'], factory);
|
|
||||||
} else {
|
|
||||||
// Browser globals.
|
|
||||||
factory(jQuery);
|
|
||||||
}
|
|
||||||
}(function ($) {
|
|
||||||
|
|
||||||
var pluses = /\+/g;
|
|
||||||
|
|
||||||
function encode(s) {
|
|
||||||
return config.raw ? s : encodeURIComponent(s);
|
|
||||||
}
|
|
||||||
|
|
||||||
function decode(s) {
|
|
||||||
return config.raw ? s : decodeURIComponent(s);
|
|
||||||
}
|
|
||||||
|
|
||||||
function stringifyCookieValue(value) {
|
|
||||||
return encode(config.json ? JSON.stringify(value) : String(value));
|
|
||||||
}
|
|
||||||
|
|
||||||
function parseCookieValue(s) {
|
|
||||||
if (s.indexOf('"') === 0) {
|
|
||||||
// This is a quoted cookie as according to RFC2068, unescape...
|
|
||||||
s = s.slice(1, -1).replace(/\\"/g, '"').replace(/\\\\/g, '\\');
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
// Replace server-side written pluses with spaces.
|
|
||||||
// If we can't decode the cookie, ignore it, it's unusable.
|
|
||||||
s = decodeURIComponent(s.replace(pluses, ' '));
|
|
||||||
} catch(e) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
// If we can't parse the cookie, ignore it, it's unusable.
|
|
||||||
return config.json ? JSON.parse(s) : s;
|
|
||||||
} catch(e) {}
|
|
||||||
}
|
|
||||||
|
|
||||||
function read(s, converter) {
|
|
||||||
var value = config.raw ? s : parseCookieValue(s);
|
|
||||||
return $.isFunction(converter) ? converter(value) : value;
|
|
||||||
}
|
|
||||||
|
|
||||||
var config = $.cookie = function (key, value, options) {
|
|
||||||
|
|
||||||
// Write
|
|
||||||
if (value !== undefined && !$.isFunction(value)) {
|
|
||||||
options = $.extend({}, config.defaults, options);
|
|
||||||
|
|
||||||
if (typeof options.expires === 'number') {
|
|
||||||
var days = options.expires, t = options.expires = new Date();
|
|
||||||
t.setDate(t.getDate() + days);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (document.cookie = [
|
|
||||||
encode(key), '=', stringifyCookieValue(value),
|
|
||||||
options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
|
|
||||||
options.path ? '; path=' + options.path : '',
|
|
||||||
options.domain ? '; domain=' + options.domain : '',
|
|
||||||
options.secure ? '; secure' : ''
|
|
||||||
].join(''));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Read
|
|
||||||
|
|
||||||
var result = key ? undefined : {};
|
|
||||||
|
|
||||||
// To prevent the for loop in the first place assign an empty array
|
|
||||||
// in case there are no cookies at all. Also prevents odd result when
|
|
||||||
// calling $.cookie().
|
|
||||||
var cookies = document.cookie ? document.cookie.split('; ') : [];
|
|
||||||
|
|
||||||
for (var i = 0, l = cookies.length; i < l; i++) {
|
|
||||||
var parts = cookies[i].split('=');
|
|
||||||
var name = decode(parts.shift());
|
|
||||||
var cookie = parts.join('=');
|
|
||||||
|
|
||||||
if (key && key === name) {
|
|
||||||
// If second argument (value) is a function it's a converter...
|
|
||||||
result = read(cookie, value);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Prevent storing a cookie that we couldn't decode.
|
|
||||||
if (!key && (cookie = read(cookie)) !== undefined) {
|
|
||||||
result[name] = cookie;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
};
|
|
||||||
|
|
||||||
config.defaults = {};
|
|
||||||
|
|
||||||
$.removeCookie = function (key, options) {
|
|
||||||
if ($.cookie(key) !== undefined) {
|
|
||||||
// Must not alter options, thus extending a fresh object...
|
|
||||||
$.cookie(key, '', $.extend({}, options, { expires: -1 }));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
};
|
|
||||||
|
|
||||||
}));
|
|
6
lib/jquery-ui-1.10.4.custom.min.js
vendored
6
lib/jquery-ui-1.10.4.custom.min.js
vendored
File diff suppressed because one or more lines are too long
|
@ -3,7 +3,8 @@
|
||||||
"version": "7.0.0-next",
|
"version": "7.0.0-next",
|
||||||
"description": "jQuery QLOCKTWO plugin",
|
"description": "jQuery QLOCKTWO plugin",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"jquery-plugin", "qlocktwo"
|
"jquery-plugin",
|
||||||
|
"qlocktwo"
|
||||||
],
|
],
|
||||||
"homepage": "http://bärneruhr.ch/",
|
"homepage": "http://bärneruhr.ch/",
|
||||||
"author": {
|
"author": {
|
||||||
|
@ -31,8 +32,10 @@
|
||||||
"grunt-contrib-qunit": "~0.5.1",
|
"grunt-contrib-qunit": "~0.5.1",
|
||||||
"grunt-contrib-uglify": "~0.5.0",
|
"grunt-contrib-uglify": "~0.5.0",
|
||||||
"grunt-contrib-watch": "~0.6.1",
|
"grunt-contrib-watch": "~0.6.1",
|
||||||
|
"grunt-mocha-phantomjs": "^0.6.0",
|
||||||
"jshint-stylish": "~0.2.0",
|
"jshint-stylish": "~0.2.0",
|
||||||
"load-grunt-tasks": "~0.6.0",
|
"load-grunt-tasks": "~0.6.0",
|
||||||
|
"phantomjs": "^1.9.13",
|
||||||
"time-grunt": "~0.3.2"
|
"time-grunt": "~0.3.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
14
src/uhr.js
14
src/uhr.js
|
@ -344,6 +344,16 @@
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
var destroy = function destroy() {
|
||||||
|
this.timer = null;
|
||||||
|
$(this.element)
|
||||||
|
.removeAttr('style')
|
||||||
|
.removeAttr('class')
|
||||||
|
.empty();
|
||||||
|
$('#uhr-configlink' + this.id).remove();
|
||||||
|
$('#uhr-controlpanel' + this.id).remove();
|
||||||
|
|
||||||
|
};
|
||||||
var setCookie = function setCookie(cookieName, cookieValue) {
|
var setCookie = function setCookie(cookieName, cookieValue) {
|
||||||
var options = {};
|
var options = {};
|
||||||
if (this.options.cookiePath !== undefined) {
|
if (this.options.cookiePath !== undefined) {
|
||||||
|
@ -457,7 +467,9 @@
|
||||||
"mode": setMode,
|
"mode": setMode,
|
||||||
"width": setWidth,
|
"width": setWidth,
|
||||||
// constructor method
|
// constructor method
|
||||||
"_create": create
|
"_create": create,
|
||||||
|
// destructor method
|
||||||
|
"_destroy": destroy
|
||||||
});
|
});
|
||||||
$.fritteli.uhr.register = uhrGlobals.registerLanguage;
|
$.fritteli.uhr.register = uhrGlobals.registerLanguage;
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -6,23 +6,28 @@
|
||||||
<link rel="stylesheet" type="text/css" href="css/mocha.css"/>
|
<link rel="stylesheet" type="text/css" href="css/mocha.css"/>
|
||||||
<link rel="stylesheet" type="text/css" href="../css/uhr.css"/>
|
<link rel="stylesheet" type="text/css" href="../css/uhr.css"/>
|
||||||
<link rel="stylesheet" type="text/css" href="../css/uhr-black.css" data-class="black"/>
|
<link rel="stylesheet" type="text/css" href="../css/uhr-black.css" data-class="black"/>
|
||||||
|
<link rel="stylesheet" type="text/css" href="../css/uhr-red.css" data-class="red"/>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="mocha"></div>
|
|
||||||
<script src="lib/mocha.js"></script>
|
|
||||||
<script src="lib/chai.js"></script>
|
|
||||||
<script>mocha.setup('tdd');</script>
|
|
||||||
<script src="../lib/jquery-2.1.0.min.js"></script>
|
|
||||||
<script src="../lib/jquery-ui-1.10.4.custom.min.js"></script>
|
|
||||||
<script src="../lib/jquery-cookie-1.4.0.js"></script>
|
|
||||||
<script src="../src/uhr.js"></script>
|
|
||||||
<script src="../src/uhr-de_CH.js"></script>
|
|
||||||
<script src="test.js"></script>
|
|
||||||
<div id="u"></div>
|
<div id="u"></div>
|
||||||
<script>
|
<div id="mocha"></div>
|
||||||
|
<script type="text/javascript" src="lib/mocha.js"></script>
|
||||||
|
<script type="text/javascript" src="lib/chai.js"></script>
|
||||||
|
<script type="text/javascript" src="../dist/libs.js"></script>
|
||||||
|
<script type="text/javascript" src="../dist/jquery.uhr.complete.js"></script>
|
||||||
|
<script type="text/javascript">
|
||||||
|
mocha.setup('tdd');
|
||||||
|
</script>
|
||||||
|
<script type="text/javascript" src="test.js"></script>
|
||||||
|
<script type="text/javascript">
|
||||||
mocha.checkLeaks();
|
mocha.checkLeaks();
|
||||||
|
mocha.globals(['jQuery*']);
|
||||||
|
if (window.mochaPhantomJS) {
|
||||||
|
mochaPhantomJS.run();
|
||||||
|
}
|
||||||
|
else {
|
||||||
mocha.run();
|
mocha.run();
|
||||||
// $('#u').uhr({'width':'200px'});
|
}
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
22
test/test.js
22
test/test.js
|
@ -1,5 +1,21 @@
|
||||||
suite('Bärneruhr', function() {
|
suite('Bärneruhr', function () {
|
||||||
"use strict";
|
'use strict';
|
||||||
test('dummy', function() {
|
var assert = chai.assert;
|
||||||
|
test('create widget', function () {
|
||||||
|
var e = jQuery('#u');
|
||||||
|
var uhr = e.uhr('instance');
|
||||||
|
assert.isUndefined(uhr);
|
||||||
|
uhr = e.uhr();
|
||||||
|
assert.isNotNull(uhr);
|
||||||
|
assert.isDefined(uhr);
|
||||||
|
});
|
||||||
|
test('destroy widget', function() {
|
||||||
|
var e = jQuery('#u');
|
||||||
|
var uhr = e.uhr('instance');
|
||||||
|
assert.isNotNull(uhr);
|
||||||
|
assert.isDefined(uhr);
|
||||||
|
e.uhr('destroy');
|
||||||
|
uhr = e.uhr('instance');
|
||||||
|
assert.isUndefined(uhr);
|
||||||
});
|
});
|
||||||
});
|
});
|
Loading…
Reference in a new issue