jquery-ui/tests/progressbar.js

69 lines
1.5 KiB
JavaScript
Raw Normal View History

2008-09-20 17:42:04 +00:00
/*
* progressbar unit tests
*/
(function($) {
//
// Progressbar Test Helper Functions
//
var defaults = {
disabled: false,
value: 0
};
var el;
// Progressbar Tests
2008-09-20 17:42:04 +00:00
module("progressbar");
test("init", function() {
expect(1);
$("<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);
$("<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() {
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() {
el = $("#progressbar").progressbar({
value: 50
2008-09-20 17:42:04 +00:00
});
2008-11-24 13:52:13 +00:00
equals(el.progressbar("option", "value"), 50, "value");
2008-09-20 17:42:04 +00:00
});
test("accessibility", function() {
expect(7);
el = $("#progressbar").progressbar();
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-11-24 13:52:13 +00:00
el.progressbar("value", 77);
equals(el.attr("aria-valuenow"), 77, "aria-valuenow");
el.progressbar("disable");
equals(el.attr("aria-disabled"), "true", "aria-disabled");
el.progressbar("enable");
equals(el.attr("aria-disabled"), "false", "enabled");
});
2008-09-20 17:42:04 +00:00
})(jQuery);