2008-09-20 17:42:04 +00:00
|
|
|
/*
|
|
|
|
* progressbar unit tests
|
|
|
|
*/
|
|
|
|
(function($) {
|
2008-11-12 02:52:31 +00:00
|
|
|
//
|
|
|
|
// Progressbar Test Helper Functions
|
|
|
|
//
|
|
|
|
|
|
|
|
var defaults = {
|
|
|
|
disabled: false,
|
|
|
|
duration: 1000,
|
|
|
|
increment: 1,
|
|
|
|
interval: 1000,
|
|
|
|
range: true,
|
|
|
|
width: 300
|
|
|
|
};
|
|
|
|
|
|
|
|
var el;
|
|
|
|
|
|
|
|
// Progressbar Tests
|
2008-09-20 17:42:04 +00:00
|
|
|
module("progressbar");
|
|
|
|
|
|
|
|
test("init", function() {
|
|
|
|
expect(1);
|
|
|
|
|
2008-11-12 02:52:31 +00:00
|
|
|
$("<div></div>").appendTo('body').progressbar().remove();
|
2008-09-20 17:42:04 +00:00
|
|
|
ok(true, '.progressbar() called on element');
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
test("destroy", function() {
|
|
|
|
expect(1);
|
|
|
|
|
2008-11-18 02:55:25 +00:00
|
|
|
$("<div></div>").appendTo('body').progressbar().progressbar("destroy").remove();
|
2008-09-20 17:42:04 +00:00
|
|
|
ok(true, '.progressbar("destroy") called on element');
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
test("defaults", function() {
|
2008-11-12 02:52:31 +00:00
|
|
|
el = $('<div></div>').progressbar();
|
|
|
|
$.each(defaults, function(key, val) {
|
|
|
|
var actual = el.data(key + ".progressbar"), expected = val;
|
|
|
|
same(actual, expected, key);
|
|
|
|
});
|
|
|
|
el.remove();
|
2008-09-20 17:42:04 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
test("set defaults on init", function() {
|
|
|
|
expect(5);
|
|
|
|
el = $("#progressbar").progressbar({
|
|
|
|
width: 500,
|
|
|
|
duration: 5000,
|
|
|
|
interval: 500,
|
|
|
|
increment: 5,
|
|
|
|
range: false
|
|
|
|
});
|
|
|
|
|
|
|
|
equals(el.data("width.progressbar"), 500, "width");
|
|
|
|
equals(el.data("duration.progressbar"), 5000, "duration");
|
|
|
|
equals(el.data("interval.progressbar"), 500, "interval");
|
|
|
|
equals(el.data("increment.progressbar"), 5, "increment");
|
|
|
|
equals(el.data("range.progressbar"), false, "range");
|
|
|
|
|
|
|
|
});
|
|
|
|
|
2008-10-29 16:57:04 +00:00
|
|
|
test("accessibility", function() {
|
|
|
|
expect(7);
|
|
|
|
el = $("#progressbar").progressbar();
|
|
|
|
|
2008-11-05 19:43:21 +00:00
|
|
|
equals(el.attr("role"), "progressbar", "aria role");
|
|
|
|
equals(el.attr("aria-valuemin"), 0, "aria-valuemin");
|
|
|
|
equals(el.attr("aria-valuemax"), 100, "aria-valuemax");
|
|
|
|
equals(el.attr("aria-valuenow"), 0, "aria-valuenow initially");
|
2008-10-29 16:57:04 +00:00
|
|
|
el.progressbar("progress", 77);
|
2008-11-05 19:43:21 +00:00
|
|
|
equals(el.attr("aria-valuenow"), 77, "aria-valuenow");
|
2008-10-29 16:57:04 +00:00
|
|
|
el.progressbar("disable");
|
2008-11-05 19:43:21 +00:00
|
|
|
equals(el.attr("aria-disabled"), "true", "aria-disabled");
|
2008-10-29 16:57:04 +00:00
|
|
|
el.progressbar("enable");
|
2008-11-05 19:43:21 +00:00
|
|
|
equals(el.attr("aria-disabled"), "false", "enabled");
|
2008-10-29 16:57:04 +00:00
|
|
|
});
|
2008-09-20 17:42:04 +00:00
|
|
|
|
|
|
|
})(jQuery);
|