mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-12-07 06:14:24 +00:00
e7a10c70ae
This helps fix issues that make tooltip tests sometimes fail when run against jQuery 3.2 or newer due to timing differences. Details: * Add the `moduleAfterEach` function ensuring no timers are running. * Attach this function via `common.testWidget`. * Attach this function to most test suites. * Add a tooltip test helper cleaning up leftover timers. * Rename legacy `setup`/`teardown` hooks to `beforeEach`/`afterEach`. Closes gh-1920
45 lines
1.4 KiB
JavaScript
45 lines
1.4 KiB
JavaScript
define( [
|
|
"qunit",
|
|
"jquery",
|
|
"lib/helper",
|
|
"ui/widgets/progressbar"
|
|
], function( QUnit, $, helper ) {
|
|
|
|
QUnit.module( "progressbar: methods", { afterEach: helper.moduleAfterEach } );
|
|
|
|
QUnit.test( "destroy", function( assert ) {
|
|
assert.expect( 1 );
|
|
assert.domEqual( "#progressbar", function() {
|
|
$( "#progressbar" ).progressbar().progressbar( "destroy" );
|
|
} );
|
|
} );
|
|
|
|
QUnit.test( "disable", function( assert ) {
|
|
assert.expect( 3 );
|
|
|
|
var element = $( "#progressbar" ).progressbar().progressbar( "disable" );
|
|
|
|
assert.hasClasses( element.progressbar( "widget" ), "ui-state-disabled" );
|
|
assert.ok( element.progressbar( "widget" ).attr( "aria-disabled" ), "element gets aria-disabled" );
|
|
assert.hasClasses( element.progressbar( "widget" ), "ui-progressbar-disabled" );
|
|
} );
|
|
|
|
QUnit.test( "value", function( assert ) {
|
|
assert.expect( 3 );
|
|
|
|
var element = $( "<div>" ).progressbar( { value: 20 } );
|
|
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" );
|
|
} );
|
|
|
|
QUnit.test( "widget", function( assert ) {
|
|
assert.expect( 2 );
|
|
var element = $( "#progressbar" ).progressbar(),
|
|
widgetElement = element.progressbar( "widget" );
|
|
assert.equal( widgetElement.length, 1, "one element" );
|
|
assert.strictEqual( widgetElement[ 0 ], element[ 0 ], "same element" );
|
|
} );
|
|
|
|
} );
|