diff options
author | Amanpreet Singh <apsdehal@gmail.com> | 2016-04-03 20:13:27 +0530 |
---|---|---|
committer | Amanpreet Singh <apsdehal@gmail.com> | 2016-04-14 00:06:11 +0530 |
commit | f375fd1300b4e08c0e71a073131260dfb8e5762f (patch) | |
tree | 467dcec8f29c8cc272946545c4264f21b8e580b4 /tests/unit/button/options.js | |
parent | d83db4f5284df9fd80c3a98b1a3c5b6ca31b0c9a (diff) | |
download | jquery-ui-f375fd1300b4e08c0e71a073131260dfb8e5762f.tar.gz jquery-ui-f375fd1300b4e08c0e71a073131260dfb8e5762f.zip |
Button: Shift to no globals
Diffstat (limited to 'tests/unit/button/options.js')
-rw-r--r-- | tests/unit/button/options.js | 135 |
1 files changed, 68 insertions, 67 deletions
diff --git a/tests/unit/button/options.js b/tests/unit/button/options.js index 6ef166974..7d6547ff1 100644 --- a/tests/unit/button/options.js +++ b/tests/unit/button/options.js @@ -1,66 +1,67 @@ define( [ + "qunit", "jquery", "ui/widgets/button" -], function( $ ) { +], function( QUnit, $ ) { -module( "button: options" ); +QUnit.module( "button: options" ); -test( "disabled, explicit value", function( assert ) { - expect( 8 ); +QUnit.test( "disabled, explicit value", function( assert ) { + assert.expect( 8 ); var element = $( "#button" ).button( { disabled: false } ); - strictEqual( element.button( "option", "disabled" ), false, "disabled option set to false" ); - strictEqual( element.prop( "disabled" ), false, "Disabled property is false" ); + assert.strictEqual( element.button( "option", "disabled" ), false, "disabled option set to false" ); + assert.strictEqual( element.prop( "disabled" ), false, "Disabled property is false" ); assert.lacksClasses( element.button( "widget" ), "ui-state-disabled ui-button-disabled" ); element = $( "#button" ).button( { disabled: true } ); assert.hasClasses( element.button( "widget" ), "ui-state-disabled" ); - strictEqual( element.button( "widget" ).attr( "aria-disabled" ), undefined, + assert.strictEqual( element.button( "widget" ).attr( "aria-disabled" ), undefined, "element does not get aria-disabled" ); assert.hasClasses( element.button( "widget" ), "ui-button-disabled" ); - strictEqual( element.button( "option", "disabled" ), true, "disabled option set to true" ); - strictEqual( element.prop( "disabled" ), true, "Disabled property is set" ); + assert.strictEqual( element.button( "option", "disabled" ), true, "disabled option set to true" ); + assert.strictEqual( element.prop( "disabled" ), true, "Disabled property is set" ); } ); // We are testing the default here because the default null is a special value which means to check // the DOM. We need to make sure this happens correctly. Checking the options should never return // null, it should always be true or false. -test( "disabled, null", function() { - expect( 4 ); +QUnit.test( "disabled, null", function( assert ) { + assert.expect( 4 ); var element = $( "#button" ), elementDisabled = $( "#button-disabled" ); element.add( elementDisabled ).button( { disabled: null } ); - strictEqual( element.button( "option", "disabled" ), false, "disabled option set to false" ); - strictEqual( element.prop( "disabled" ), false, "element is disabled" ); - strictEqual( elementDisabled.button( "option", "disabled" ), true, + assert.strictEqual( element.button( "option", "disabled" ), false, "disabled option set to false" ); + assert.strictEqual( element.prop( "disabled" ), false, "element is disabled" ); + assert.strictEqual( elementDisabled.button( "option", "disabled" ), true, "disabled option set to true" ); - strictEqual( elementDisabled.prop( "disabled" ), true, "element is disabled" ); + assert.strictEqual( elementDisabled.prop( "disabled" ), true, "element is disabled" ); } ); -test( "showLabel, false, without icon", function( assert ) { - expect( 4 ); +QUnit.test( "showLabel, false, without icon", function( assert ) { + assert.expect( 4 ); var button = $( "#button" ).button( { showLabel: false } ); assert.lacksClasses( button, "ui-button-icon-only" ); - strictEqual( button.button( "option", "showLabel" ), true, + assert.strictEqual( button.button( "option", "showLabel" ), true, "showLabel false only allowed if icon true" ); button.button( "option", "showLabel", false ); assert.lacksClasses( button, "ui-button-icon-only" ); - strictEqual( button.button( "option", "showLabel" ), true, + assert.strictEqual( button.button( "option", "showLabel" ), true, "showLabel false only allowed if icon true" ); } ); -test( "showLabel, false, with icon", function( assert ) { - expect( 1 ); +QUnit.test( "showLabel, false, with icon", function( assert ) { + assert.expect( 1 ); var button = $( "#button" ).button( { showLabel: false, icon: "iconclass" @@ -68,53 +69,53 @@ test( "showLabel, false, with icon", function( assert ) { assert.hasClasses( button, "ui-button ui-corner-all ui-widget ui-button-icon-only" ); } ); -test( "label, default", function() { - expect( 2 ); +QUnit.test( "label, default", function( assert ) { + assert.expect( 2 ); var button = $( "#button" ).button(); - deepEqual( button.text(), "Label" ); - deepEqual( button.button( "option", "label" ), "Label" ); + assert.deepEqual( button.text(), "Label" ); + assert.deepEqual( button.button( "option", "label" ), "Label" ); } ); -test( "label, with html markup", function() { - expect( 3 ); +QUnit.test( "label, with html markup", function( assert ) { + assert.expect( 3 ); var button = $( "#button2" ).button(); - deepEqual( button.text(), "label with span" ); - deepEqual( button.html().toLowerCase(), "label <span>with span</span>" ); - deepEqual( button.button( "option", "label" ).toLowerCase(), "label <span>with span</span>" ); + assert.deepEqual( button.text(), "label with span" ); + assert.deepEqual( button.html().toLowerCase(), "label <span>with span</span>" ); + assert.deepEqual( button.button( "option", "label" ).toLowerCase(), "label <span>with span</span>" ); } ); -test( "label, explicit value", function() { - expect( 2 ); +QUnit.test( "label, explicit value", function( assert ) { + assert.expect( 2 ); var button = $( "#button" ).button( { label: "xxx" } ); - deepEqual( button.text(), "xxx" ); - deepEqual( button.button( "option", "label" ), "xxx" ); + assert.deepEqual( button.text(), "xxx" ); + assert.deepEqual( button.button( "option", "label" ), "xxx" ); } ); -test( "label, default, with input type submit", function() { - expect( 2 ); +QUnit.test( "label, default, with input type submit", function( assert ) { + assert.expect( 2 ); var button = $( "#submit" ).button(); - deepEqual( button.val(), "Label" ); - deepEqual( button.button( "option", "label" ), "Label" ); + assert.deepEqual( button.val(), "Label" ); + assert.deepEqual( button.button( "option", "label" ), "Label" ); } ); -test( "label, explicit value, with input type submit", function() { - expect( 2 ); +QUnit.test( "label, explicit value, with input type submit", function( assert ) { + assert.expect( 2 ); var button = $( "#submit" ).button( { label: "xxx" } ); - deepEqual( button.val(), "xxx" ); - deepEqual( button.button( "option", "label" ), "xxx" ); + assert.deepEqual( button.val(), "xxx" ); + assert.deepEqual( button.button( "option", "label" ), "xxx" ); } ); -test( "icon", function( assert ) { - expect( 4 ); +QUnit.test( "icon", function( assert ) { + assert.expect( 4 ); var button = $( "#button" ).button( { showLabel: false, icon: "iconclass" @@ -122,18 +123,18 @@ test( "icon", function( assert ) { icon = button.find( ".ui-icon" ); assert.hasClasses( icon, "iconclass" ); - equal( icon.length, 1, "button with icon option set has icon" ); + assert.equal( icon.length, 1, "button with icon option set has icon" ); button.button( "option", "icon", false ); - equal( button.find( ".ui-icon" ).length, 0, "setting icon to false removes the icon" ); + assert.equal( button.find( ".ui-icon" ).length, 0, "setting icon to false removes the icon" ); button.button( "option", "icon", "iconclass" ); - ok( button.find( ".ui-icon" ).length, "setting icon to a value adds the icon" ); + assert.ok( button.find( ".ui-icon" ).length, "setting icon to a value adds the icon" ); } ); -test( "icon position", function( assert ) { - expect( 22 ); +QUnit.test( "icon position", function( assert ) { + assert.expect( 22 ); var button = $( "#button" ).button( { icon: "ui-icon-gear" @@ -141,41 +142,41 @@ test( "icon position", function( assert ) { icon = button.find( ".ui-icon" ), space = button.find( ".ui-button-icon-space" ); - equal( icon.length, 1, "button with icon option set has icon" ); - equal( button.button( "option", "iconPosition" ), "beginning", + assert.equal( icon.length, 1, "button with icon option set has icon" ); + assert.equal( button.button( "option", "iconPosition" ), "beginning", "Button has iconPosition beginning by default" ); - equal( button.contents()[ 0 ], icon[ 0 ], "icon is prepended when position is begining" ); - equal( icon.next()[ 0 ], space[ 0 ], "icon is followed by a space when position is begining" ); - equal( space.length, 1, + assert.equal( button.contents()[ 0 ], icon[ 0 ], "icon is prepended when position is begining" ); + assert.equal( icon.next()[ 0 ], space[ 0 ], "icon is followed by a space when position is begining" ); + assert.equal( space.length, 1, "ui-button-icon-space contains a breaking space iconPosition:beginning" ); assert.lacksClasses( icon, "ui-widget-icon-block" ); button.button( "option", "iconPosition", "end" ); icon = button.find( ".ui-icon" ); space = button.find( ".ui-button-icon-space" ); - equal( icon.length, 1, "Changing position to end does not re-create or duplicate icon" ); - equal( button.button( "option", "iconPosition" ), "end", "Button has iconPosition end" ); - equal( button.contents().last()[ 0 ], icon[ 0 ], "icon is appended when position is end" ); - equal( icon.prev()[ 0 ], space[ 0 ], "icon is preceeded by a space when position is end" ); - equal( space.length, 1, + assert.equal( icon.length, 1, "Changing position to end does not re-create or duplicate icon" ); + assert.equal( button.button( "option", "iconPosition" ), "end", "Button has iconPosition end" ); + assert.equal( button.contents().last()[ 0 ], icon[ 0 ], "icon is appended when position is end" ); + assert.equal( icon.prev()[ 0 ], space[ 0 ], "icon is preceeded by a space when position is end" ); + assert.equal( space.length, 1, "ui-button-icon-space contains a breaking space iconPosition:beginning" ); assert.lacksClasses( icon, "ui-widget-icon-block" ); button.button( "option", "iconPosition", "top" ); icon = button.find( ".ui-icon" ); - equal( icon.length, 1, "Changing position to top does not re-create or duplicate icon" ); - equal( button.button( "option", "iconPosition" ), "top", "Button has iconPosition top" ); - equal( button.contents()[ 0 ], icon[ 0 ], "icon is prepended when position is top" ); - ok( !button.find( "ui-button-icon-space" ).length, + assert.equal( icon.length, 1, "Changing position to top does not re-create or duplicate icon" ); + assert.equal( button.button( "option", "iconPosition" ), "top", "Button has iconPosition top" ); + assert.equal( button.contents()[ 0 ], icon[ 0 ], "icon is prepended when position is top" ); + assert.ok( !button.find( "ui-button-icon-space" ).length, "Button should not have an iconSpace with position: top" ); assert.hasClasses( icon, "ui-widget-icon-block" ); button.button( "option", "iconPosition", "bottom" ); icon = button.find( ".ui-icon" ); - equal( icon.length, 1, "Changing position to bottom does not re-create or duplicate icon" ); - equal( button.button( "option", "iconPosition" ), "bottom", "Button has iconPosition top" ); - equal( button.contents().last()[ 0 ], icon[ 0 ], "icon is prepended when position is bottom" ); - ok( !button.find( "ui-button-icon-space" ).length, + assert.equal( icon.length, 1, "Changing position to bottom does not re-create or duplicate icon" ); + assert.equal( button.button( "option", "iconPosition" ), "bottom", "Button has iconPosition top" ); + assert.equal( button.contents().last()[ 0 ], icon[ 0 ], "icon is prepended when position is bottom" ); + assert.ok( !button.find( "ui-button-icon-space" ).length, "Button should not have an iconSpace with position: bottom" ); assert.hasClasses( icon, "ui-widget-icon-block" ); |