diff options
author | Amanpreet Singh <apsdehal@gmail.com> | 2016-04-03 20:23:34 +0530 |
---|---|---|
committer | Amanpreet Singh <apsdehal@gmail.com> | 2016-04-14 00:06:12 +0530 |
commit | e089b1dd491063d016472ac8163560e8320db180 (patch) | |
tree | c56315dfc9817ba13698288bd405b051cea1a48c /tests/unit/checkboxradio/options.js | |
parent | fd1c236c0f85f1fdb5972c243d78cbf720f77434 (diff) | |
download | jquery-ui-e089b1dd491063d016472ac8163560e8320db180.tar.gz jquery-ui-e089b1dd491063d016472ac8163560e8320db180.zip |
Checkboxradio: Shift to use no globals
Diffstat (limited to 'tests/unit/checkboxradio/options.js')
-rw-r--r-- | tests/unit/checkboxradio/options.js | 91 |
1 files changed, 46 insertions, 45 deletions
diff --git a/tests/unit/checkboxradio/options.js b/tests/unit/checkboxradio/options.js index 1f862c242..4f6201ef3 100644 --- a/tests/unit/checkboxradio/options.js +++ b/tests/unit/checkboxradio/options.js @@ -1,25 +1,26 @@ define( [ + "qunit", "jquery", "ui/widgets/checkboxradio" -], function( $ ) { +], function( QUnit, $ ) { -module( "Checkboxradio: options" ); +QUnit.module( "Checkboxradio: options" ); function assertDisabled( checkbox, assert ) { assert.hasClasses( checkbox.checkboxradio( "widget" ), "ui-state-disabled", "label gets ui-state-disabled" ); - strictEqual( checkbox.is( ":disabled" ), true, "checkbox is disabled" ); + assert.strictEqual( checkbox.is( ":disabled" ), true, "checkbox is disabled" ); } function assertEnabled( checkbox, assert ) { assert.lacksClasses( checkbox.checkboxradio( "widget" ), "ui-state-disabled", "label has ui-state-disabled removed when disabled set to false" ); - strictEqual( checkbox.is( ":disabled" ), false, + assert.strictEqual( checkbox.is( ":disabled" ), false, "checkbox has disabled prop removed when disabled set to false" ); } -test( "disabled", function( assert ) { - expect( 6 ); +QUnit.test( "disabled", function( assert ) { + assert.expect( 6 ); var checkbox = $( "#checkbox-option-disabled" ); checkbox.checkboxradio( { @@ -35,8 +36,8 @@ test( "disabled", function( assert ) { assertDisabled( checkbox, assert ); } ); -test( "disabled - prop true on init", function( assert ) { - expect( 2 ); +QUnit.test( "disabled - prop true on init", function( assert ) { + assert.expect( 2 ); var checkbox = $( "#checkbox-option-disabled" ); checkbox.prop( "disabled", true ); @@ -45,8 +46,8 @@ test( "disabled - prop true on init", function( assert ) { assertDisabled( checkbox, assert ); } ); -test( "disabled - explicit null value, checks the DOM", function( assert ) { - expect( 2 ); +QUnit.test( "disabled - explicit null value, checks the DOM", function( assert ) { + assert.expect( 2 ); var checkbox = $( "#checkbox-option-disabled" ); checkbox.prop( "disabled", true ); @@ -56,8 +57,8 @@ test( "disabled - explicit null value, checks the DOM", function( assert ) { assertDisabled( checkbox, assert ); } ); -function assertNoIcon( checkbox ) { - strictEqual( checkbox.checkboxradio( "widget" ).find( "span.ui-icon" ).length, 0, +function assertNoIcon( assert, checkbox ) { + assert.strictEqual( checkbox.checkboxradio( "widget" ).find( "span.ui-icon" ).length, 0, "Label does not contain an icon" ); } @@ -65,7 +66,7 @@ function assertIcon( checkbox, icon, assert ) { var iconElement = checkbox.checkboxradio( "widget" ).find( ".ui-icon" ); icon = icon || "blank"; - strictEqual( iconElement.length, 1, + assert.strictEqual( iconElement.length, 1, "Label contains icon" ); assert.hasClasses( iconElement, "ui-checkboxradio-icon ui-corner-all ui-icon " + "ui-icon-background ui-icon-" + icon, @@ -75,37 +76,37 @@ function assertIcon( checkbox, icon, assert ) { } } -test( "icon - false on init", function() { +QUnit.test( "icon - false on init", function( assert ) { var checkbox = $( "#checkbox-option-icon" ); - expect( 1 ); + assert.expect( 1 ); checkbox.checkboxradio( { icon: false } ); - assertNoIcon( checkbox ); + assertNoIcon( assert, checkbox ); } ); -test( "icon - default unchecked", function( assert ) { +QUnit.test( "icon - default unchecked", function( assert ) { var checkbox = $( "#checkbox-option-icon" ); - expect( 3 ); + assert.expect( 3 ); checkbox.checkboxradio(); assertIcon( checkbox, false, assert ); } ); -test( "icon - default checked", function( assert ) { +QUnit.test( "icon - default checked", function( assert ) { var checkbox = $( "#checkbox-option-icon" ).attr( "checked", true ); - expect( 2 ); + assert.expect( 2 ); checkbox.checkboxradio(); assertIcon( checkbox, "check ui-state-highlight", assert ); } ); -test( "icon", function( assert ) { +QUnit.test( "icon", function( assert ) { var checkbox = $( "#checkbox-option-icon" ); - expect( 9 ); + assert.expect( 9 ); checkbox.prop( "checked", true ); @@ -113,35 +114,35 @@ test( "icon", function( assert ) { assertIcon( checkbox, "check ui-state-highlight", assert ); checkbox.checkboxradio( "option", "icon", false ); - assertNoIcon( checkbox ); + assertNoIcon( assert, checkbox ); checkbox.checkboxradio( "option", "icon", true ); assertIcon( checkbox, "check ui-state-highlight", assert ); checkbox.checkboxradio( "option", "icon", false ); - assertNoIcon( checkbox ); + assertNoIcon( assert, checkbox ); checkbox.checkboxradio( "option", "icon", true ); checkbox.prop( "checked", false ).checkboxradio( "refresh" ); assertIcon( checkbox, false, assert ); } ); -test( "label - default", function() { +QUnit.test( "label - default", function( assert ) { var checkbox = $( "#checkbox-option-label" ), widget; - expect( 2 ); + assert.expect( 2 ); checkbox.checkboxradio(); widget = checkbox.checkboxradio( "widget" ); - strictEqual( checkbox.checkboxradio( "option", "label" ), + assert.strictEqual( checkbox.checkboxradio( "option", "label" ), "checkbox label", "When no value passed on create text from dom is used for option" ); - strictEqual( $.trim( widget.text() ), + assert.strictEqual( $.trim( widget.text() ), "checkbox label", "When no value passed on create text from dom is used in dom" ); } ); -test( "label - explicit value", function() { - expect( 5 ); +QUnit.test( "label - explicit value", function( assert ) { + assert.expect( 5 ); var checkbox = $( "#checkbox-option-label" ).checkboxradio( { label: "foo" } ), @@ -149,23 +150,23 @@ test( "label - explicit value", function() { icon = widget.find( ".ui-icon" ), iconSpace = widget.find( ".ui-checkboxradio-icon-space" ); - strictEqual( checkbox.checkboxradio( "option", "label" ), + assert.strictEqual( checkbox.checkboxradio( "option", "label" ), "foo", "When value is passed on create value is used for option" ); - strictEqual( $.trim( widget.text() ), + assert.strictEqual( $.trim( widget.text() ), "foo", "When value is passed on create value is used in dom" ); - strictEqual( icon.length, 1, + assert.strictEqual( icon.length, 1, "Icon is preserved when label is set on init when wrapped in label" ); - strictEqual( iconSpace.length, 1, + assert.strictEqual( iconSpace.length, 1, "Icon space is preserved when label is set on init when wrapped in label" ); - strictEqual( $( "#checkbox-option-label" ).length, 1, + assert.strictEqual( $( "#checkbox-option-label" ).length, 1, "Element is preserved when label is set on init when wrapped in label" ); } ); -test( "label - explicit null value", function() { +QUnit.test( "label - explicit null value", function( assert ) { var checkbox = $( "#checkbox-option-label" ), widget; - expect( 2 ); + assert.expect( 2 ); // The default null is a special value which means to check the DOM. // We need to make sure that the option never return null. @@ -174,15 +175,15 @@ test( "label - explicit null value", function() { label: null } ); widget = checkbox.checkboxradio( "widget" ); - strictEqual( checkbox.checkboxradio( "option", "label" ), + assert.strictEqual( checkbox.checkboxradio( "option", "label" ), "checkbox label", "When null is passed on create text from dom is used for option" ); - strictEqual( $.trim( widget.text() ), + assert.strictEqual( $.trim( widget.text() ), "checkbox label", "When null is passed on create text from dom is used in dom" ); } ); -test( "label", function() { - expect( 4 ); +QUnit.test( "label", function( assert ) { + assert.expect( 4 ); var checkbox = $( "#checkbox-option-label" ), widget; @@ -190,15 +191,15 @@ test( "label", function() { checkbox.checkboxradio(); widget = checkbox.checkboxradio( "widget" ); checkbox.checkboxradio( "option", "label", "bar" ); - strictEqual( checkbox.checkboxradio( "option", "label" ), + assert.strictEqual( checkbox.checkboxradio( "option", "label" ), "bar", "When value is passed value is used for option" ); - strictEqual( $.trim( widget.text() ), + assert.strictEqual( $.trim( widget.text() ), "bar", "When value is passed value is used in dom" ); checkbox.checkboxradio( "option", "label", null ); - strictEqual( checkbox.checkboxradio( "option", "label" ), + assert.strictEqual( checkbox.checkboxradio( "option", "label" ), "bar", "When null is passed text from dom is used for option" ); - strictEqual( $.trim( widget.text() ), + assert.strictEqual( $.trim( widget.text() ), "bar", "When null is passed text from dom is used in dom" ); } ); |