diff options
Diffstat (limited to 'apps/it/static/js/ui/tests/unit/autocomplete')
10 files changed, 0 insertions, 886 deletions
diff --git a/apps/it/static/js/ui/tests/unit/autocomplete/all.html b/apps/it/static/js/ui/tests/unit/autocomplete/all.html deleted file mode 100644 index bfc8b8e..0000000 --- a/apps/it/static/js/ui/tests/unit/autocomplete/all.html +++ /dev/null @@ -1,30 +0,0 @@ -<!doctype html> -<html lang="en"> -<head> - <meta charset="utf-8"> - <title>jQuery UI Autocomplete Test Suite</title> - - <script src="../../../jquery-1.10.2.js"></script> - - <link rel="stylesheet" href="../../../external/qunit.css"> - <link rel="stylesheet" href="../qunit-composite.css"> - <script src="../../../external/qunit.js"></script> - <script src="../qunit-composite.js"></script> - <script src="../subsuite.js"></script> - - <script> - testAllVersions( "autocomplete" ); - </script> -</head> -<body> - -<h1 id="qunit-header">jQuery UI Autocomplete Test Suite</h1> -<h2 id="qunit-banner"></h2> -<div id="qunit-testrunner-toolbar"></div> -<h2 id="qunit-userAgent"></h2> -<ol id="qunit-tests"></ol> -<div id="qunit-fixture"> - -</div> -</body> -</html> diff --git a/apps/it/static/js/ui/tests/unit/autocomplete/autocomplete.html b/apps/it/static/js/ui/tests/unit/autocomplete/autocomplete.html deleted file mode 100644 index 8c7b5b6..0000000 --- a/apps/it/static/js/ui/tests/unit/autocomplete/autocomplete.html +++ /dev/null @@ -1,49 +0,0 @@ -<!doctype html> -<html lang="en"> -<head> - <meta charset="utf-8"> - <title>jQuery UI Autocomplete Test Suite</title> - - <script src="../../jquery.js"></script> - <link rel="stylesheet" href="../../../external/qunit.css"> - <script src="../../../external/qunit.js"></script> - <script src="../../jquery.simulate.js"></script> - <script src="../testsuite.js"></script> - <script> - TestHelpers.loadResources({ - css: [ "ui.core", "ui.menu", "ui.autocomplete" ], - js: [ - "ui/jquery.ui.core.js", - "ui/jquery.ui.widget.js", - "ui/jquery.ui.position.js", - "ui/jquery.ui.menu.js", - "ui/jquery.ui.autocomplete.js" - ] - }); - </script> - - <script src="autocomplete_common.js"></script> - <script src="autocomplete_core.js"></script> - <script src="autocomplete_events.js"></script> - <script src="autocomplete_methods.js"></script> - <script src="autocomplete_options.js"></script> - - <script src="../swarminject.js"></script> -</head> -<body> - -<h1 id="qunit-header">jQuery UI Autocomplete Test Suite</h1> -<h2 id="qunit-banner"></h2> -<div id="qunit-testrunner-toolbar"></div> -<h2 id="qunit-userAgent"></h2> -<ol id="qunit-tests"></ol> -<div id="qunit-fixture"> - -<div id="autocomplete-wrap1" class="autocomplete-wrap"></div> -<div id="autocomplete-wrap2" class="autocomplete-wrap"><input id="autocomplete" class="foo"></div> -<div id="autocomplete-contenteditable" contenteditable="" tabindex=0></div> -<textarea id="autocomplete-textarea"></textarea> - -</div> -</body> -</html> diff --git a/apps/it/static/js/ui/tests/unit/autocomplete/autocomplete_common.js b/apps/it/static/js/ui/tests/unit/autocomplete/autocomplete_common.js deleted file mode 100644 index 63b24d3..0000000 --- a/apps/it/static/js/ui/tests/unit/autocomplete/autocomplete_common.js +++ /dev/null @@ -1,29 +0,0 @@ -TestHelpers.commonWidgetTests( "autocomplete", { - defaults: { - appendTo: null, - autoFocus: false, - delay: 300, - disabled: false, - messages: { - noResults: "No search results.", - results: $.ui.autocomplete.prototype.options.messages.results - }, - minLength: 1, - position: { - my: "left top", - at: "left bottom", - collision: "none" - }, - source: null, - - // callbacks - change: null, - close: null, - create: null, - focus: null, - open: null, - response: null, - search: null, - select: null - } -}); diff --git a/apps/it/static/js/ui/tests/unit/autocomplete/autocomplete_core.js b/apps/it/static/js/ui/tests/unit/autocomplete/autocomplete_core.js deleted file mode 100644 index 679955d..0000000 --- a/apps/it/static/js/ui/tests/unit/autocomplete/autocomplete_core.js +++ /dev/null @@ -1,270 +0,0 @@ -(function( $ ) { - -module( "autocomplete: core" ); - -test( "prevent form submit on enter when menu is active", function() { - expect( 2 ); - var event, - element = $( "#autocomplete" ) - .autocomplete({ - source: [ "java", "javascript" ] - }) - .val( "ja" ) - .autocomplete( "search" ), - menu = element.autocomplete( "widget" ); - - event = $.Event( "keydown" ); - event.keyCode = $.ui.keyCode.DOWN; - element.trigger( event ); - deepEqual( menu.find( ".ui-menu-item:has(.ui-state-focus)" ).length, 1, "menu item is active" ); - - event = $.Event( "keydown" ); - event.keyCode = $.ui.keyCode.ENTER; - element.trigger( event ); - ok( event.isDefaultPrevented(), "default action is prevented" ); -}); - -test( "allow form submit on enter when menu is not active", function() { - expect( 1 ); - var event, - element = $( "#autocomplete" ) - .autocomplete({ - autoFocus: false, - source: [ "java", "javascript" ] - }) - .val( "ja" ) - .autocomplete( "search" ); - - event = $.Event( "keydown" ); - event.keyCode = $.ui.keyCode.ENTER; - element.trigger( event ); - ok( !event.isDefaultPrevented(), "default action is prevented" ); -}); - -(function() { - test( "up arrow invokes search - input", function() { - arrowsInvokeSearch( "#autocomplete", true, true ); - }); - - test( "down arrow invokes search - input", function() { - arrowsInvokeSearch( "#autocomplete", false, true ); - }); - - test( "up arrow invokes search - textarea", function() { - arrowsInvokeSearch( "#autocomplete-textarea", true, false ); - }); - - test( "down arrow invokes search - textarea", function() { - arrowsInvokeSearch( "#autocomplete-textarea", false, false ); - }); - - test( "up arrow invokes search - contenteditable", function() { - arrowsInvokeSearch( "#autocomplete-contenteditable", true, false ); - }); - - test( "down arrow invokes search - contenteditable", function() { - arrowsInvokeSearch( "#autocomplete-contenteditable", false, false ); - }); - - test( "up arrow moves focus - input", function() { - arrowsMoveFocus( "#autocomplete", true ); - }); - - test( "down arrow moves focus - input", function() { - arrowsMoveFocus( "#autocomplete", false ); - }); - - test( "up arrow moves focus - textarea", function() { - arrowsMoveFocus( "#autocomplete-textarea", true ); - }); - - test( "down arrow moves focus - textarea", function() { - arrowsMoveFocus( "#autocomplete-textarea", false ); - }); - - test( "up arrow moves focus - contenteditable", function() { - arrowsMoveFocus( "#autocomplete-contenteditable", true ); - }); - - test( "down arrow moves focus - contenteditable", function() { - arrowsMoveFocus( "#autocomplete-contenteditable", false ); - }); - - test( "up arrow moves cursor - input", function() { - arrowsNavigateElement( "#autocomplete", true, false ); - }); - - test( "down arrow moves cursor - input", function() { - arrowsNavigateElement( "#autocomplete", false, false ); - }); - - test( "up arrow moves cursor - textarea", function() { - arrowsNavigateElement( "#autocomplete-textarea", true, true ); - }); - - test( "down arrow moves cursor - textarea", function() { - arrowsNavigateElement( "#autocomplete-textarea", false, true ); - }); - - test( "up arrow moves cursor - contenteditable", function() { - arrowsNavigateElement( "#autocomplete-contenteditable", true, true ); - }); - - test( "down arrow moves cursor - contenteditable", function() { - arrowsNavigateElement( "#autocomplete-contenteditable", false, true ); - }); - - function arrowsInvokeSearch( id, isKeyUp, shouldMove ) { - expect( 1 ); - - var didMove = false, - element = $( id ).autocomplete({ - source: [ "a" ], - delay: 0, - minLength: 0 - }); - element.data( "ui-autocomplete" )._move = function() { - didMove = true; - }; - element.simulate( "keydown", { keyCode: ( isKeyUp ? $.ui.keyCode.UP : $.ui.keyCode.DOWN ) } ); - equal( didMove, shouldMove, "respond to arrow" ); - } - - function arrowsMoveFocus( id, isKeyUp ) { - expect( 1 ); - - var element = $( id ).autocomplete({ - source: [ "a" ], - delay: 0, - minLength: 0 - }); - element.data( "ui-autocomplete" )._move = function() { - ok( true, "repsond to arrow" ); - }; - element.autocomplete( "search" ); - element.simulate( "keydown", { keyCode: ( isKeyUp ? $.ui.keyCode.UP : $.ui.keyCode.DOWN ) } ); - } - - function arrowsNavigateElement( id, isKeyUp, shouldMove ) { - expect( 1 ); - - var didMove = false, - element = $( id ).autocomplete({ - source: [ "a" ], - delay: 0, - minLength: 0 - }); - element.on( "keypress", function( e ) { - didMove = !e.isDefaultPrevented(); - }); - element.simulate( "keydown", { keyCode: ( isKeyUp ? $.ui.keyCode.UP : $.ui.keyCode.DOWN ) } ); - element.simulate( "keypress" ); - equal( didMove, shouldMove, "respond to arrow" ); - } -})(); - -asyncTest( "handle race condition", function() { - expect( 3 ); - var count = 0, - element = $( "#autocomplete" ).autocomplete({ - source: function( request, response ) { - count++; - if ( request.term.length === 1 ) { - equal( count, 1, "request with 1 character is first" ); - setTimeout(function() { - response([ "one" ]); - setTimeout( checkResults, 1 ); - }, 1 ); - return; - } - equal( count, 2, "request with 2 characters is second" ); - response([ "two" ]); - } - }); - - element.autocomplete( "search", "a" ); - element.autocomplete( "search", "ab" ); - - function checkResults() { - equal( element.autocomplete( "widget" ).find( ".ui-menu-item" ).text(), "two", - "correct results displayed" ); - start(); - } -}); - -asyncTest( "simultaneous searches (#9334)", function() { - expect( 2 ); - var element = $( "#autocomplete" ).autocomplete({ - source: function( request, response ) { - setTimeout(function() { - response([ request.term ]); - }); - }, - response: function() { - ok( true, "response from first instance" ); - } - }), - element2 = $( "#autocomplete-textarea" ).autocomplete({ - source: function( request, response ) { - setTimeout(function() { - response([ request.term ]); - }); - }, - response: function() { - ok( true, "response from second instance" ); - start(); - } - }); - - element.autocomplete( "search", "test" ); - element2.autocomplete( "search", "test" ); -}); - -test( "ARIA", function() { - expect( 7 ); - var element = $( "#autocomplete" ).autocomplete({ - source: [ "java", "javascript" ] - }), - liveRegion = element.data( "ui-autocomplete" ).liveRegion; - - equal( liveRegion.text(), "", "Empty live region on create" ); - - element.autocomplete( "search", "j" ); - equal( liveRegion.text(), "2 results are available, use up and down arrow keys to navigate.", - "Live region for multiple values" ); - - element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } ); - equal( liveRegion.text(), "2 results are available, use up and down arrow keys to navigate.", - "Live region not changed on focus" ); - - element.one( "autocompletefocus", function( event ) { - event.preventDefault(); - }); - element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } ); - equal( liveRegion.text(), "javascript", - "Live region updated when default focus is prevented" ); - - element.autocomplete( "search", "javas" ); - equal( liveRegion.text(), "1 result is available, use up and down arrow keys to navigate.", - "Live region for one value" ); - - element.autocomplete( "search", "z" ); - equal( liveRegion.text(), "No search results.", - "Live region for no values" ); - - element.autocomplete( "search", "j" ); - equal( liveRegion.text(), "2 results are available, use up and down arrow keys to navigate.", - "Live region for multiple values" ); -}); - -test( ".replaceWith() (#9172)", function() { - expect( 1 ); - - var element = $( "#autocomplete" ).autocomplete(), - replacement = "<div>test</div>", - parent = element.parent(); - element.replaceWith( replacement ); - equal( parent.html().toLowerCase(), replacement ); -}); - -}( jQuery ) ); diff --git a/apps/it/static/js/ui/tests/unit/autocomplete/autocomplete_events.js b/apps/it/static/js/ui/tests/unit/autocomplete/autocomplete_events.js deleted file mode 100644 index fb1cf73..0000000 --- a/apps/it/static/js/ui/tests/unit/autocomplete/autocomplete_events.js +++ /dev/null @@ -1,182 +0,0 @@ -(function( $ ) { - -module( "autocomplete: events" ); - -var data = [ "Clojure", "COBOL", "ColdFusion", "Java", "JavaScript", "Scala", "Scheme" ]; - -$.each([ - { - type: "input", - selector: "#autocomplete", - valueMethod: "val" - }, - { - type: "textarea", - selector: "#autocomplete-textarea", - valueMethod: "val" - }, - { - type: "contenteditable", - selector: "#autocomplete-contenteditable", - valueMethod: "text" - } -], function( i, settings ) { - asyncTest( "all events - " + settings.type, function() { - expect( 13 ); - var element = $( settings.selector ) - .autocomplete({ - autoFocus: false, - delay: 0, - source: data, - search: function( event ) { - equal( event.originalEvent.type, "keydown", "search originalEvent" ); - }, - response: function( event, ui ) { - deepEqual( ui.content, [ - { label: "Clojure", value: "Clojure" }, - { label: "Java", value: "Java" }, - { label: "JavaScript", value: "JavaScript" } - ], "response ui.content" ); - ui.content.splice( 0, 1 ); - }, - open: function() { - ok( menu.is( ":visible" ), "menu open on open" ); - }, - focus: function( event, ui ) { - equal( event.originalEvent.type, "menufocus", "focus originalEvent" ); - deepEqual( ui.item, { label: "Java", value: "Java" }, "focus ui.item" ); - }, - close: function( event ) { - equal( event.originalEvent.type, "menuselect", "close originalEvent" ); - ok( menu.is( ":hidden" ), "menu closed on close" ); - }, - select: function( event, ui ) { - equal( event.originalEvent.type, "menuselect", "select originalEvent" ); - deepEqual( ui.item, { label: "Java", value: "Java" }, "select ui.item" ); - }, - change: function( event, ui ) { - equal( event.originalEvent.type, "blur", "change originalEvent" ); - deepEqual( ui.item, { label: "Java", value: "Java" }, "change ui.item" ); - ok( menu.is( ":hidden" ), "menu closed on change" ); - start(); - } - }), - menu = element.autocomplete( "widget" ); - - element.simulate( "focus" )[ settings.valueMethod ]( "j" ).keydown(); - setTimeout(function() { - ok( menu.is( ":visible" ), "menu is visible after delay" ); - element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } ); - element.simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } ); - // blur must be async for IE to handle it properly - setTimeout(function() { - element.simulate( "blur" ); - }, 1 ); - }, 50 ); - }); -}); - -asyncTest( "change without selection", function() { - expect( 1 ); - var element = $( "#autocomplete" ).autocomplete({ - delay: 0, - source: data, - change: function( event, ui ) { - strictEqual( ui.item, null ); - start(); - } - }); - element.triggerHandler( "focus" ); - element.val( "ja" ).triggerHandler( "blur" ); -}); - -asyncTest( "cancel search", function() { - expect( 6 ); - var first = true, - element = $( "#autocomplete" ).autocomplete({ - delay: 0, - source: data, - search: function() { - if ( first ) { - equal( element.val(), "ja", "val on first search" ); - first = false; - return false; - } - equal( element.val(), "java", "val on second search" ); - }, - open: function() { - ok( true, "menu opened" ); - } - }), - menu = element.autocomplete( "widget" ); - element.val( "ja" ).keydown(); - setTimeout(function() { - ok( menu.is( ":hidden" ), "menu is hidden after first search" ); - element.val( "java" ).keydown(); - setTimeout(function() { - ok( menu.is( ":visible" ), "menu is visible after second search" ); - equal( menu.find( ".ui-menu-item" ).length, 2, "# of menu items" ); - start(); - }, 50 ); - }, 50 ); -}); - -asyncTest( "cancel focus", function() { - expect( 1 ); - var customVal = "custom value", - element = $( "#autocomplete" ).autocomplete({ - delay: 0, - source: data, - focus: function() { - $( this ).val( customVal ); - return false; - } - }); - element.val( "ja" ).keydown(); - setTimeout(function() { - element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } ); - equal( element.val(), customVal ); - start(); - }, 50 ); -}); - -asyncTest( "cancel select", function() { - expect( 1 ); - var customVal = "custom value", - element = $( "#autocomplete" ).autocomplete({ - delay: 0, - source: data, - select: function() { - $( this ).val( customVal ); - return false; - } - }); - element.val( "ja" ).keydown(); - setTimeout(function() { - element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } ); - element.simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } ); - equal( element.val(), customVal ); - start(); - }, 50 ); -}); - -asyncTest( "blur during remote search", function() { - expect( 1 ); - var ac = $( "#autocomplete" ).autocomplete({ - delay: 0, - source: function( request, response ) { - ok( true, "trigger request" ); - ac.simulate( "blur" ); - setTimeout(function() { - response([ "result" ]); - start(); - }, 100 ); - }, - open: function() { - ok( false, "opened after a blur" ); - } - }); - ac.val( "ro" ).keydown(); -}); - -}( jQuery ) ); diff --git a/apps/it/static/js/ui/tests/unit/autocomplete/autocomplete_methods.js b/apps/it/static/js/ui/tests/unit/autocomplete/autocomplete_methods.js deleted file mode 100644 index 1bfa105..0000000 --- a/apps/it/static/js/ui/tests/unit/autocomplete/autocomplete_methods.js +++ /dev/null @@ -1,45 +0,0 @@ -(function( $ ) { - -module( "autocomplete: methods" ); - -test( "destroy", function() { - expect( 1 ); - domEqual( "#autocomplete", function() { - $( "#autocomplete" ).autocomplete().autocomplete( "destroy" ); - }); -}); - -test( "search, close", function() { - expect( 6 ); - var data = [ "c++", "java", "php", "coldfusion", "javascript", "asp", "ruby", "python", "c", "scala", "groovy", "haskell", "perl" ], - element = $( "#autocomplete" ).autocomplete({ - source: data, - minLength: 0 - }), - menu = element.autocomplete( "widget" ); - - ok( menu.is( ":hidden" ), "menu is hidden on init" ); - - element.autocomplete( "search" ); - ok( menu.is( ":visible" ), "menu is visible after search" ); - equal( menu.find( ".ui-menu-item" ).length, data.length, "all items for a blank search" ); - - element.val( "has" ).autocomplete( "search" ); - equal( menu.find( ".ui-menu-item" ).text(), "haskell", "only one item for set input value" ); - - element.autocomplete( "search", "ja" ); - equal( menu.find( ".ui-menu-item" ).length, 2, "only java and javascript for 'ja'" ); - - element.autocomplete( "close" ); - ok( menu.is( ":hidden" ), "menu is hidden after close" ); -}); - -test( "widget", function() { - expect( 2 ); - var element = $( "#autocomplete" ).autocomplete(), - widgetElement = element.autocomplete( "widget" ); - equal( widgetElement.length, 1, "one element" ); - ok( widgetElement.is( ".ui-menu" ), "menu element" ); -}); - -}( jQuery ) ); diff --git a/apps/it/static/js/ui/tests/unit/autocomplete/autocomplete_options.js b/apps/it/static/js/ui/tests/unit/autocomplete/autocomplete_options.js deleted file mode 100644 index 0a2e07b..0000000 --- a/apps/it/static/js/ui/tests/unit/autocomplete/autocomplete_options.js +++ /dev/null @@ -1,278 +0,0 @@ -(function( $ ) { - -module( "autocomplete: options" ); - -var data = [ "c++", "java", "php", "coldfusion", "javascript", "asp", "ruby", - "python", "c", "scala", "groovy", "haskell", "perl" ]; - -test( "appendTo", function() { - expect( 8 ); - var detached = $( "<div>" ), - element = $( "#autocomplete" ).autocomplete(); - equal( element.autocomplete( "widget" ).parent()[ 0 ], document.body, - "defaults to body" ); - element.autocomplete( "destroy" ); - - element.autocomplete({ - appendTo: ".autocomplete-wrap" - }); - equal( element.autocomplete( "widget" ).parent()[ 0 ], - $( "#autocomplete-wrap1" )[ 0 ], "first found element" ); - equal( $( "#autocomplete-wrap2 .ui-autocomplete" ).length, 0, - "only appends to one element" ); - element.autocomplete( "destroy" ); - - $( "#autocomplete-wrap2" ).addClass( "ui-front" ); - element.autocomplete(); - equal( element.autocomplete( "widget" ).parent()[ 0 ], - $( "#autocomplete-wrap2" )[ 0 ], "null, inside .ui-front" ); - element.autocomplete( "destroy" ); - $( "#autocomlete-wrap2" ).removeClass( "ui-front" ); - - element.autocomplete().autocomplete( "option", "appendTo", "#autocomplete-wrap1" ); - equal( element.autocomplete( "widget" ).parent()[ 0 ], - $( "#autocomplete-wrap1" )[ 0 ], "modified after init" ); - element.autocomplete( "destroy" ); - - element.autocomplete({ - appendTo: detached - }); - equal( element.autocomplete( "widget" ).parent()[ 0 ], detached[ 0 ], - "detached jQuery object" ); - element.autocomplete( "destroy" ); - - element.autocomplete({ - appendTo: detached[ 0 ] - }); - equal( element.autocomplete( "widget" ).parent()[ 0 ], detached[ 0 ], - "detached DOM element" ); - element.autocomplete( "destroy" ); - - element.autocomplete().autocomplete( "option", "appendTo", detached ); - equal( element.autocomplete( "widget" ).parent()[ 0 ], detached[ 0 ], - "detached DOM element via option()" ); - element.autocomplete( "destroy" ); -}); - -function autoFocusTest( afValue, focusedLength ) { - var element = $( "#autocomplete" ).autocomplete({ - autoFocus: afValue, - delay: 0, - source: data, - open: function() { - equal( - element.autocomplete( "widget" ) - .children( ".ui-menu-item:first" ) - .find( ".ui-state-focus" ) - .length, - focusedLength, - "first item is " + (afValue ? "" : "not") + " auto focused" ); - start(); - } - }); - element.val( "ja" ).keydown(); - stop(); -} - -test( "autoFocus: false", function() { - expect( 1 ); - autoFocusTest( false, 0 ); -}); - -test( "autoFocus: true", function() { - expect( 1 ); - autoFocusTest( true, 1 ); -}); - -asyncTest( "delay", function() { - expect( 2 ); - var element = $( "#autocomplete" ).autocomplete({ - source: data, - delay: 50 - }), - menu = element.autocomplete( "widget" ); - element.val( "ja" ).keydown(); - - ok( menu.is( ":hidden" ), "menu is closed immediately after search" ); - - setTimeout(function() { - ok( menu.is( ":visible" ), "menu is open after delay" ); - start(); - }, 100 ); -}); - -asyncTest( "disabled", function() { - expect( 2 ); - var element = $( "#autocomplete" ).autocomplete({ - source: data, - delay: 0, - disabled: true - }), - menu = element.autocomplete( "widget" ); - element.val( "ja" ).keydown(); - - ok( menu.is( ":hidden" ) ); - - setTimeout(function() { - ok( menu.is( ":hidden" ) ); - start(); - }, 50 ); -}); - -test( "minLength", function() { - expect( 2 ); - var element = $( "#autocomplete" ).autocomplete({ - source: data - }), - menu = element.autocomplete( "widget" ); - element.autocomplete( "search", "" ); - ok( menu.is( ":hidden" ), "blank not enough for minLength: 1" ); - - element.autocomplete( "option", "minLength", 0 ); - element.autocomplete( "search", "" ); - ok( menu.is( ":visible" ), "blank enough for minLength: 0" ); -}); - -asyncTest( "minLength, exceed then drop below", function() { - expect( 4 ); - var element = $( "#autocomplete" ).autocomplete({ - minLength: 2, - source: function( req, res ) { - equal( req.term, "12", "correct search term" ); - setTimeout(function() { - res([ "item" ]); - }, 1 ); - } - }), - menu = element.autocomplete( "widget" ); - - ok( menu.is( ":hidden" ), "menu is hidden before first search" ); - element.autocomplete( "search", "12" ); - - ok( menu.is( ":hidden" ), "menu is hidden before second search" ); - element.autocomplete( "search", "1" ); - - setTimeout(function() { - ok( menu.is( ":hidden" ), "menu is hidden after searches" ); - start(); - }, 50 ); -}); - -test( "minLength, exceed then drop below then exceed", function() { - expect( 3 ); - var _res = [], - element = $( "#autocomplete" ).autocomplete({ - minLength: 2, - source: function( req, res ) { - _res.push( res ); - } - }), - menu = element.autocomplete( "widget" ); - - // trigger a valid search - ok( menu.is( ":hidden" ), "menu is hidden before first search" ); - element.autocomplete( "search", "12" ); - - // trigger a search below the minLength, to turn on cancelSearch flag - ok( menu.is( ":hidden" ), "menu is hidden before second search" ); - element.autocomplete( "search", "1" ); - - // trigger a valid search - element.autocomplete( "search", "13" ); - // react as if the first search was cancelled (default ajax behavior) - _res[ 0 ]([]); - // react to second search - _res[ 1 ]([ "13" ]); - - ok( menu.is( ":visible" ), "menu is visible after searches" ); -}); - -test( "source, local string array", function() { - expect( 1 ); - var element = $( "#autocomplete" ).autocomplete({ - source: data - }), - menu = element.autocomplete( "widget" ); - element.val( "ja" ).autocomplete( "search" ); - equal( menu.find( ".ui-menu-item" ).text(), "javajavascript" ); -}); - -function sourceTest( source, async ) { - var element = $( "#autocomplete" ).autocomplete({ - source: source - }), - menu = element.autocomplete( "widget" ); - function result() { - equal( menu.find( ".ui-menu-item" ).text(), "javajavascript" ); - element.autocomplete( "destroy" ); - if ( async ) { - start(); - } - } - if ( async ) { - stop(); - $( document ).one( "ajaxStop", result ); - } - element.val( "ja" ).autocomplete( "search" ); - if ( !async ) { - result(); - } -} - -test( "source, local object array, only label property", function() { - expect( 1 ); - sourceTest([ - { label: "java" }, - { label: "php" }, - { label: "coldfusion" }, - { label: "javascript" } - ]); -}); - -test( "source, local object array, only value property", function() { - expect( 1 ); - sourceTest([ - { value: "java" }, - { value: "php" }, - { value: "coldfusion" }, - { value: "javascript" } - ]); -}); - -test( "source, url string with remote json string array", function() { - expect( 1 ); - sourceTest( "remote_string_array.txt", true ); -}); - -test( "source, url string with remote json object array, only value properties", function() { - expect( 1 ); - sourceTest( "remote_object_array_values.txt", true ); -}); - -test( "source, url string with remote json object array, only label properties", function() { - expect( 1 ); - sourceTest( "remote_object_array_labels.txt", true ); -}); - -test( "source, custom", function() { - expect( 2 ); - sourceTest(function( request, response ) { - equal( request.term, "ja" ); - response( ["java", "javascript"] ); - }); -}); - -test( "source, update after init", function() { - expect( 2 ); - var element = $( "#autocomplete" ).autocomplete({ - source: [ "java", "javascript", "haskell" ] - }), - menu = element.autocomplete( "widget" ); - element.val( "ja" ).autocomplete( "search" ); - equal( menu.find( ".ui-menu-item" ).text(), "javajavascript" ); - element.autocomplete( "option", "source", [ "php", "asp" ] ); - element.val( "ph" ).autocomplete( "search" ); - equal( menu.find( ".ui-menu-item" ).text(), "php" ); -}); - -}( jQuery ) ); diff --git a/apps/it/static/js/ui/tests/unit/autocomplete/remote_object_array_labels.txt b/apps/it/static/js/ui/tests/unit/autocomplete/remote_object_array_labels.txt deleted file mode 100644 index 502496c..0000000 --- a/apps/it/static/js/ui/tests/unit/autocomplete/remote_object_array_labels.txt +++ /dev/null @@ -1 +0,0 @@ -[{"label":"java"},{"label":"javascript"}]
\ No newline at end of file diff --git a/apps/it/static/js/ui/tests/unit/autocomplete/remote_object_array_values.txt b/apps/it/static/js/ui/tests/unit/autocomplete/remote_object_array_values.txt deleted file mode 100644 index 029cbb9..0000000 --- a/apps/it/static/js/ui/tests/unit/autocomplete/remote_object_array_values.txt +++ /dev/null @@ -1 +0,0 @@ -[{"value":"java"},{"value":"javascript"}]
\ No newline at end of file diff --git a/apps/it/static/js/ui/tests/unit/autocomplete/remote_string_array.txt b/apps/it/static/js/ui/tests/unit/autocomplete/remote_string_array.txt deleted file mode 100644 index 3b24c8e..0000000 --- a/apps/it/static/js/ui/tests/unit/autocomplete/remote_string_array.txt +++ /dev/null @@ -1 +0,0 @@ -["java", "javascript"]
\ No newline at end of file |