How to use complete method in avocado

Best Python code snippet using avocado_python

ui-autocomplete.js

Source:ui-autocomplete.js Github

copy

Full Screen

...420 enumerable: true,421 configurable: true422 });423 RadAutoCompleteTextView.prototype.resetAutoComplete = function () {424 this._android.resetAutocomplete();425 };426 RadAutoCompleteTextView.prototype.addToken = function (token) {427 var image = token.image ? RadAutoCompleteTextView.resolveDrawableFromResource(token.image) : null;428 var nativeObject = new com.telerik.widget.autocomplete.TokenModel(token.text, image);429 this._android.addTokenView(nativeObject);430 if (this._android.getDisplayMode() === com.telerik.widget.autocomplete.DisplayMode.PLAIN) {431 // HACK: to unify behavior in iOS and Android432 this._android.setText(token.text);433 }434 };435 RadAutoCompleteTextView.prototype.insertTokenAtIndex = function (token, index) {436 var image = token.image ? RadAutoCompleteTextView.resolveDrawableFromResource(token.image) : null;437 var nativeObject = new com.telerik.widget.autocomplete.TokenModel(token.text, image);438 var nativeTokenView = new com.telerik.widget.autocomplete.TokenView(this._context);...

Full Screen

Full Screen

konytextfieldautocomplete.js

Source:konytextfieldautocomplete.js Github

copy

Full Screen

1/************************ TEXT FIELD AUTO COMPLETE *******************/2$KW.TextField.AutoComplete = {3 /**4 * Global vars5 */6 __AutoCompleteClass : 'autocomplete_base',7 __AutoComplete : new Array(),8 __AutoCompleteElementId : null,9 // Basic UA detection10 isIE : document.all ? true : false,11 isGecko : navigator.userAgent.toLowerCase().indexOf('gecko') != -1,12 isOpera : navigator.userAgent.toLowerCase().indexOf('opera') != -1,13 AutoSuggestOrientation: function(){14 if(this.__AutoCompleteElementId != null) {15 this.AutoComplete_HideAll();16 // AutoComplete_CreateDropdown(__AutoCompleteElementId)17 this.AutoComplete_CreateDropdownZeroSize(this.__AutoCompleteElementId);18 this.AutoComplete_ShowDropdown(this.__AutoCompleteElementId);19 this.AutoComplete_HideAll();20 this.AutoComplete_CreateDropdown(this.__AutoCompleteElementId);21 this.AutoComplete_ShowDropdown(this.__AutoCompleteElementId);22 //AutoComplete_HideAll()23 }24 },25 /**26 * Attachs the autocomplete object to a form element. Sets27 * onkeypress event on the form element.28 *29 * @param string formElement Name of form element to attach to30 * @param array data Array of strings of which to use as the autocomplete data31 */32 AutoComplete_Create:function(id, data){33 this.__AutoComplete[id] = {'data':data,34 'isVisible':false,35 'element':document.getElementById(id),36 'dropdown':null,37 'highlighted':null,38 'styleclass':this.__AutoCompleteClass};39 this.__AutoComplete[id]['element'].setAttribute(this.__AutoCompleteClass, 'off');40 this.__AutoComplete[id]['element'].onkeydown = function(e) {return $KW.TextField.AutoComplete.AutoComplete_KeyDown(this.getAttribute('id'), e);}41 this.__AutoComplete[id]['element'].onkeyup = function(e) {return $KW.TextField.AutoComplete.AutoComplete_KeyUp(this.getAttribute('id'), e);}42 this.__AutoComplete[id]['element'].onkeypress = function(e) {if (!e) e = window.event; if (e.keyCode == 13 || this.isOpera) return false;}43 this.__AutoComplete[id]['element'].ondblclick = function() {$KW.TextField.AutoComplete.AutoComplete_ShowDropdown(this.getAttribute('id'));}44 this.__AutoComplete[id]['element'].onclick = function(e) {if (!e) e = window.event; e.cancelBubble = true; e.returnValue = false;}45 // Hides the dropdowns when document clicked46 var docClick = function()47 {48 for (id in this.__AutoComplete) {49 $KW.TextField.AutoComplete.AutoComplete_HideDropdown(id);50 }51 }52 if (document.addEventListener) {53 document.addEventListener('click', docClick, false);54 } else if (document.attachEvent) {55 document.attachEvent('onclick', docClick, false);56 }57 // Max number of items shown at once58 if (arguments[2] != null) {59 this.__AutoComplete[id]['maxitems'] = arguments[2];60 this.__AutoComplete[id]['firstItemShowing'] = 0;61 this.__AutoComplete[id]['lastItemShowing'] = arguments[2] - 1;62 }63 this.AutoComplete_CreateDropdown(id);64 // Prevent select dropdowns showing thru65 if (this.isIE) {66 this.__AutoComplete[id]['iframe'] = document.createElement('iframe');67 this.__AutoComplete[id]['iframe'].id = id +'_iframe';68 this.__AutoComplete[id]['iframe'].style.position = 'absolute';69 this.__AutoComplete[id]['iframe'].style.top = '0';70 this.__AutoComplete[id]['iframe'].style.left = '0';71 this.__AutoComplete[id]['iframe'].style.width = '0px';72 this.__AutoComplete[id]['iframe'].style.height = '0px';73 this.__AutoComplete[id]['iframe'].style.zIndex = '98';74 this.__AutoComplete[id]['iframe'].style.visibility = 'hidden';75 this.__AutoComplete[id]['element'].parentNode.insertBefore(this.__AutoComplete[id]['iframe'], this.__AutoComplete[id]['element']);76 }77 },78 /**79 * Creates the dropdown layer80 *81 * @param string id The form elements id. Used to identify the correct dropdown.82 */83 AutoComplete_CreateDropdown:function(id){84 var left = this.AutoComplete_GetLeft(this.__AutoComplete[id]['element']);85 var top = this.AutoComplete_GetTop(this.__AutoComplete[id]['element']) + this.__AutoComplete[id]['element'].offsetHeight;86 var width = this.__AutoComplete[id]['element'].offsetWidth;87 //alert(left)88 this.__AutoComplete[id]['dropdown'] = document.createElement('div');89 this.__AutoComplete[id]['dropdown'].className = this.__AutoCompleteClass; // Don't use setAttribute()90 91 this.AutoComplete_RemoveDivs(id);92 this.__AutoComplete[id]['element'].parentNode.insertBefore(this.__AutoComplete[id]['dropdown'], this.__AutoComplete[id]['element']);93 // Position it94 this.__AutoComplete[id]['dropdown'].style.left = left + 'px';95 this.__AutoComplete[id]['dropdown'].style.top = top + 'px';96 this.__AutoComplete[id]['dropdown'].style.width = width + 'px';97 this.__AutoComplete[id]['dropdown'].style.zIndex = '99';98 this.__AutoComplete[id]['dropdown'].style.visibility = 'hidden';99 100 //override autocomplete styles101 var el = document.getElementById(id);102 if(el.getAttribute('autosuggestskin') != null) {103 this.__AutoComplete[id]['styleclass'] = el.getAttribute('autosuggestskin');104 this.__AutoComplete[id]['dropdown'].className = this.__AutoComplete[id]['styleclass'];105 this.__AutoComplete[id]['dropdown'].style.position='absolute';106 this.__AutoComplete[id]['dropdown'].style.borderStyle='solid';107 this.__AutoComplete[id]['dropdown'].style.borderWidth='1px';108 this.__AutoComplete[id]['dropdown'].style.borderColor='black';109 this.__AutoComplete[id]['dropdown'].style.backgroundColor='white';110 this.__AutoComplete[id]['dropdown'].style.overflow='auto';111 this.__AutoComplete[id]['dropdown'].style.overflowX='hidden';112 113 }114 else115 {116 this.__AutoComplete[id]['dropdown'].style.fontFamily= this.getElementStyle(el,'font-family');117 this.__AutoComplete[id]['dropdown'].style.fontSize= this.getElementStyle(el,'font-size');118 this.__AutoComplete[id]['dropdown'].style.fontStyle= this.getElementStyle(el,'font-style');119 this.__AutoComplete[id]['dropdown'].style.fontWeight= this.getElementStyle(el,'font-weight');120 this.__AutoComplete[id]['dropdown'].style.color= this.getElementStyle(el,'color');121 }122 this.AutoComplete_RemoveDivs(id);123 this.__AutoComplete[id]['element'].parentNode.insertBefore(this.__AutoComplete[id]['dropdown'], this.__AutoComplete[id]['element']);124 },125 126 getElementStyle:function(el,styleProp){ 127 var elementstyle = null;128 if (el.currentStyle)129 elementstyle = el.currentStyle[styleProp];130 else if (window.getComputedStyle)131 elementstyle = document.defaultView.getComputedStyle(el,null).getPropertyValue(styleProp);132 return elementstyle;133 },134 135 AutoComplete_RemoveDivs : function(id) {136 var autoCompleteParent = document.getElementById(id).parentNode;137 if(this.__AutoComplete[id]) {138 var autoCompleteDivs = document.getElementsByClassName(this.__AutoComplete[id]['styleclass']);139 if(autoCompleteDivs.length>0){140 for( var i = 0; i< autoCompleteDivs.length;i++){141 if(autoCompleteDivs[i].nextSibling.id === id)142 autoCompleteParent.removeChild(autoCompleteDivs[i]);143 }144 }145 }146 },147 /* TODO: Need to verify below values are correct or not.*/148 AutoComplete_CreateDropdownZeroSize:function(id){149 // Position it150 this.__AutoComplete[id]['dropdown'].style.left = '1px';151 this.__AutoComplete[id]['dropdown'].style.top = '1px';152 this.__AutoComplete[id]['dropdown'].style.width = '10px';153 this.__AutoComplete[id]['dropdown'].style.zIndex = '99';154 this.__AutoComplete[id]['dropdown'].style.visibility = 'hidden';155 },156 /**157 * Gets left coord of given element158 *159 * @param object element The element to get the left coord for160 */161 AutoComplete_GetLeft:function(element)162 {163 var curNode = element;164 var left = 0;165 do {166 left += curNode.offsetLeft;167 curNode = curNode.offsetParent;168 } while(curNode.tagName.toLowerCase() != 'body');169 return left;170 },171 /**172 * Gets top coord of given element173 *174 * @param object element The element to get the top coord for175 */176 AutoComplete_GetTop:function(element)177 {178 var curNode = element;179 var top = 0;180 do {181 top += curNode.offsetTop;182 curNode = curNode.offsetParent;183 } while(curNode.tagName.toLowerCase() != 'body');184 return top;185 },186 /**187 * Shows the dropdown layer188 *189 * @param string id The form elements id. Used to identify the correct dropdown.190 */191 AutoComplete_ShowDropdown:function(id)192 {193 this.AutoComplete_HideAll();194 this.__AutoCompleteElementId = id;195 var value = this.__AutoComplete[id]['element'].value;196 var toDisplay = new Array();197 var newDiv = null;198 var text = null;199 var numItems = this.__AutoComplete[id]['dropdown'].childNodes.length;200 // Remove all child nodes from dropdown201 while (this.__AutoComplete[id]['dropdown'].childNodes.length > 0) {202 this.__AutoComplete[id]['dropdown'].removeChild(this.__AutoComplete[id]['dropdown'].childNodes[0]);203 }204 // Go thru data searching for matches205 value = value.ltrim().toUpperCase();206 for (i=0; i<this.__AutoComplete[id]['data'].length; ++i) {207 if (this.__AutoComplete[id]['data'][i].toUpperCase().indexOf(value) != -1) {208 toDisplay[toDisplay.length] = this.__AutoComplete[id]['data'][i];209 }210 }211 // No matches?212 if (toDisplay.length == 0) {213 this.AutoComplete_HideDropdown(id);214 return;215 }216 var target = document.getElementById(id);217 var space = target.getAttribute('suggestionspace');218 if(space)219 space = parseInt(space)/2;220 // Add data to the dropdown layer221 for (i=0; i<toDisplay.length; ++i) {222 newDiv = document.createElement('div');223 newDiv.className = 'autocomplete_item'; // Don't use setAttribute()224 newDiv.setAttribute('id', 'autocomplete_item_' + i);225 newDiv.setAttribute('index', i);226 newDiv.style.zIndex = '99';227 // Scrollbars are on display ?228 if (toDisplay.length > this.__AutoComplete[id]['maxitems'] && navigator.userAgent.indexOf('MSIE') == -1) {229 newDiv.style.width = this.__AutoComplete[id]['element'].offsetWidth - 22 + 'px';230 }231 newDiv.onmouseover = function() {$KW.TextField.AutoComplete.AutoComplete_HighlightItem($KW.TextField.AutoComplete.__AutoComplete[id]['element'].getAttribute('id'), this.getAttribute('index'));};232 newDiv.onclick = function() {$KW.TextField.AutoComplete.AutoComplete_SetValue($KW.TextField.AutoComplete.__AutoComplete[id]['element'].getAttribute('id')); $KW.TextField.AutoComplete.AutoComplete_RemoveDivs(id);}233 text = document.createTextNode(toDisplay[i]);234 newDiv.appendChild(text);235 this.AutoComplete_HideAllDropdowns()236 237 if(space){238 newDiv.style.paddingBottom=space+"px";239 newDiv.style.paddingTop=space+"px";240 }241 this.__AutoComplete[id]['dropdown'].appendChild(newDiv);242 }243 // Too many items?244 if (toDisplay.length > this.__AutoComplete[id]['maxitems']) {245 this.__AutoComplete[id]['dropdown'].style.height = (this.__AutoComplete[id]['maxitems'] * 15) + 2 + 'px';246 } else {247 this.__AutoComplete[id]['dropdown'].style.height = '';248 }249 /**250 * Set left/top in case of document movement/scroll/window resize etc251 */252 this.__AutoComplete[id]['dropdown'].style.left = this.AutoComplete_GetLeft(this.__AutoComplete[id]['element']) + 'px';253 this.__AutoComplete[id]['dropdown'].style.top = this.AutoComplete_GetTop(this.__AutoComplete[id]['element']) + this.__AutoComplete[id]['element'].offsetHeight + 'px';254 // Show the iframe for IE255 if (this.isIE) {256 this.__AutoComplete[id]['iframe'].style.top = this.__AutoComplete[id]['dropdown'].style.top;257 this.__AutoComplete[id]['iframe'].style.left = this.__AutoComplete[id]['dropdown'].style.left;258 this.__AutoComplete[id]['iframe'].style.width = this.__AutoComplete[id]['dropdown'].offsetWidth;259 this.__AutoComplete[id]['iframe'].style.height = this.__AutoComplete[id]['dropdown'].offsetHeight;260 this.__AutoComplete[id]['iframe'].style.visibility = 'visible';261 }262 // Show dropdown263 if (!this.__AutoComplete[id]['isVisible']) {264 this.__AutoComplete[id]['dropdown'].style.visibility = 'visible';265 this.__AutoComplete[id]['isVisible'] = true;266 }267 // If now showing less items than before, reset the highlighted value268 if (this.__AutoComplete[id]['dropdown'].childNodes.length != numItems) {269 this.__AutoComplete[id]['highlighted'] = null;270 }271 },272 /**273 * Hides the dropdown layer274 *275 * @param string id The form elements id. Used to identify the correct dropdown.276 */277 AutoComplete_HideDropdown:function(id)278 {279 if (this.__AutoComplete[id]['iframe']) {280 this.__AutoComplete[id]['iframe'].style.visibility = 'hidden';281 }282 if(this.__AutoComplete[id]['dropdown']) {283 this.__AutoComplete[id]['dropdown'].style.visibility = 'hidden';284 }285 this.__AutoComplete[id]['highlighted'] = null;286 this.__AutoComplete[id]['isVisible'] = false;287 },288 /**289 * Hides all dropdowns290 */291 AutoComplete_HideAll:function()292 {293 for (id in this.__AutoComplete) {294 this.AutoComplete_HideDropdown(id);295 }296 },297 AutoComplete_HideAllDropdowns:function(){298 var autocompdivs = document.getElementsByClassName(this.__AutoComplete[id]['styleclass']);299 if(autocompdivs != null) {300 for(var i=0;i<autocompdivs.length;i++) {301 autocompdivs[i].style.visibility = 'hidden';302 }303 }304 },305 /**306 * Highlights a specific item307 *308 * @param string id The form elements id. Used to identify the correct dropdown.309 * @param int index The index of the element in the dropdown to highlight310 */311 AutoComplete_HighlightItem:function(id, index)312 {313 if (this.__AutoComplete[id]['dropdown'].childNodes[index]) {314 for (var i=0; i<this.__AutoComplete[id]['dropdown'].childNodes.length; ++i) {315 if (this.__AutoComplete[id]['dropdown'].childNodes[i].className == 'autocomplete_item_highlighted') {316 this.__AutoComplete[id]['dropdown'].childNodes[i].className = 'autocomplete_item';317 }318 }319 this.__AutoComplete[id]['dropdown'].childNodes[index].className = 'autocomplete_item_highlighted';320 this.__AutoComplete[id]['highlighted'] = index;321 }322 },323 /**324 * Highlights the menu item with the given index325 *326 * @param string id The form elements id. Used to identify the correct dropdown.327 * @param int index The index of the element in the dropdown to highlight328 */329 AutoComplete_Highlight:function(id, index)330 {331 // Out of bounds checking332 if (index == 1 && this.__AutoComplete[id]['highlighted'] == this.__AutoComplete[id]['dropdown'].childNodes.length - 1) {333 this.__AutoComplete[id]['dropdown'].childNodes[this.__AutoComplete[id]['highlighted']].className = 'autocomplete_item';334 this.__AutoComplete[id]['highlighted'] = null;335 } else if (index == -1 && this.__AutoComplete[id]['highlighted'] == 0) {336 this.__AutoComplete[id]['dropdown'].childNodes[0].className = 'autocomplete_item';337 this.__AutoComplete[id]['highlighted'] = this.__AutoComplete[id]['dropdown'].childNodes.length;338 }339 // Nothing highlighted at the moment340 if (this.__AutoComplete[id]['highlighted'] == null) {341 this.__AutoComplete[id]['dropdown'].childNodes[0].className = 'autocomplete_item_highlighted';342 this.__AutoComplete[id]['highlighted'] = 0;343 } else {344 if (this.__AutoComplete[id]['dropdown'].childNodes[this.__AutoComplete[id]['highlighted']]) {345 this.__AutoComplete[id]['dropdown'].childNodes[this.__AutoComplete[id]['highlighted']].className = 'autocomplete_item';346 }347 var newIndex = this.__AutoComplete[id]['highlighted'] + index;348 if (this.__AutoComplete[id]['dropdown'].childNodes[newIndex]) {349 this.__AutoComplete[id]['dropdown'].childNodes[newIndex].className = 'autocomplete_item_highlighted';350 this.__AutoComplete[id]['highlighted'] = newIndex;351 }352 }353 },354 /**355 * Sets the input to a given value356 *357 * @param string id The form elements id. Used to identify the correct dropdown.358 */359 AutoComplete_SetValue:function(id)360 {361 this.__AutoComplete[id]['element'].value = this.__AutoComplete[id]['dropdown'].childNodes[this.__AutoComplete[id]['highlighted']].innerHTML;362 },363 /**364 * Checks if the dropdown needs scrolling365 *366 * @param string id The form elements id. Used to identify the correct dropdown.367 */368 AutoComplete_ScrollCheck:function(id)369 {370 // Scroll down, or wrapping around from scroll up371 if (this.__AutoComplete[id]['highlighted'] > this.__AutoComplete[id]['lastItemShowing']) {372 this.__AutoComplete[id]['firstItemShowing'] = this.__AutoComplete[id]['highlighted'] - (this.__AutoComplete[id]['maxitems'] - 1);373 this.__AutoComplete[id]['lastItemShowing'] = this.__AutoComplete[id]['highlighted'];374 }375 // Scroll up, or wrapping around from scroll down376 if (this.__AutoComplete[id]['highlighted'] < this.__AutoComplete[id]['firstItemShowing']) {377 this.__AutoComplete[id]['firstItemShowing'] = this.__AutoComplete[id]['highlighted'];378 this.__AutoComplete[id]['lastItemShowing'] = this.__AutoComplete[id]['highlighted'] + (this.__AutoComplete[id]['maxitems'] - 1);379 }380 this.__AutoComplete[id]['dropdown'].scrollTop = this.__AutoComplete[id]['firstItemShowing'] * 15;381 },382 /**383 * Function which handles the keypress event384 *385 * @param string id The form elements id. Used to identify the correct dropdown.386 */387 AutoComplete_KeyDown:function(id)388 {389 // Mozilla390 if (arguments[1] != null) {391 event = arguments[1];392 }393 var keyCode = event.keyCode;394 switch (keyCode) {395 // Return/Enter396 case 13:397 if (this.__AutoComplete[id]['highlighted'] != null) {398 this.AutoComplete_SetValue(id);399 this.AutoComplete_HideAllDropdowns();400 }401 /* commented to fix the support ticket #3331. Due to the below code kony ondone event handler associated with KEYDOWN event is not fired.402 event.returnValue = false;403 event.cancelBubble = true;404 */405 break;406 // Escape407 case 27:408 this.AutoComplete_HideAllDropdowns();409 event.returnValue = false;410 event.cancelBubble = true;411 break;412 // Up arrow413 case 38:414 if (!this.__AutoComplete[id]['isVisible']) {415 this.AutoComplete_ShowDropdown(id);416 }417 this.AutoComplete_Highlight(id, -1);418 this.AutoComplete_ScrollCheck(id, -1);419 return false;420 break;421 // Tab422 case 9:423 if (this.__AutoComplete[id]['isVisible']) {424 this.AutoComplete_HideAllDropdowns();425 }426 return;427 // Down arrow428 case 40:429 if (!this.__AutoComplete[id]['isVisible']) {430 this.AutoComplete_ShowDropdown(id);431 }432 this.AutoComplete_Highlight(id, 1);433 this.AutoComplete_ScrollCheck(id, 1);434 return false;435 break;436 }437 },438 /**439 * Function which handles the keyup event440 *441 * @param string id The form elements id. Used to identify the correct dropdown.442 */443 AutoComplete_KeyUp:function(id)444 {445 // Mozilla446 if (arguments[1] != null) {447 event = arguments[1];448 }449 var keyCode = event.keyCode;450 switch (keyCode) {451 case 13:452 event.returnValue = false;453 event.cancelBubble = true;454 break;455 case 27:456 this.AutoComplete_HideAllDropdowns();457 event.returnValue = false;458 event.cancelBubble = true;459 break;460 case 38:461 case 40:462 return false;463 break;464 default:465 this.AutoComplete_ShowDropdown(id);466 break;467 }468 },469 /**470 471 * Returns whether the dropdown is visible472 *473 * @param string id The form elements id. Used to identify the correct dropdown.474 */475 AutoComplete_isVisible:function(id)476 {477 return this__AutoComplete[id]['dropdown'].style.visibility == 'visible';478 }...

Full Screen

Full Screen

ui-autocomplete.common.js

Source:ui-autocomplete.common.js Github

copy

Full Screen

1Object.defineProperty(exports, "__esModule", { value: true });2var view_1 = require("tns-core-modules/ui/core/view");3var builder = require("tns-core-modules/ui/builder");4// Enums5var AutoCompleteDisplayMode;6(function (AutoCompleteDisplayMode) {7 AutoCompleteDisplayMode["Tokens"] = "Tokens";8 AutoCompleteDisplayMode["Plain"] = "Plain";9})(AutoCompleteDisplayMode = exports.AutoCompleteDisplayMode || (exports.AutoCompleteDisplayMode = {}));10var AutoCompleteSuggestMode;11(function (AutoCompleteSuggestMode) {12 AutoCompleteSuggestMode["Suggest"] = "Suggest";13 AutoCompleteSuggestMode["Append"] = "Append";14 AutoCompleteSuggestMode["SuggestAppend"] = "SuggestAppend";15})(AutoCompleteSuggestMode = exports.AutoCompleteSuggestMode || (exports.AutoCompleteSuggestMode = {}));16var AutoCompleteLayoutMode;17(function (AutoCompleteLayoutMode) {18 AutoCompleteLayoutMode["Horizontal"] = "Horizontal";19 AutoCompleteLayoutMode["Wrap"] = "Wrap";20})(AutoCompleteLayoutMode = exports.AutoCompleteLayoutMode || (exports.AutoCompleteLayoutMode = {}));21var AutoCompleteCompletionMode;22(function (AutoCompleteCompletionMode) {23 AutoCompleteCompletionMode["StartsWith"] = "StartsWith";24 AutoCompleteCompletionMode["Contains"] = "Contains";25})(AutoCompleteCompletionMode = exports.AutoCompleteCompletionMode || (exports.AutoCompleteCompletionMode = {}));26var AutoCompleteViewType;27(function (AutoCompleteViewType) {28 AutoCompleteViewType["ItemView"] = "ItemView";29})(AutoCompleteViewType = exports.AutoCompleteViewType || (exports.AutoCompleteViewType = {}));30// AutoComplete object classes31var SuggestionView = /** @class */ (function (_super) {32 __extends(SuggestionView, _super);33 function SuggestionView() {34 return _super.call(this) || this;35 }36 Object.defineProperty(SuggestionView.prototype, "android", {37 // properties38 get: function () {39 return undefined;40 },41 enumerable: true,42 configurable: true43 });44 Object.defineProperty(SuggestionView.prototype, "_nativeView", {45 get: function () {46 return undefined;47 },48 enumerable: true,49 configurable: true50 });51 Object.defineProperty(SuggestionView.prototype, "owner", {52 get: function () {53 return this._owner;54 },55 set: function (value) {56 this._owner = value;57 },58 enumerable: true,59 configurable: true60 });61 SuggestionView.prototype.updateView = function () {62 };63 SuggestionView.prototype.onSuggestionViewHeightPropertyChanged = function (oldValue, newValue) {64 this.onSuggestionViewHeightChanged(oldValue, newValue);65 };66 SuggestionView.prototype.onSuggestionViewHeightChanged = function (oldValue, newValue) {67 };68 SuggestionView.prototype.onSuggestionItemTemplatePropertyChanged = function (oldValue, newValue) {69 this.onSuggestionItemTemplateChanged(oldValue, newValue);70 };71 SuggestionView.prototype.onSuggestionItemTemplateChanged = function (oldValue, newValue) {72 };73 SuggestionView.suggestionViewHeightProperty = new view_1.Property({74 name: "suggestionViewHeight",75 defaultValue: undefined,76 valueConverter: function (value) {77 if (typeof value === "string") {78 return parseInt(value);79 }80 return value;81 },82 valueChanged: function (target, oldValue, newValue) {83 target.onSuggestionViewHeightPropertyChanged(oldValue, newValue);84 },85 });86 SuggestionView.suggestionItemTemplateProperty = new view_1.Property({87 name: "suggestionItemTemplate",88 defaultValue: undefined,89 valueChanged: function (target, oldValue, newValue) {90 target.onSuggestionItemTemplatePropertyChanged(oldValue, newValue);91 },92 });93 return SuggestionView;94}(view_1.View));95exports.SuggestionView = SuggestionView;96SuggestionView.suggestionViewHeightProperty.register(SuggestionView);97SuggestionView.suggestionItemTemplateProperty.register(SuggestionView);98// TokenModel99var TokenModel = /** @class */ (function () {100 function TokenModel(text, image) {101 this.text = text;102 this.image = image;103 }104 Object.defineProperty(TokenModel.prototype, "android", {105 get: function () {106 return undefined;107 },108 enumerable: true,109 configurable: true110 });111 Object.defineProperty(TokenModel.prototype, "ios", {112 get: function () {113 return undefined;114 },115 enumerable: true,116 configurable: true117 });118 return TokenModel;119}());120exports.TokenModel = TokenModel;121var CollectionViewEventData = /** @class */ (function () {122 function CollectionViewEventData() {123 }124 Object.defineProperty(CollectionViewEventData.prototype, "android", {125 get: function () {126 return this._android;127 },128 set: function (value) {129 this._android = value;130 },131 enumerable: true,132 configurable: true133 });134 Object.defineProperty(CollectionViewEventData.prototype, "ios", {135 get: function () {136 return this._ios;137 },138 set: function (value) {139 this._ios = value;140 },141 enumerable: true,142 configurable: true143 });144 Object.defineProperty(CollectionViewEventData.prototype, "eventName", {145 get: function () {146 return this._eventName;147 },148 set: function (value) {149 this._eventName = value;150 },151 enumerable: true,152 configurable: true153 });154 Object.defineProperty(CollectionViewEventData.prototype, "object", {155 get: function () {156 return this._object;157 },158 set: function (value) {159 this._object = value;160 },161 enumerable: true,162 configurable: true163 });164 Object.defineProperty(CollectionViewEventData.prototype, "index", {165 get: function () {166 return this._index;167 },168 set: function (value) {169 this._index = value;170 },171 enumerable: true,172 configurable: true173 });174 Object.defineProperty(CollectionViewEventData.prototype, "groupIndex", {175 get: function () {176 return this._groupIndex;177 },178 set: function (value) {179 this._groupIndex = value;180 },181 enumerable: true,182 configurable: true183 });184 Object.defineProperty(CollectionViewEventData.prototype, "data", {185 get: function () {186 return this._data;187 },188 set: function (value) {189 this._data = value;190 },191 enumerable: true,192 configurable: true193 });194 Object.defineProperty(CollectionViewEventData.prototype, "returnValue", {195 get: function () {196 return this._returnValue;197 },198 set: function (value) {199 this._returnValue = value;200 },201 enumerable: true,202 configurable: true203 });204 Object.defineProperty(CollectionViewEventData.prototype, "view", {205 get: function () {206 return this._view;207 },208 set: function (value) {209 this._view = value;210 },211 enumerable: true,212 configurable: true213 });214 return CollectionViewEventData;215}());216exports.CollectionViewEventData = CollectionViewEventData;217// Event object218var AutoCompleteEventData = /** @class */ (function () {219 function AutoCompleteEventData(object, eventName, text, token) {220 this._object = object;221 this._eventName = eventName;222 this._token = token;223 this._text = text;224 }225 Object.defineProperty(AutoCompleteEventData.prototype, "eventName", {226 get: function () {227 return this._eventName;228 },229 set: function (value) {230 this._eventName = value;231 },232 enumerable: true,233 configurable: true234 });235 Object.defineProperty(AutoCompleteEventData.prototype, "text", {236 get: function () {237 return this._text;238 },239 set: function (value) {240 this._text = value;241 },242 enumerable: true,243 configurable: true244 });245 Object.defineProperty(AutoCompleteEventData.prototype, "token", {246 get: function () {247 return this._token;248 },249 set: function (value) {250 this._token = value;251 },252 enumerable: true,253 configurable: true254 });255 Object.defineProperty(AutoCompleteEventData.prototype, "object", {256 get: function () {257 return this._object;258 },259 set: function (value) {260 this._object = value;261 },262 enumerable: true,263 configurable: true264 });265 return AutoCompleteEventData;266}());267exports.AutoCompleteEventData = AutoCompleteEventData;268// RadAutoComplete impl269var RadAutoCompleteTextView = /** @class */ (function (_super) {270 __extends(RadAutoCompleteTextView, _super);271 function RadAutoCompleteTextView() {272 return _super.call(this) || this;273 }274 Object.defineProperty(RadAutoCompleteTextView.prototype, "itemViewLoader", {275 // properties276 get: function () {277 return this._itemViewLoader;278 },279 set: function (value) {280 if (this._itemViewLoader !== value) {281 this._itemViewLoader = value;282 this.onItemViewLoaderChanged();283 }284 },285 enumerable: true,286 configurable: true287 });288 Object.defineProperty(RadAutoCompleteTextView.prototype, "filteredItems", {289 get: function () {290 return undefined;291 },292 enumerable: true,293 configurable: true294 });295 RadAutoCompleteTextView.prototype.onLoadSuggestionsAsyncPropertyChanged = function (oldValue, newValue) {296 this.onLoadSuggestionsAsyncChanged(oldValue, newValue);297 };298 RadAutoCompleteTextView.prototype.onLoadSuggestionsAsyncChanged = function (oldValue, newValue) {299 };300 RadAutoCompleteTextView.prototype.onItemViewLoaderChanged = function () {301 };302 RadAutoCompleteTextView.prototype.resolveTemplateView = function (template) {303 return builder.parse(template, this);304 };305 RadAutoCompleteTextView.prototype.getViewForViewType = function (viewType) {306 var newView = undefined;307 if (this._itemViewLoader !== undefined) {308 newView = this._itemViewLoader(viewType);309 }310 if (newView) {311 return newView;312 }313 var templateString = undefined;314 switch (viewType) {315 case AutoCompleteViewType.ItemView:316 if (this.suggestionView) {317 templateString = this.suggestionView.suggestionItemTemplate;318 }319 break;320 }321 return templateString === undefined ? undefined : this.resolveTemplateView(templateString);322 };323 RadAutoCompleteTextView.prototype.onItemsPropertyChanged = function (oldValue, newValue) {324 this.onItemsChanged(oldValue, newValue);325 };326 RadAutoCompleteTextView.prototype.onItemsChanged = function (oldValue, newValue) {327 };328 RadAutoCompleteTextView.prototype.onSuggestionViewPropertyChanged = function (oldValue, newValue) {329 this.onSuggestionViewChanged(oldValue, newValue);330 };331 RadAutoCompleteTextView.prototype.onSuggestionViewChanged = function (oldValue, newValue) {332 };333 RadAutoCompleteTextView.prototype.onDisplayModePropertyChanged = function (oldValue, newValue) {334 this.onDisplayModeChanged(oldValue, newValue);335 };336 RadAutoCompleteTextView.prototype.onDisplayModeChanged = function (oldValue, newValue) {337 };338 RadAutoCompleteTextView.prototype.onCompletionModePropertyChanged = function (oldValue, newValue) {339 this.onCompletionModeChanged(oldValue, newValue);340 };341 RadAutoCompleteTextView.prototype.onCompletionModeChanged = function (oldValue, newValue) {342 };343 RadAutoCompleteTextView.prototype.onLayoutModePropertyChanged = function (oldValue, newValue) {344 this.onLayoutModeChanged(oldValue, newValue);345 };346 RadAutoCompleteTextView.prototype.onLayoutModeChanged = function (oldValue, newValue) {347 };348 RadAutoCompleteTextView.prototype.onSuggestModePropertyChanged = function (oldValue, newValue) {349 this.onSuggestModeChanged(oldValue, newValue);350 };351 RadAutoCompleteTextView.prototype.onSuggestModeChanged = function (oldValue, newValue) {352 };353 RadAutoCompleteTextView.prototype.onHintPropertyChanged = function (oldValue, newValue) {354 this.onHintChanged(oldValue, newValue);355 };356 RadAutoCompleteTextView.prototype.onHintChanged = function (oldValue, newValue) {357 };358 RadAutoCompleteTextView.prototype.onTextPropertyChanged = function (oldValue, newValue) {359 this.onTextChanged(oldValue, newValue);360 };361 RadAutoCompleteTextView.prototype.onTextChanged = function (oldValue, newValue) {362 };363 RadAutoCompleteTextView.prototype.onMinimumCharactersToSearchPropertyChanged = function (oldValue, newValue) {364 this.onMinimumCharactersToSearchChanged(oldValue, newValue);365 };366 RadAutoCompleteTextView.prototype.onMinimumCharactersToSearchChanged = function (oldValue, newValue) {367 };368 RadAutoCompleteTextView.prototype.onNoResultsTextPropertyChanged = function (oldValue, newValue) {369 this.onNoResultsTextChanged(oldValue, newValue);370 };371 RadAutoCompleteTextView.prototype.onNoResultsTextChanged = function (oldValue, newValue) {372 };373 RadAutoCompleteTextView.prototype.onShowCloseButtonPropertyChanged = function (oldValue, newValue) {374 this.onShowCloseButtonChanged(oldValue, newValue);375 };376 RadAutoCompleteTextView.prototype.onShowCloseButtonChanged = function (oldValue, newValue) {377 };378 RadAutoCompleteTextView.prototype.onCloseButtonImageSrcPropertyChanged = function (oldValue, newValue) {379 this.onCloseButtonImageSrcChanged(oldValue, newValue);380 };381 RadAutoCompleteTextView.prototype.onCloseButtonImageSrcChanged = function (oldValue, newValue) {382 };383 RadAutoCompleteTextView.prototype.onReadOnlyPropertyChanged = function (oldValue, newValue) {384 this.onReadOnlyChanged(oldValue, newValue);385 };386 RadAutoCompleteTextView.prototype.onReadOnlyChanged = function (oldValue, newValue) {387 };388 // Methods389 RadAutoCompleteTextView.prototype.resetAutoComplete = function () {390 };391 RadAutoCompleteTextView.prototype.addToken = function (token) {392 };393 RadAutoCompleteTextView.prototype.insertTokenAtIndex = function (token, index) {394 };395 RadAutoCompleteTextView.prototype.removeToken = function (token) {396 };397 RadAutoCompleteTextView.prototype.removeTokenAtIndex = function (index) {398 };399 RadAutoCompleteTextView.prototype.removeAllTokens = function () {400 };401 RadAutoCompleteTextView.prototype.tokens = function () {402 };403 RadAutoCompleteTextView.prototype.tokenAtIndex = function (index) {404 };405 RadAutoCompleteTextView.textChangedEvent = "textChanged";406 RadAutoCompleteTextView.tokenRemovedEvent = "tokenRemoved";407 RadAutoCompleteTextView.tokenAddedEvent = "tokenAdded";408 RadAutoCompleteTextView.tokenSelectedEvent = "tokenSelected";409 RadAutoCompleteTextView.tokenDeselectedEvent = "tokenDeselected";410 RadAutoCompleteTextView.didAutoCompleteEvent = "didAutoComplete";411 RadAutoCompleteTextView.suggestionViewBecameVisibleEvent = "suggestionViewBecameVisible";412 RadAutoCompleteTextView.itemLoadingEvent = "itemLoading";413 RadAutoCompleteTextView.loadSuggestionsAsyncProperty = new view_1.Property({414 name: "loadSuggestionsAsync",415 defaultValue: undefined,416 valueChanged: function (target, oldValue, newValue) {417 target.onLoadSuggestionsAsyncPropertyChanged(oldValue, newValue);418 },419 });420 RadAutoCompleteTextView.itemsProperty = new view_1.Property({421 name: "items",422 defaultValue: undefined,423 valueChanged: function (target, oldValue, newValue) {424 target.onItemsPropertyChanged(oldValue, newValue);425 },426 });427 // SuggestionView428 RadAutoCompleteTextView.suggestionViewProperty = new view_1.Property({429 name: "suggestionView",430 defaultValue: undefined,431 valueChanged: function (target, oldValue, newValue) {432 target.onSuggestionViewPropertyChanged(oldValue, newValue);433 },434 });435 // Display mode436 RadAutoCompleteTextView.displayModeProperty = new view_1.Property({437 name: "displayMode",438 defaultValue: AutoCompleteDisplayMode.Plain,439 valueConverter: function (value) { return AutoCompleteDisplayMode[value]; },440 valueChanged: function (target, oldValue, newValue) {441 target.onDisplayModePropertyChanged(oldValue, newValue);442 },443 });444 // Completion Mode445 RadAutoCompleteTextView.completionModeProperty = new view_1.Property({446 name: "completionMode",447 defaultValue: AutoCompleteCompletionMode.StartsWith,448 valueConverter: function (value) { return AutoCompleteCompletionMode[value]; },449 valueChanged: function (target, oldValue, newValue) {450 target.onCompletionModePropertyChanged(oldValue, newValue);451 },452 });453 // Layout mode454 RadAutoCompleteTextView.layoutModeProperty = new view_1.Property({455 name: "layoutMode",456 defaultValue: AutoCompleteLayoutMode.Wrap,457 valueConverter: function (value) { return AutoCompleteLayoutMode[value]; },458 valueChanged: function (target, oldValue, newValue) {459 target.onLayoutModePropertyChanged(oldValue, newValue);460 },461 });462 // Suggest Mode463 RadAutoCompleteTextView.suggestModeProperty = new view_1.Property({464 name: "suggestMode",465 defaultValue: AutoCompleteSuggestMode.Suggest,466 valueConverter: function (value) { return AutoCompleteSuggestMode[value]; },467 valueChanged: function (target, oldValue, newValue) {468 target.onSuggestModePropertyChanged(oldValue, newValue);469 },470 });471 // Hint472 RadAutoCompleteTextView.hintProperty = new view_1.Property({473 name: "hint",474 defaultValue: undefined,475 valueChanged: function (target, oldValue, newValue) {476 target.onHintPropertyChanged(oldValue, newValue);477 },478 });479 // Text480 RadAutoCompleteTextView.textProperty = new view_1.Property({481 name: "text",482 defaultValue: "",483 valueChanged: function (target, oldValue, newValue) {484 target.onTextPropertyChanged(oldValue, newValue);485 },486 });487 // MinimumCharactersToSearch488 RadAutoCompleteTextView.minimumCharactersToSearchProperty = new view_1.Property({489 name: "minimumCharactersToSearch",490 defaultValue: 1,491 valueConverter: parseInt,492 valueChanged: function (target, oldValue, newValue) {493 target.onMinimumCharactersToSearchPropertyChanged(oldValue, newValue);494 },495 });496 RadAutoCompleteTextView.noResultsTextProperty = new view_1.Property({497 name: "noResultsText",498 defaultValue: undefined,499 valueChanged: function (target, oldValue, newValue) {500 target.onNoResultsTextPropertyChanged(oldValue, newValue);501 },502 });503 RadAutoCompleteTextView.showCloseButtonProperty = new view_1.Property({504 name: "showCloseButton",505 defaultValue: true,506 valueConverter: view_1.booleanConverter,507 valueChanged: function (target, oldValue, newValue) {508 target.onShowCloseButtonPropertyChanged(oldValue, newValue);509 },510 });511 RadAutoCompleteTextView.closeButtonImageSrcProperty = new view_1.Property({512 name: "closeButtonImageSrc",513 defaultValue: undefined,514 valueChanged: function (target, oldValue, newValue) {515 target.onCloseButtonImageSrcPropertyChanged(oldValue, newValue);516 },517 });518 RadAutoCompleteTextView.readOnlyProperty = new view_1.Property({519 name: "readOnly",520 defaultValue: false,521 valueConverter: view_1.booleanConverter,522 valueChanged: function (target, oldValue, newValue) {523 target.onReadOnlyPropertyChanged(oldValue, newValue);524 },525 });526 return RadAutoCompleteTextView;527}(view_1.View));528exports.RadAutoCompleteTextView = RadAutoCompleteTextView;529RadAutoCompleteTextView.loadSuggestionsAsyncProperty.register(RadAutoCompleteTextView);530RadAutoCompleteTextView.itemsProperty.register(RadAutoCompleteTextView);531RadAutoCompleteTextView.suggestionViewProperty.register(RadAutoCompleteTextView);532RadAutoCompleteTextView.displayModeProperty.register(RadAutoCompleteTextView);533RadAutoCompleteTextView.completionModeProperty.register(RadAutoCompleteTextView);534RadAutoCompleteTextView.layoutModeProperty.register(RadAutoCompleteTextView);535RadAutoCompleteTextView.suggestModeProperty.register(RadAutoCompleteTextView);536RadAutoCompleteTextView.hintProperty.register(RadAutoCompleteTextView);537RadAutoCompleteTextView.textProperty.register(RadAutoCompleteTextView);538RadAutoCompleteTextView.minimumCharactersToSearchProperty.register(RadAutoCompleteTextView);539RadAutoCompleteTextView.noResultsTextProperty.register(RadAutoCompleteTextView);540RadAutoCompleteTextView.showCloseButtonProperty.register(RadAutoCompleteTextView);541RadAutoCompleteTextView.closeButtonImageSrcProperty.register(RadAutoCompleteTextView);...

Full Screen

Full Screen

url_autocomplete_tests.js

Source:url_autocomplete_tests.js Github

copy

Full Screen

1let _ = require('lodash');2let url_pattern_matcher = require('../../src/autocomplete/url_pattern_matcher');3let autocomplete_engine = require('../../src/autocomplete/engine');4var {test, module, ok, fail, asyncTest, deepEqual, equal, start} = QUnit;5module("Url autocomplete");6function patterns_test(name, endpoints, tokenPath, expectedContext, globalUrlComponentFactories) {7 test(name, function () {8 var patternMatcher = new url_pattern_matcher.UrlPatternMatcher(globalUrlComponentFactories);9 _.each(endpoints, function (e, id) {10 e.id = id;11 _.each(e.patterns, function (p) {12 patternMatcher.addEndpoint(p, e);13 });14 });15 if (typeof tokenPath === "string") {16 if (tokenPath[tokenPath.length - 1] == "$") {17 tokenPath = tokenPath.substr(0, tokenPath.length - 1) + "/" + url_pattern_matcher.URL_PATH_END_MARKER;18 }19 tokenPath = _.map(tokenPath.split("/"), function (p) {20 p = p.split(",");21 if (p.length === 1) {22 return p[0];23 }24 return p;25 });26 }27 if (expectedContext.autoCompleteSet) {28 expectedContext.autoCompleteSet = _.map(expectedContext.autoCompleteSet, function (t) {29 if (_.isString(t)) {30 t = {name: t}31 }32 return t;33 });34 expectedContext.autoCompleteSet = _.sortBy(expectedContext.autoCompleteSet, 'name');35 }36 var context = {};37 if (expectedContext.method) {38 context.method = expectedContext.method;39 }40 autocomplete_engine.populateContext(tokenPath, context, null,41 expectedContext.autoCompleteSet, patternMatcher.getTopLevelComponents()42 );43 // override context to just check on id44 if (context.endpoint) {45 context.endpoint = context.endpoint.id;46 }47 if (context.autoCompleteSet) {48 context.autoCompleteSet = _.sortBy(context.autoCompleteSet, 'name');49 }50 deepEqual(context, expectedContext);51 });52}53function t(name, meta) {54 if (meta) {55 return {name: name, meta: meta};56 }57 return name;58}59(function () {60 var endpoints = {61 "1": {62 patterns: [63 "a/b"64 ]65 }66 };67 patterns_test("simple single path - completion",68 endpoints,69 "a/b$",70 {endpoint: "1"}71 );72 patterns_test("simple single path - completion, with auto complete",73 endpoints,74 "a/b",75 {autoCompleteSet: []}76 );77 patterns_test("simple single path - partial, without auto complete",78 endpoints,79 "a",80 {}81 );82 patterns_test("simple single path - partial, with auto complete",83 endpoints,84 "a",85 {autoCompleteSet: ["b"]}86 );87 patterns_test("simple single path - partial, with auto complete",88 endpoints,89 [],90 {autoCompleteSet: ["a/b"]}91 );92 patterns_test("simple single path - different path",93 endpoints,94 "a/c",95 {}96 );97})();98(function () {99 var endpoints = {100 "1": {101 patterns: [102 "a/b",103 "a/b/{p}"104 ]105 },106 "2": {107 patterns: [108 "a/c"109 ]110 }111 };112 patterns_test("shared path - completion 1",113 endpoints,114 "a/b$",115 {endpoint: "1"}116 );117 patterns_test("shared path - completion 2",118 endpoints,119 "a/c$",120 {endpoint: "2"}121 );122 patterns_test("shared path - completion 1 with param",123 endpoints,124 "a/b/v$",125 {endpoint: "1", p: "v"}126 );127 patterns_test("shared path - partial, with auto complete",128 endpoints,129 "a",130 {autoCompleteSet: ["b", "c"]}131 );132 patterns_test("shared path - partial, with auto complete of param, no options",133 endpoints,134 "a/b",135 {autoCompleteSet: []}136 );137 patterns_test("shared path - partial, without auto complete",138 endpoints,139 "a",140 {}141 );142 patterns_test("shared path - different path - with auto complete",143 endpoints,144 "a/e",145 {autoCompleteSet: []}146 );147 patterns_test("shared path - different path - without auto complete",148 endpoints,149 "a/e",150 {}151 );152})();153(function () {154 var endpoints = {155 "1": {156 patterns: [157 "a/{p}",158 ],159 url_components: {160 p: ["a", "b"]161 }162 },163 "2": {164 patterns: [165 "a/c"166 ]167 }168 };169 patterns_test("option testing - completion 1",170 endpoints,171 "a/a$",172 {endpoint: "1", p: ["a"]}173 );174 patterns_test("option testing - completion 2",175 endpoints,176 "a/b$",177 {endpoint: "1", p: ["b"]}178 );179 patterns_test("option testing - completion 3",180 endpoints,181 "a/b,a$",182 {endpoint: "1", p: ["b", "a"]}183 );184 patterns_test("option testing - completion 4",185 endpoints,186 "a/c$",187 {endpoint: "2"}188 );189 patterns_test("option testing - completion 5",190 endpoints,191 "a/d$",192 {}193 );194 patterns_test("option testing - partial, with auto complete",195 endpoints,196 "a",197 {autoCompleteSet: [t("a", "p"), t("b", "p"), "c"]}198 );199 patterns_test("option testing - partial, without auto complete",200 endpoints,201 "a",202 {}203 );204 patterns_test("option testing - different path - with auto complete",205 endpoints,206 "a/e",207 {autoCompleteSet: []}208 );209})();210(function () {211 var endpoints = {212 "1": {213 patterns: [214 "a/{p}",215 ],216 url_components: {217 p: ["a", "b"]218 }219 },220 "2": {221 patterns: [222 "b/{p}",223 ]224 },225 "3": {226 patterns: [227 "b/{l}/c",228 ],229 url_components: {230 l: {231 type: "list",232 list: ["la", "lb"],233 allow_non_valid: true234 }235 }236 }237 };238 var globalFactories = {239 "p": function (name, parent) {240 return new autocomplete_engine.ListComponent(name, ["g1", "g2"], parent);241 }242 };243 patterns_test("global parameters testing - completion 1",244 endpoints,245 "a/a$",246 {endpoint: "1", p: ["a"]},247 globalFactories248 );249 patterns_test("global parameters testing - completion 2",250 endpoints,251 "b/g1$",252 {endpoint: "2", p: ["g1"]},253 globalFactories254 );255 patterns_test("global parameters testing - partial, with auto complete",256 endpoints,257 "a",258 {autoCompleteSet: [t("a", "p"), t("b", "p")]},259 globalFactories260 );261 patterns_test("global parameters testing - partial, with auto complete 2",262 endpoints,263 "b",264 {autoCompleteSet: [t("g1", "p"), t("g2", "p"), t("la", "l"), t("lb", "l")]},265 globalFactories266 );267 patterns_test("Non valid token acceptance - partial, with auto complete 1",268 endpoints,269 "b/la",270 {autoCompleteSet: ["c"], "l": ["la"]},271 globalFactories272 );273 patterns_test("Non valid token acceptance - partial, with auto complete 2",274 endpoints,275 "b/non_valid",276 {autoCompleteSet: ["c"], "l": ["non_valid"]},277 globalFactories278 );279})();280(function () {281 var endpoints = {282 "1": {283 patterns: [284 "a/b/{p}/c/e"285 ]286 }287 };288 patterns_test("look ahead - autocomplete before param 1",289 endpoints,290 "a",291 {autoCompleteSet: ["b"]}292 );293 patterns_test("look ahead - autocomplete before param 2",294 endpoints,295 [],296 {autoCompleteSet: ["a/b"]}297 );298 patterns_test("look ahead - autocomplete after param 1",299 endpoints,300 "a/b/v",301 {autoCompleteSet: ["c/e"], "p": "v"}302 );303 patterns_test("look ahead - autocomplete after param 2",304 endpoints,305 "a/b/v/c",306 {autoCompleteSet: ["e"], "p": "v"}307 );308})();309(function () {310 var endpoints = {311 "1_param": {312 patterns: [313 "a/{p}"314 ],315 methods: ["GET"]316 },317 "2_explicit": {318 patterns: [319 "a/b"320 ],321 methods: ["GET"]322 }323 };324 var e = _.cloneDeep(endpoints);325 e["1_param"].priority = 1;326 patterns_test("Competing endpoints - priority 1",327 e,328 "a/b$",329 {method: "GET", endpoint: "1_param", "p": "b"}330 );331 e = _.cloneDeep(endpoints);332 e["1_param"].priority = 1;333 e["2_explicit"].priority = 0;334 patterns_test("Competing endpoints - priority 2",335 e,336 "a/b$",337 {method: "GET", endpoint: "2_explicit"}338 );339 e = _.cloneDeep(endpoints);340 e["2_explicit"].priority = 0;341 patterns_test("Competing endpoints - priority 3",342 e,343 "a/b$",344 {method: "GET", endpoint: "2_explicit"}345 );346})();347(function () {348 var endpoints = {349 "1_GET": {350 patterns: [351 "a"352 ],353 methods: ["GET"]354 },355 "1_PUT": {356 patterns: [357 "a"358 ],359 methods: ["PUT"]360 },361 "2_GET": {362 patterns: [363 "a/b"364 ],365 methods: ["GET"]366 },367 "2_DELETE": {368 patterns: [369 "a/b"370 ],371 methods: ["DELETE"]372 }373 };374 patterns_test("Competing endpoint - sub url of another - auto complete",375 endpoints,376 "a",377 {method: "GET", autoCompleteSet: ["b"]}378 );379 patterns_test("Competing endpoint - sub url of another, complete 1",380 endpoints,381 "a$",382 {method: "GET", endpoint: "1_GET"}383 );384 patterns_test("Competing endpoint - sub url of another, complete 2",385 endpoints,386 "a$",387 {method: "PUT", endpoint: "1_PUT"}388 );389 patterns_test("Competing endpoint - sub url of another, complete 3",390 endpoints,391 "a$",392 {method: "DELETE"}393 );394 patterns_test("Competing endpoint - extension of another, complete 1, auto complete",395 endpoints,396 "a/b$",397 {method: "PUT", autoCompleteSet: []}398 );399 patterns_test("Competing endpoint - extension of another, complete 1",400 endpoints,401 "a/b$",402 {method: "GET", endpoint: "2_GET"}403 );404 patterns_test("Competing endpoint - extension of another, complete 1",405 endpoints,406 "a/b$",407 {method: "DELETE", endpoint: "2_DELETE"}408 );409 patterns_test("Competing endpoint - extension of another, complete 1",410 endpoints,411 "a/b$",412 {method: "PUT"}413 );...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run avocado automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful