jquery-ui/tests/unit/progressbar/methods.js

46 lines
1.5 KiB
JavaScript
Raw Normal View History

define( [
2016-04-06 13:08:28 +00:00
"qunit",
"jquery",
"lib/helper",
"ui/widgets/progressbar"
], function( QUnit, $, helper ) {
"use strict";
QUnit.module( "progressbar: methods", { afterEach: helper.moduleAfterEach } );
2016-04-06 13:08:28 +00:00
QUnit.test( "destroy", function( assert ) {
assert.expect( 1 );
assert.domEqual( "#progressbar", function() {
2012-05-26 03:10:46 +00:00
$( "#progressbar" ).progressbar().progressbar( "destroy" );
2015-08-24 12:58:48 +00:00
} );
} );
2016-04-06 13:08:28 +00:00
QUnit.test( "disable", function( assert ) {
assert.expect( 3 );
var element = $( "#progressbar" ).progressbar().progressbar( "disable" );
assert.hasClasses( element.progressbar( "widget" ), "ui-state-disabled" );
2016-04-06 13:08:28 +00:00
assert.ok( element.progressbar( "widget" ).attr( "aria-disabled" ), "element gets aria-disabled" );
assert.hasClasses( element.progressbar( "widget" ), "ui-progressbar-disabled" );
2015-08-24 12:58:48 +00:00
} );
2016-04-06 13:08:28 +00:00
QUnit.test( "value", function( assert ) {
assert.expect( 3 );
2015-08-24 12:58:48 +00:00
var element = $( "<div>" ).progressbar( { value: 20 } );
2016-04-06 13:08:28 +00:00
assert.equal( element.progressbar( "value" ), 20, "correct value as getter" );
assert.strictEqual( element.progressbar( "value", 30 ), element, "chainable as setter" );
assert.equal( element.progressbar( "option", "value" ), 30, "correct value after setter" );
2015-08-24 12:58:48 +00:00
} );
2016-04-06 13:08:28 +00:00
QUnit.test( "widget", function( assert ) {
assert.expect( 2 );
var element = $( "#progressbar" ).progressbar(),
widgetElement = element.progressbar( "widget" );
2016-04-06 13:08:28 +00:00
assert.equal( widgetElement.length, 1, "one element" );
assert.strictEqual( widgetElement[ 0 ], element[ 0 ], "same element" );
2015-08-24 12:58:48 +00:00
} );
} );