diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/bootstrap.js | 8 | ||||
-rw-r--r-- | tests/lib/common.js | 4 | ||||
-rw-r--r-- | tests/lib/qunit.js | 3 | ||||
-rw-r--r-- | tests/unit/checkboxradio/options.js | 10 | ||||
-rw-r--r-- | tests/unit/core/core.js | 5 | ||||
-rw-r--r-- | tests/unit/dialog/deprecated.js | 2 | ||||
-rw-r--r-- | tests/unit/dialog/options.js | 22 | ||||
-rw-r--r-- | tests/unit/draggable/options.js | 11 | ||||
-rw-r--r-- | tests/unit/effects/core.js | 2 | ||||
-rw-r--r-- | tests/unit/menu/helper.js | 2 | ||||
-rw-r--r-- | tests/unit/selectmenu/core.js | 14 | ||||
-rw-r--r-- | tests/unit/selectmenu/methods.js | 8 | ||||
-rw-r--r-- | tests/unit/subsuite.js | 5 | ||||
-rw-r--r-- | tests/unit/widget/core.js | 10 | ||||
-rw-r--r-- | tests/visual/dialog/performance.html | 2 |
15 files changed, 62 insertions, 46 deletions
diff --git a/tests/lib/bootstrap.js b/tests/lib/bootstrap.js index 487b3b807..27c1b610f 100644 --- a/tests/lib/bootstrap.js +++ b/tests/lib/bootstrap.js @@ -104,8 +104,8 @@ function jqueryUrl() { var version = parseUrl().jquery || DEFAULT_JQUERY_VERSION; var url; - if ( version === "git" ) { - url = "http://code.jquery.com/jquery-" + version; + if ( version === "git" || version === "3.x-git" ) { + url = "https://code.jquery.com/jquery-" + version; } else { url = "../../../external/jquery-" + version + "/jquery"; } @@ -118,9 +118,9 @@ function migrateUrl() { var url; if ( jqueryVersion === "git" ) { - url = "http://code.jquery.com/jquery-migrate-git"; + url = "https://code.jquery.com/jquery-migrate-git"; } else if ( jqueryVersion[ 0 ] === "3" ) { - url = "../../../external/jquery-migrate-3.0.0/jquery-migrate"; + url = "../../../external/jquery-migrate-3.1.0/jquery-migrate"; } else if ( jqueryVersion[ 0 ] === "1" || jqueryVersion[ 0 ] === "2" ) { url = "../../../external/jquery-migrate-1.4.1/jquery-migrate"; } else if ( jqueryVersion === "custom" ) { diff --git a/tests/lib/common.js b/tests/lib/common.js index 57b7768cf..7d3b3db2a 100644 --- a/tests/lib/common.js +++ b/tests/lib/common.js @@ -13,8 +13,8 @@ function testWidgetDefaults( widget, defaults ) { var count = 0; $.each( defaults, function( key, val ) { assert.expect( ++count ); - if ( $.isFunction( val ) ) { - assert.ok( $.isFunction( pluginDefaults[ key ] ), key ); + if ( typeof val === "function" ) { + assert.ok( typeof pluginDefaults[ key ] === "function", key ); return; } assert.deepEqual( pluginDefaults[ key ], val, key ); diff --git a/tests/lib/qunit.js b/tests/lib/qunit.js index c16d31154..4c5ec3812 100644 --- a/tests/lib/qunit.js +++ b/tests/lib/qunit.js @@ -31,6 +31,9 @@ QUnit.config.urlConfig.push( { "2.2.0", "2.2.1", "2.2.2", "2.2.3", "2.2.4", "3.0.0", "3.1.0", "3.1.1", + "3.2.0", "3.2.1", + "3.3.0", "3.3.1", + "3.4.0", "3.4.1", "git", "custom" ], tooltip: "Which jQuery Core version to test against" diff --git a/tests/unit/checkboxradio/options.js b/tests/unit/checkboxradio/options.js index 7fe6a0710..c0fc333c3 100644 --- a/tests/unit/checkboxradio/options.js +++ b/tests/unit/checkboxradio/options.js @@ -137,7 +137,7 @@ QUnit.test( "label - default", function( assert ) { widget = checkbox.checkboxradio( "widget" ); assert.strictEqual( checkbox.checkboxradio( "option", "label" ), "checkbox label", "When no value passed on create text from dom is used for option" ); - assert.strictEqual( $.trim( widget.text() ), + assert.strictEqual( String.prototype.trim.call( widget.text() ), "checkbox label", "When no value passed on create text from dom is used in dom" ); } ); @@ -152,7 +152,7 @@ QUnit.test( "label - explicit value", function( assert ) { assert.strictEqual( checkbox.checkboxradio( "option", "label" ), "foo", "When value is passed on create value is used for option" ); - assert.strictEqual( $.trim( widget.text() ), + assert.strictEqual( String.prototype.trim.call( widget.text() ), "foo", "When value is passed on create value is used in dom" ); assert.strictEqual( icon.length, 1, "Icon is preserved when label is set on init when wrapped in label" ); @@ -177,7 +177,7 @@ QUnit.test( "label - explicit null value", function( assert ) { widget = checkbox.checkboxradio( "widget" ); assert.strictEqual( checkbox.checkboxradio( "option", "label" ), "checkbox label", "When null is passed on create text from dom is used for option" ); - assert.strictEqual( $.trim( widget.text() ), + assert.strictEqual( String.prototype.trim.call( widget.text() ), "checkbox label", "When null is passed on create text from dom is used in dom" ); } ); @@ -193,13 +193,13 @@ QUnit.test( "label", function( assert ) { checkbox.checkboxradio( "option", "label", "bar" ); assert.strictEqual( checkbox.checkboxradio( "option", "label" ), "bar", "When value is passed value is used for option" ); - assert.strictEqual( $.trim( widget.text() ), + assert.strictEqual( String.prototype.trim.call( widget.text() ), "bar", "When value is passed value is used in dom" ); checkbox.checkboxradio( "option", "label", null ); assert.strictEqual( checkbox.checkboxradio( "option", "label" ), "bar", "When null is passed text from dom is used for option" ); - assert.strictEqual( $.trim( widget.text() ), + assert.strictEqual( String.prototype.trim.call( widget.text() ), "bar", "When null is passed text from dom is used in dom" ); } ); diff --git a/tests/unit/core/core.js b/tests/unit/core/core.js index b5b6b3b81..acfc291ff 100644 --- a/tests/unit/core/core.js +++ b/tests/unit/core/core.js @@ -152,8 +152,9 @@ QUnit.test( "Labels", function( assert ) { var found = labels.map( function() { // Support: Core 1.9 Only - // We use $.trim() because core 1.9.x silently fails when white space is present - return $.trim( $( this ).text() ); + // We use String.prototype.trim because core 1.9.x silently fails + // when white space is present + return String.prototype.trim.call( $( this ).text() ); } ).get(); assert.deepEqual( found, expected, diff --git a/tests/unit/dialog/deprecated.js b/tests/unit/dialog/deprecated.js index 973a90893..eac0e123d 100644 --- a/tests/unit/dialog/deprecated.js +++ b/tests/unit/dialog/deprecated.js @@ -50,7 +50,7 @@ QUnit.test( "buttons - deprecated options", function( assert ) { buttons = element.dialog( "widget" ).find( ".ui-dialog-buttonpane button" ); assert.equal( buttons.length, 1, "correct number of buttons" ); assert.equal( buttons.attr( "id" ), "my-button-id", "correct id" ); - assert.equal( $.trim( buttons.text() ), "a button", "correct label" ); + assert.equal( String.prototype.trim.call( buttons.text() ), "a button", "correct label" ); assert.hasClasses( buttons, "additional-class" ); assert.deepEqual( buttons.button( "option", "icon" ), "ui-icon-cancel" ); assert.equal( buttons.button( "option", "showLabel" ), false ); diff --git a/tests/unit/dialog/options.js b/tests/unit/dialog/options.js index 1be2888e3..4d8e4f717 100644 --- a/tests/unit/dialog/options.js +++ b/tests/unit/dialog/options.js @@ -166,7 +166,7 @@ QUnit.test( "buttons - advanced", function( assert ) { buttons = element.dialog( "widget" ).find( ".ui-dialog-buttonpane button" ); assert.equal( buttons.length, 1, "correct number of buttons" ); assert.equal( buttons.attr( "id" ), "my-button-id", "correct id" ); - assert.equal( $.trim( buttons.text() ), "a button", "correct label" ); + assert.equal( String.prototype.trim.call( buttons.text() ), "a button", "correct label" ); assert.hasClasses( buttons, "additional-class" ); assert.deepEqual( buttons.button( "option", "icon" ), "ui-icon-cancel" ); assert.equal( buttons.button( "option", "showLabel" ), false ); @@ -210,22 +210,22 @@ QUnit.test( "closeText", function( assert ) { assert.expect( 4 ); var element = $( "<div></div>" ).dialog(); - assert.equal( $.trim( element.dialog( "widget" ).find( ".ui-dialog-titlebar-close" ).text() ), "Close", + assert.equal( String.prototype.trim.call( element.dialog( "widget" ).find( ".ui-dialog-titlebar-close" ).text() ), "Close", "default close text" ); element.remove(); element = $( "<div></div>" ).dialog( { closeText: "foo" } ); - assert.equal( $.trim( element.dialog( "widget" ).find( ".ui-dialog-titlebar-close" ).text() ), "foo", + assert.equal( String.prototype.trim.call( element.dialog( "widget" ).find( ".ui-dialog-titlebar-close" ).text() ), "foo", "closeText on init" ); element.remove(); element = $( "<div></div>" ).dialog().dialog( "option", "closeText", "bar" ); - assert.equal( $.trim( element.dialog( "widget" ).find( ".ui-dialog-titlebar-close" ).text() ), "bar", + assert.equal( String.prototype.trim.call( element.dialog( "widget" ).find( ".ui-dialog-titlebar-close" ).text() ), "bar", "closeText via option method" ); element.remove(); element = $( "<div></div>" ).dialog( { closeText: "<span>foo</span>" } ); - assert.equal( $.trim( element.dialog( "widget" ).find( ".ui-dialog-titlebar-close" ).text() ), "<span>foo</span>", + assert.equal( String.prototype.trim.call( element.dialog( "widget" ).find( ".ui-dialog-titlebar-close" ).text() ), "<span>foo</span>", "closeText is escaped" ); element.remove(); } ); @@ -251,21 +251,25 @@ QUnit.test( "height", function( assert ) { assert.expect( 4 ); var element = $( "<div></div>" ).dialog(); - assert.equal( element.dialog( "widget" ).outerHeight(), 150, "default height" ); + assert.ok( Math.abs( element.dialog( "widget" ).outerHeight() - 150 ) < 0.25, + "default height within 0.25 from expected" ); element.remove(); element = $( "<div></div>" ).dialog( { height: 237 } ); - assert.equal( element.dialog( "widget" ).outerHeight(), 237, "explicit height" ); + assert.ok( Math.abs( element.dialog( "widget" ).outerHeight() - 237 ) < 0.25, + "explicit height within 0.25 from expected" ); element.remove(); element = $( "<div></div>" ).dialog(); element.dialog( "option", "height", 238 ); - assert.equal( element.dialog( "widget" ).outerHeight(), 238, "explicit height set after init" ); + assert.ok( Math.abs( element.dialog( "widget" ).outerHeight() - 238 ) < 0.25, + "explicit height set after init within 0.25 from expected" ); element.remove(); element = $( "<div></div>" ).css( "padding", "20px" ) .dialog( { height: 240 } ); - assert.equal( element.dialog( "widget" ).outerHeight(), 240, "explicit height with padding" ); + assert.ok( Math.abs( element.dialog( "widget" ).outerHeight() - 240 ) < 0.25, + "explicit height with padding within 0.25 from expected" ); element.remove(); } ); diff --git a/tests/unit/draggable/options.js b/tests/unit/draggable/options.js index 656df621f..ff72f9d02 100644 --- a/tests/unit/draggable/options.js +++ b/tests/unit/draggable/options.js @@ -252,9 +252,9 @@ QUnit.test( "cancelement, default, switching after initialization", function( as } ); QUnit.test( "connectToSortable, dragging out of a sortable", function( assert ) { - assert.expect( 4 ); + assert.expect( 5 ); - var sortItem, dragHelper, + var sortItem, dragHelper, result, element = $( "#draggableSortable" ).draggable( { scroll: false, connectToSortable: "#sortable" @@ -280,7 +280,12 @@ QUnit.test( "connectToSortable, dragging out of a sortable", function( assert ) // http://bugs.jqueryui.com/ticket/8809 // Position issue when connected to sortable - assert.deepEqual( ui.helper.offset(), offsetExpected, "draggable offset is correct" ); + result = ui.helper.offset(); + + // Support: Chrome <=45 - 73+ + // In recent Chrome these values differ a little. + assert.ok( Math.abs( result.top - offsetExpected.top ) < 0.25, "draggable offset is within 0.25 of expected" ); + assert.ok( Math.abs( result.left - offsetExpected.left ) < 0.25, "draggable offset is within 0.25 of expected" ); // Http://bugs.jqueryui.com/ticket/7734 // HTML IDs are removed when dragging to a Sortable diff --git a/tests/unit/effects/core.js b/tests/unit/effects/core.js index 9863cd8ca..d095bfbd5 100644 --- a/tests/unit/effects/core.js +++ b/tests/unit/effects/core.js @@ -210,7 +210,7 @@ QUnit.test( "animateClass clears style properties when stopped", function( asser .stop( true, true ) .promise() .then( function() { - assert.equal( orig, $.trim( style.cssText ), "cssText is the same after stopping animation midway" ); + assert.equal( orig, String.prototype.trim.call( style.cssText ), "cssText is the same after stopping animation midway" ); ready(); } ); } ); diff --git a/tests/unit/menu/helper.js b/tests/unit/menu/helper.js index 445663985..1e4a21485 100644 --- a/tests/unit/menu/helper.js +++ b/tests/unit/menu/helper.js @@ -14,7 +14,7 @@ return $.extend( helper, { if ( message === undefined ) { message = lastItem; } - log.push( $.trim( message ) ); + log.push( String.prototype.trim.call( message ) ); }, logOutput: function() { diff --git a/tests/unit/selectmenu/core.js b/tests/unit/selectmenu/core.js index 708452312..b0f56f3b3 100644 --- a/tests/unit/selectmenu/core.js +++ b/tests/unit/selectmenu/core.js @@ -95,7 +95,7 @@ QUnit.test( "_renderButtonItem()", function( assert ) { element.selectmenu( "refresh" ); option = element.find( "option:selected" ); assert.equal( - $.trim( button.text() ), + String.prototype.trim.call( button.text() ), option.text() + element[ 0 ].selectedIndex, "refresh: button item text" ); @@ -104,7 +104,7 @@ QUnit.test( "_renderButtonItem()", function( assert ) { menu.find( "li" ).last().simulate( "mouseover" ).trigger( "click" ); option = element.find( "option" ).last(); assert.equal( - $.trim( button.text() ), + String.prototype.trim.call( button.text() ), option.text() + element[ 0 ].selectedIndex, "click: button item text" ); @@ -153,7 +153,7 @@ $.each( [ selected.val(), "original select state" ); - assert.equal( $.trim( button.text() ), selected.text(), "button text" ); + assert.equal( String.prototype.trim.call( button.text() ), selected.text(), "button text" ); ready(); } ); } ); @@ -189,7 +189,7 @@ $.each( [ selected.val(), "original select state" ); - assert.equal( $.trim( button.text() ), selected.text(), "button text" ); + assert.equal( String.prototype.trim.call( button.text() ), selected.text(), "button text" ); ready(); }, 1 ); } ); @@ -231,7 +231,7 @@ $.each( [ "button aria-activedescendant" ); assert.equal( element.find( "option:selected" ).val(), options.eq( 1 ).val(), "original select state" ); - assert.equal( $.trim( button.text() ), options.eq( 1 ).text(), "button text" ); + assert.equal( String.prototype.trim.call( button.text() ), options.eq( 1 ).text(), "button text" ); ready(); } ); } ); @@ -352,10 +352,10 @@ QUnit.test( "Selectmenu should reset when its parent form resets", function( ass element.val( "Slower" ); element.selectmenu( "refresh" ); - assert.equal( $.trim( widget.text() ), "Slower" ); + assert.equal( String.prototype.trim.call( widget.text() ), "Slower" ); form[ 0 ].reset(); setTimeout( function() { - assert.equal( $.trim( widget.text() ), initialValue ); + assert.equal( String.prototype.trim.call( widget.text() ), initialValue ); ready(); } ); } ); diff --git a/tests/unit/selectmenu/methods.js b/tests/unit/selectmenu/methods.js index c25d01af5..2722fed01 100644 --- a/tests/unit/selectmenu/methods.js +++ b/tests/unit/selectmenu/methods.js @@ -83,21 +83,21 @@ QUnit.test( "refresh - change selected option", function( assert ) { var element = $( "#speed" ).selectmenu(), button = element.selectmenu( "widget" ); - assert.equal( $.trim( button.text() ), "Medium", "button text after init" ); + assert.equal( String.prototype.trim.call( button.text() ), "Medium", "button text after init" ); button.simulate( "focus" ); setTimeout( function() { - assert.equal( $.trim( button.text() ), "Medium", "button text after focus" ); + assert.equal( String.prototype.trim.call( button.text() ), "Medium", "button text after focus" ); element[ 0 ].selectedIndex = 0; element.selectmenu( "refresh" ); - assert.equal( $.trim( button.text() ), "Slower", "button text after changing selected option" ); + assert.equal( String.prototype.trim.call( button.text() ), "Slower", "button text after changing selected option" ); element.find( "option" ).prop( "selected", false ); element.append( "<option selected value=\"selected_option\">Selected option</option>" ); element.selectmenu( "refresh" ); - assert.equal( $.trim( button.text() ), "Selected option", "button text after adding selected option" ); + assert.equal( String.prototype.trim.call( button.text() ), "Selected option", "button text after adding selected option" ); ready(); } ); diff --git a/tests/unit/subsuite.js b/tests/unit/subsuite.js index e8a2c72fa..3ffb04366 100644 --- a/tests/unit/subsuite.js +++ b/tests/unit/subsuite.js @@ -12,7 +12,10 @@ var versions = [ "2.2.0", "2.2.1", "2.2.2", "2.2.3", "2.2.4", "3.0.0", "3.1.0", "3.1.1", - "git", "custom" + "3.2.0", "3.2.1", + "3.3.0", "3.3.1", + "3.4.0", "3.4.1", + "3.x-git", "git", "custom" ], additionalTests = { diff --git a/tests/unit/widget/core.js b/tests/unit/widget/core.js index d6bb3efb8..283b55416 100644 --- a/tests/unit/widget/core.js +++ b/tests/unit/widget/core.js @@ -29,7 +29,7 @@ QUnit.test( "widget creation", function( assert ) { }; $.widget( "ui.testWidget", myPrototype ); - assert.ok( $.isFunction( $.ui.testWidget ), "constructor was created" ); + assert.ok( typeof $.ui.testWidget === "function", "constructor was created" ); assert.equal( typeof $.ui.testWidget.prototype, "object", "prototype was created" ); method = "_create"; $.ui.testWidget.prototype._create(); @@ -947,7 +947,7 @@ QUnit.test( "_on() with delegate", function( assert ) { this.element = { on: function( event, handler ) { assert.equal( event, "click.testWidget" + uuid ); - assert.ok( $.isFunction( handler ) ); + assert.ok( typeof handler === "function" ); }, trigger: $.noop }; @@ -956,7 +956,7 @@ QUnit.test( "_on() with delegate", function( assert ) { on: function( event, selector, handler ) { assert.equal( selector, "a" ); assert.equal( event, "click.testWidget" + uuid ); - assert.ok( $.isFunction( handler ) ); + assert.ok( typeof handler === "function" ); } }; }; @@ -969,7 +969,7 @@ QUnit.test( "_on() with delegate", function( assert ) { on: function( event, selector, handler ) { assert.equal( selector, "form fieldset > input" ); assert.equal( event, "change.testWidget" + uuid ); - assert.ok( $.isFunction( handler ) ); + assert.ok( typeof handler === "function" ); } }; }; @@ -1608,7 +1608,7 @@ QUnit.test( "$.widget.bridge()", function( assert ) { $.widget.bridge( "testWidget", TestWidget ); - assert.ok( $.isFunction( $.fn.testWidget ), "jQuery plugin was created" ); + assert.ok( typeof $.fn.testWidget === "function", "jQuery plugin was created" ); assert.strictEqual( elem.testWidget( { foo: "bar" } ), elem, "plugin returns original jQuery object" ); instance = elem.data( "testWidget" ); diff --git a/tests/visual/dialog/performance.html b/tests/visual/dialog/performance.html index 45ef90941..065eacbbe 100644 --- a/tests/visual/dialog/performance.html +++ b/tests/visual/dialog/performance.html @@ -7,7 +7,7 @@ <script src="../../../external/requirejs/require.js"></script> <script src="../../../demos/bootstrap.js"> var start, - html = new Array( 500 ).join( $.trim( $( "#template" ).html() ) ); + html = new Array( 500 ).join( String.prototype.trim.call( $( "#template" ).html() ) ); $( html ).appendTo( "body" ); start = new Date(); |