2009-02-02 05:58:49 +00:00
|
|
|
/*
|
|
|
|
* slider_methods.js
|
|
|
|
*/
|
|
|
|
(function($) {
|
|
|
|
|
|
|
|
module("slider: methods");
|
|
|
|
|
2009-02-02 07:13:25 +00:00
|
|
|
test("init", function() {
|
2010-08-27 18:48:17 +00:00
|
|
|
expect(5);
|
2009-02-02 07:13:25 +00:00
|
|
|
|
|
|
|
$("<div></div>").appendTo('body').slider().remove();
|
|
|
|
ok(true, '.slider() called on element');
|
|
|
|
|
|
|
|
$([]).slider().remove();
|
|
|
|
ok(true, '.slider() called on empty collection');
|
|
|
|
|
|
|
|
$('<div></div>').slider().remove();
|
|
|
|
ok(true, '.slider() called on disconnected DOMElement');
|
|
|
|
|
2012-10-23 14:36:42 +00:00
|
|
|
var el = $('<div></div>').slider();
|
|
|
|
el.slider("option", "foo");
|
2009-02-02 07:13:25 +00:00
|
|
|
el.remove();
|
|
|
|
ok(true, 'arbitrary option getter after init');
|
|
|
|
|
2009-11-09 01:50:23 +00:00
|
|
|
$('<div></div>').slider().slider("option", "foo", "bar").remove();
|
2009-02-02 07:13:25 +00:00
|
|
|
ok(true, 'arbitrary option setter after init');
|
2009-02-02 05:58:49 +00:00
|
|
|
});
|
|
|
|
|
2009-02-02 07:13:25 +00:00
|
|
|
test("destroy", function() {
|
2012-07-17 19:04:16 +00:00
|
|
|
expect( 1 );
|
|
|
|
domEqual( "#slider1", function() {
|
|
|
|
$( "#slider1" ).slider().slider( "destroy" );
|
|
|
|
});
|
2009-02-02 05:58:49 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
test("enable", function() {
|
2012-07-17 19:04:16 +00:00
|
|
|
expect( 5 );
|
2012-04-19 02:46:39 +00:00
|
|
|
var el,
|
|
|
|
expected = $('<div></div>').slider(),
|
2009-04-15 02:33:28 +00:00
|
|
|
actual = expected.slider('enable');
|
2012-02-28 14:56:32 +00:00
|
|
|
equal(actual, expected, 'enable is chainable');
|
2009-09-19 15:19:42 +00:00
|
|
|
|
2012-04-19 02:46:39 +00:00
|
|
|
el = $('<div></div>').slider({ disabled: true });
|
2012-11-16 11:47:22 +00:00
|
|
|
ok(el.hasClass('ui-state-disabled'), 'slider has ui-state-disabled class before enable method call');
|
2010-03-17 15:02:18 +00:00
|
|
|
ok(el.hasClass('ui-slider-disabled'), 'slider has ui-slider-disabled class before enable method call');
|
2009-09-19 15:19:42 +00:00
|
|
|
el.slider('enable');
|
2012-11-16 11:47:22 +00:00
|
|
|
ok(!el.hasClass('ui-state-disabled'), 'slider does not have ui-state-disabled class after enable method call');
|
2010-03-17 15:02:18 +00:00
|
|
|
ok(!el.hasClass('ui-slider-disabled'), 'slider does not have ui-slider-disabled class after enable method call');
|
2009-02-02 05:58:49 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
test("disable", function() {
|
2012-07-17 19:04:16 +00:00
|
|
|
expect( 5 );
|
2012-04-19 02:46:39 +00:00
|
|
|
var el,
|
|
|
|
expected = $('<div></div>').slider(),
|
2009-04-15 02:33:28 +00:00
|
|
|
actual = expected.slider('disable');
|
2012-02-28 14:56:32 +00:00
|
|
|
equal(actual, expected, 'disable is chainable');
|
2009-09-19 15:19:42 +00:00
|
|
|
|
2012-04-19 02:46:39 +00:00
|
|
|
el = $('<div></div>').slider({ disabled: false });
|
2012-11-16 11:47:22 +00:00
|
|
|
ok(!el.hasClass('ui-state-disabled'), 'slider does not have ui-state-disabled class before disabled method call');
|
2010-03-17 15:02:18 +00:00
|
|
|
ok(!el.hasClass('ui-slider-disabled'), 'slider does not have ui-slider-disabled class before disable method call');
|
2009-09-19 15:19:42 +00:00
|
|
|
el.slider('disable');
|
2012-11-16 11:47:22 +00:00
|
|
|
ok(el.hasClass('ui-state-disabled'), 'slider has ui-state-disabled class after disable method call');
|
2010-03-17 15:02:18 +00:00
|
|
|
ok(el.hasClass('ui-slider-disabled'), 'slider has ui-slider-disabled class after disable method call');
|
2009-02-02 05:58:49 +00:00
|
|
|
});
|
|
|
|
|
2009-02-02 07:13:25 +00:00
|
|
|
test("value", function() {
|
2012-07-17 19:04:16 +00:00
|
|
|
expect( 17 );
|
2009-09-19 15:34:20 +00:00
|
|
|
$([false, 'min', 'max']).each(function() {
|
|
|
|
var el = $('<div></div>').slider({
|
|
|
|
range: this,
|
|
|
|
value: 5
|
|
|
|
});
|
2012-02-28 14:56:32 +00:00
|
|
|
equal(el.slider('value'), 5, 'range: ' + this + ' slider method get');
|
|
|
|
equal(el.slider('value', 10), el, 'value method is chainable');
|
|
|
|
equal(el.slider('value'), 10, 'range: ' + this + ' slider method set');
|
2009-09-19 15:34:20 +00:00
|
|
|
el.remove();
|
|
|
|
});
|
|
|
|
var el = $('<div></div>').slider({
|
|
|
|
min: -1, value: 0, max: 1
|
|
|
|
});
|
|
|
|
// min with value option vs value method
|
|
|
|
el.slider('option', 'value', -2);
|
2012-02-28 14:56:32 +00:00
|
|
|
equal(el.slider('option', 'value'), -2, 'value option does not respect min');
|
|
|
|
equal(el.slider('value'), -1, 'value method get respects min');
|
|
|
|
equal(el.slider('value', -2), el, 'value method is chainable');
|
|
|
|
equal(el.slider('option', 'value'), -1, 'value method set respects min');
|
2009-09-19 15:34:20 +00:00
|
|
|
// max with value option vs value method
|
|
|
|
el.slider('option', 'value', 2);
|
2012-02-28 14:56:32 +00:00
|
|
|
equal(el.slider('option', 'value'), 2, 'value option does not respect max');
|
|
|
|
equal(el.slider('value'), 1, 'value method get respects max');
|
|
|
|
equal(el.slider('value', 2), el, 'value method is chainable');
|
|
|
|
equal(el.slider('option', 'value'), 1, 'value method set respects max');
|
2009-02-02 07:13:25 +00:00
|
|
|
});
|
|
|
|
|
2011-07-28 12:29:29 +00:00
|
|
|
//test("values", function() {
|
|
|
|
// ok(false, "missing test - untested code is broken code.");
|
|
|
|
//});
|
2009-02-02 07:13:25 +00:00
|
|
|
|
2009-02-02 05:58:49 +00:00
|
|
|
})(jQuery);
|