How to use compareArrays method in wpt

Best JavaScript code snippet using wpt

specsPrototype.js

Source:specsPrototype.js Github

copy

Full Screen

1function specsPrototype(specs, context){2 function reduce(arr) {3 return arr.length > 1 ? arr : arr[0];4 };5 function compareArrays(array1, array2){6 value_of(array1.length).should_be(array2.length);7 for(var i = 0; i < array1.length; i++){8 value_of(array1[i]).should_be(array2[i]);9 }10 };11 function slick_find(expression, root, append){12 root = root || context.document;13 return context.SELECT(root, expression, append)[0];14 };15 var $ = function(){16 var args = arguments;17 var expression;18 var ret = [];19 for(var i=0; i < args.length; i++){20 expression = args[i];21 if(typeof expression == 'string'){22 expression = slick_find('#' + expression);23 }24 ret.push(expression);25 }26 return reduce(ret);27 };28 var $$ = function(expression, root, append){29 root = root || context.document;30 return context.SELECT(root, expression, append||[]);31 };32 Describe('Select',function(){33 it['should SelectorWithTagName'] = function(){34 compareArrays([$('strong')], $$('strong'));35 compareArrays([], $$('nonexistent'));36 var allNodesArray = [], i;37 var allNodes = context.document.getElementsByTagName('*');38 for(i = 0; i < allNodes.length; i++){39 if(allNodes[i].nodeType === 1) allNodesArray.push(allNodes[i]);40 }41 compareArrays(allNodesArray, $$('*'));42 };43 it['should SelectorWithId'] = function(){44 compareArrays([$('fixtures')], $$('#fixtures'));45 compareArrays([], $$('nonexistent'));46 compareArrays([$('troubleForm')], $$('#troubleForm'));47 };48 it['should SelectorWithClassName'] = function(){49 compareArrays($('p', 'link_1', 'item_1'), $$('.first'));50 compareArrays([], $$('.second'));51 };52 it['should SelectorWithTagNameAndId'] = function(){53 compareArrays([$('strong')], $$('strong#strong'));54 compareArrays([], $$('p#strong'));55 };56 it['should SelectorWithTagNameAndClassName'] = function(){57 compareArrays($('link_1', 'link_2'), $$('a.internal'));58 compareArrays([$('link_2')], $$('a.internal.highlight'));59 compareArrays([$('link_2')], $$('a.highlight.internal'));60 compareArrays([], $$('a.highlight.internal.nonexistent'));61 };62 it['testSelectorWithIdAndClassName'] = function(){63 compareArrays([$('link_2')], $$('#link_2.internal'));64 compareArrays([$('link_2')], $$('.internal#link_2'));65 compareArrays([$('link_2')], $$('#link_2.internal.highlight'));66 compareArrays([], $$('#link_2.internal.nonexistent'));67 };68 it['should SelectorWithTagNameAndIdAndClassName'] = function(){69 compareArrays([$('link_2')], $$('a#link_2.internal'));70 compareArrays([$('link_2')], $$('a.internal#link_2'));71 compareArrays([$('item_1')], $$('li#item_1.first'));72 compareArrays([], $$('li#item_1.nonexistent'));73 compareArrays([], $$('li#item_1.first.nonexistent'));74 };75 it['should $$MatchesAncestryWithTokensSeparatedByWhitespace'] = function(){76 compareArrays($('em2', 'em', 'span'), $$('#fixtures a *'));77 compareArrays([$('p')], $$('div#fixtures p'));78 };79 it['should SelectorWithTagNameAndAttributeExistence'] = function(){80 compareArrays($$('#fixtures h1'), $$('h1[class]'), 'h1[class]');81 compareArrays($$('#fixtures h1'), $$('h1[CLASS]'), 'h1[CLASS]');82 83 // the element has class=""84 // this test assumes that you would want to return the element, even though the value is blank85 // value_of(context.document.querySelectorAll('li#item_3[class]')).should_be([$('item_3')]);86 value_of( context.SELECT(context.document, 'li#item_3[class]', []) ).should_be([$('item_3')]);87 // compareArrays([$('item_3')], $$('li#item_3[class]'), 'li#item_3[class]');88 };89 it['should SelectorWithTagNameAndSpecificAttributeValue'] = function(){90 compareArrays($('link_1', 'link_2', 'link_3'), $$('a[href="#"]'));91 compareArrays($('link_1', 'link_2', 'link_3'), $$('a[href=#]'));92 };93 it['should SelectorWithTagNameAndWhitespaceTokenizedAttributeValue'] = function(){94 compareArrays($('link_1', 'link_2'), $$('a[class~="internal"]'));95 compareArrays($('link_1', 'link_2'), $$('a[class~=internal]'));96 };97 it['should SelectorWithAttributeAndNoTagName'] = function(){98 compareArrays($$('a[href]', $(context.document.body)), $$('[href]', $(context.document.body)));99 compareArrays($$('a[class~="internal"]'), $$('[class~=internal]'));100 compareArrays($$('*[id]'), $$('[id]'));101 compareArrays($$('#checked_radio, #unchecked_radio'), $$('[type=radio]'));102 compareArrays($$('*[type=checkbox]'), $$('[type=checkbox]'));103 compareArrays($$('#with_title, #commaParent'), $$('[title]'));104 compareArrays($$('#troubleForm *[type=radio]'), $$('#troubleForm [type=radio]'));105 compareArrays($$('#troubleForm *[type]'), $$('#troubleForm [type]'));106 };107 it['should SelectorWithAttributeContainingDash'] = function(){108 compareArrays([$('attr_with_dash')], $$('[foo-bar]'));109 };110 it['should SelectorWithUniversalAndHyphenTokenizedAttributeValue'] = function(){111 compareArrays([$('item_3')], $$('*[xml:lang|="es"]'));112 // dont agree with this spec, based on this: http://www.w3.org/TR/css3-selectors/#attribute-selectors113 // i dont see why it should ignore the case114 //compareArrays([$('item_3')], $$('*[xml:lang|="ES"]'));115 };116 it['should SelectorWithTagNameAndNegatedAttributeValue'] = function(){117 compareArrays([], $$('a[href!="#"]'));118 };119 it['should SelectorWithBracketAttributeValue'] = function(){120 compareArrays($('chk_1', 'chk_2'), $$('#troubleForm2 input[name="brackets[5][]"]'));121 compareArrays([$('chk_1')], $$('#troubleForm2 input[name="brackets[5][]"]:checked'));122 compareArrays([$('chk_2')], $$('#troubleForm2 input[name="brackets[5][]"][value=2]'));123 compareArrays([], $$('#troubleForm2 input[name=brackets[5][]]'));124 };125 it['should $$WithNestedAttributeSelectors'] = function(){126 compareArrays([$('strong')], $$('div[style] p[id] strong'));127 };128 it['should SelectorWithMultipleConditions'] = function(){129 compareArrays([$('link_3')], $$('a[class~=external][href="#"]'));130 compareArrays([], $$('a[class~=external][href!="#"]'));131 };132 it['should ElementMatch'] = function(){133 var span = $('dupL1');134 // tests that should pass135 136 value_of(context.MATCH(span, 'span')).should_be_true();137 value_of(context.MATCH(span, 'span#dupL1')).should_be_true();138 value_of(context.MATCH(span, 'div > span'), 'child combinator').should_be_true();139 value_of(context.MATCH(span, '#dupContainer span'), 'descendant combinator').should_be_true();140 value_of(context.MATCH(span, '#dupL1'), 'ID only').should_be_true();141 value_of(context.MATCH(span, 'span.span_foo'), 'class name 1').should_be_true();142 value_of(context.MATCH(span, 'span.span_bar'), 'class name 2').should_be_true();143 value_of(context.MATCH(span, 'span:first-child'), 'first-child pseudoclass').should_be_true();144 145 value_of(!context.MATCH(span, 'span.span_wtf'), 'bogus class name').should_be_true();146 value_of(!context.MATCH(span, '#dupL2'), 'different ID').should_be_true();147 value_of(!context.MATCH(span, 'div'), 'different tag name').should_be_true();148 value_of(!context.MATCH(span, 'span span'), 'different ancestry').should_be_true();149 value_of(!context.MATCH(span, 'span > span'), 'different parent').should_be_true();150 value_of(!context.MATCH(span, 'span:nth-child(5)'), 'different pseudoclass').should_be_true();151 152 value_of(!context.MATCH($('link_2'), 'a[rel^=external]')).should_be_true();153 value_of(context.MATCH($('link_1'), 'a[rel^=external]')).should_be_true();154 value_of(context.MATCH($('link_1'), 'a[rel^="external"]')).should_be_true();155 value_of(context.MATCH($('link_1'), "a[rel^='external']")).should_be_true();156 157 //value_of(context.MATCH(span, { match: function(element) { return true }}), 'custom selector').should_be_true();158 //value_of(!context.MATCH(span, { match: function(element) { return false }}), 'custom selector').should_be_true();159 };160 it['should SelectorWithSpaceInAttributeValue'] = function(){161 compareArrays([$('with_title')], $$('cite[title="hello world!"]'));162 };163 // AND NOW COME THOSE NEW TESTS AFTER ANDREW'S REWRITE!164 165 it['should SelectorWithNamespacedAttributes'] = function(){166 // if (Prototype.BrowserFeatures.XPath) {167 // this.assertUndefined(new Selector('html[xml:lang]').xpath);168 // this.assertUndefined(new Selector('body p[xml:lang]').xpath);169 // } else170 // this.info("Could not test XPath bypass: no XPath to begin with!");171 // this.assertElementsMatch($$('[xml:lang]') , 'html', '#item_3');172 // this.assertElementsMatch($$('*[xml:lang]'), 'html', '#item_3');173 value_of( $$('[xml:lang]') ).should_be([ context.document.documentElement, context.document.getElementById('item_3') ]);174 value_of( $$('*[xml:lang]') ).should_be([ context.document.documentElement, context.document.getElementById('item_3') ]);175 };176 it['should SelectorWithChild'] = function(){177 compareArrays($('link_1', 'link_2'), $$('p.first > a'));178 compareArrays($('father', 'uncle'), $$('div#grandfather > div'));179 compareArrays($('level2_1', 'level2_2'), $$('#level1>span'));180 compareArrays($('level2_1', 'level2_2'), $$('#level1 > span'));181 compareArrays($('level3_1', 'level3_2'), $$('#level2_1 > *'));182 compareArrays([], $$('div > #nonexistent'));183 };184 it['should SelectorWithAdjacence'] = function(){185 compareArrays([$('uncle')], $$('div.brothers + div.brothers'));186 compareArrays([$('uncle')], $$('div.brothers + div')); 187 value_of($('level2_2') === reduce($$('#level2_1+span'))).should_be_true();188 value_of($('level2_2') === reduce($$('#level2_1 + span'))).should_be_true();189 value_of($('level2_2') === reduce($$('#level2_1 + *'))).should_be_true();190 compareArrays([], $$('#level2_2 + span'));191 value_of($('level3_2') === reduce($$('#level3_1 + span'))).should_be_true();192 value_of($('level3_2') === reduce($$('#level3_1 + *'))).should_be_true();193 compareArrays([], $$('#level3_2 + *'));194 compareArrays([], $$('#level3_1 + em'));195 };196 it['should SelectorWithLaterSibling'] = function(){197 compareArrays([$('list')], $$('h1 ~ ul'));198 value_of($('level2_2') === reduce($$('#level2_1 ~ span'))).should_be_true();199 compareArrays($('level2_2', 'level2_3'), reduce($$('#level2_1 ~ *')));200 compareArrays([], $$('#level2_2 ~ span'));201 compareArrays([], $$('#level3_2 ~ *'));202 compareArrays([], $$('#level3_1 ~ em'));203 compareArrays([$('level3_2')], $$('#level3_1 ~ #level3_2'));204 compareArrays([$('level3_2')], $$('span ~ #level3_2'));205 compareArrays([], $$('div ~ #level3_2'));206 compareArrays([], $$('div ~ #level2_3'));207 };208 it['should SelectorWithNewAttributeOperators'] = function(){209 compareArrays($('father', 'uncle'), $$('div[class^=bro]'));210 compareArrays($('father', 'uncle'), $$('div[class$=men]'));211 compareArrays($('father', 'uncle'), $$('div[class*="ers m"]'));212 compareArrays($('level2_1', 'level2_2', 'level2_3'), $$('#level1 *[id^="level2_"]'));213 compareArrays($('level2_1', 'level2_2', 'level2_3'), $$('#level1 *[id^=level2_]'));214 compareArrays($('level2_1', 'level3_1'), $$('#level1 *[id$="_1"]'));215 compareArrays($('level2_1', 'level3_1'), $$('#level1 *[id$=_1]'));216 compareArrays($('level2_1', 'level3_2', 'level2_2', 'level2_3'), $$('#level1 *[id*="2"]'));217 compareArrays($('level2_1', 'level3_2', 'level2_2', 'level2_3'), $$('#level1 *[id*=2]'));218 };219 it['should SelectorWithDuplicates'] = function(){220 //compareArrays($$('div div'), $$('div div').uniq());221 compareArrays($('dupL2', 'dupL3', 'dupL4', 'dupL5'), $$('#dupContainer span span'));222 };223 it['should SelectorWithFirstLastOnlyNthNthLastChild'] = function(){224 compareArrays([$('level2_1')], $$('#level1>*:first-child'));225 compareArrays($('level2_1', 'level3_1', 'level_only_child'), $$('#level1 *:first-child'));226 compareArrays([$('level2_3')], $$('#level1>*:last-child'));227 compareArrays($('level3_2', 'level_only_child', 'level2_3'), $$('#level1 *:last-child'));228 compareArrays([$('level2_3')], $$('#level1>div:last-child'));229 compareArrays([$('level2_3')], $$('#level1 div:last-child'));230 compareArrays([], $$('#level1>div:first-child'));231 compareArrays([], $$('#level1>span:last-child'));232 compareArrays($('level2_1', 'level3_1'), $$('#level1 span:first-child'));233 compareArrays([], $$('#level1:first-child'));234 compareArrays([], $$('#level1>*:only-child'));235 compareArrays([$('level_only_child')], $$('#level1 *:only-child'));236 compareArrays([], $$('#level1:only-child'));237 //compareArrays([$('link_2')], $$('#p *:last-child(2)'), 'nth-last-child');238 compareArrays([$('link_2')], $$('#p *:nth-child(3)'), 'nth-child');239 compareArrays([$('link_2')], $$('#p a:nth-child(3)'), 'nth-child');240 compareArrays($('item_2', 'item_3'), $$('#list > li:nth-child(n+2)'));241 compareArrays($('item_1', 'item_2'), $$('#list > li:nth-child(-n+2)'));242 };243 244 it['should SelectorWithFirstLastNthNthLastOfType (lack of nth-of-type, nth-last-of-type, first-of-type and last-of-type)'] = function(){245 compareArrays([$('link_2')], $$('#p a:nth-of-type(2)'), 'nth-of-type');246 compareArrays([$('link_1')], $$('#p a:nth-of-type(1)'), 'nth-of-type');247 compareArrays([$('link_2')], $$('#p a:nth-last-of-type(1)'), 'nth-last-of-type');248 compareArrays([$('link_1')], $$('#p a:first-of-type'), 'first-of-type');249 compareArrays([$('link_2')], $$('#p a:last-of-type'), 'last-of-type');250 };251 it['should SelectorWithNot'] = function(){252 //compareArrays([$('link_2')], $$('#p a:not(a:first-of-type)'), 'first-of-type');253 //compareArrays([$('link_1')], $$('#p a:not(a:last-of-type)'), 'last-of-type');254 //compareArrays([$('link_2')], $$('#p a:not(a:nth-of-type(1))'), 'nth-of-type');255 //compareArrays([$('link_1')], $$('#p a:not(a:nth-last-of-type(1))'), 'nth-last-of-type');256 compareArrays([$('link_2')], $$('#p a:not([rel~=nofollow])'), 'attribute 1');257 compareArrays([$('link_2')], $$('#p a:not(a[rel^=external])'), 'attribute 2');258 compareArrays([$('link_2')], $$('#p a:not(a[rel$=nofollow])'), 'attribute 3');259 compareArrays([$('em')], $$('#p a:not(a[rel$="nofollow"]) > em'), 'attribute 4');260 compareArrays([$('item_2')], $$('#list li:not(#item_1):not(#item_3)'), 'adjacent :not clauses');261 compareArrays([$('son')], $$('#grandfather > div:not(#uncle) #son'));262 compareArrays([$('em')], $$('#p a:not(a[rel$="nofollow"]) em'), 'attribute 4 + all descendants');263 compareArrays([$('em')], $$('#p a:not(a[rel$="nofollow"])>em'), 'attribute 4 (without whitespace)');264 };265 it['should SelectorWithEnabledDisabledChecked'] = function(){266 compareArrays([$('disabled_text_field')], $$('#troubleForm > *:disabled'));267 //compareArrays($('troubleForm').getInputs().without($('disabled_text_field'), $('hidden')), $$('#troubleForm > *:enabled'));268 compareArrays($('checked_box', 'checked_radio'), $$('#troubleForm *:checked'));269 };270 it['should SelectorWithEmpty'] = function(){271 $('level3_1').innerHTML = '';272 compareArrays($('level3_1', 'level3_2', 'level2_3'), $$('#level1 *:empty'), '#level1 *:empty');273 compareArrays([], $$('#level_only_child:empty'), 'newlines count as content!');274 };275 it['should IdenticalResultsFromEquivalentSelectors (lack of nth-last-child)'] = function(){276 compareArrays($$('div.brothers'), $$('div[class~=brothers]'));277 compareArrays($$('div.brothers'), $$('div[class~=brothers].brothers'));278 compareArrays($$('div:not(.brothers)'), $$('div:not([class~=brothers])'));279 compareArrays($$('li ~ li'), $$('li:not(:first-child)'));280 compareArrays($$('ul > li'), $$('ul > li:nth-child(n)'));281 compareArrays($$('ul > li:nth-child(even)'), $$('ul > li:nth-child(2n)'));282 compareArrays($$('ul > li:nth-child(odd)'), $$('ul > li:nth-child(2n+1)'));283 compareArrays($$('ul > li:first-child'), $$('ul > li:nth-child(1)'));284 compareArrays($$('ul > li:last-child'), $$('ul > li:nth-last-child(1)'));285 compareArrays($$('ul > li:nth-child(n-999)'), $$('ul > li'));286 compareArrays($$('ul>li'), $$('ul > li'));287 compareArrays($$('#p a:not(a[rel$="nofollow"])>em'), $$('#p a:not(a[rel$="nofollow"]) > em'));288 };289 it['should SelectorsThatShouldReturnNothing'] = function(){290 compareArrays([], $$('span:empty > *'));291 compareArrays([], $$('div.brothers:not(.brothers)'));292 compareArrays([], $$('#level2_2 :only-child:not(:last-child)'));293 compareArrays([], $$('#level2_2 :only-child:not(:first-child)'));294 };295 it['should CommasFor$$ (document ordering)'] = function(){296 // fabiomcosta: specs adapted for Slick297 // fails for lack of document ordering298 compareArrays($$('#list, #p, #link_1, #item_1, #item_3, #troubleForm'), $$('#list, .first,*[xml:lang="es-us"] , #troubleForm'));299 compareArrays($$('#commaParent, #commaChild'), $$('form[title*="commas,"], input[value="#commaOne,#commaTwo"]'));300 };301 it['should $$CombinesResultsWhenMultipleExpressionsArePassed (document ordering)'] = function(){302 compareArrays($$('#link_1, #link_2, #item_1, #item_2, #item_3'), $$('#p a', null, $$(' ul#list li ')));303 };304 305 it['should SelectorNotInsertedNodes'] = function(){306 window.debug = true;307 var wrapper = context.document.createElement('div');308 wrapper.innerHTML = ("<table><tr><td id='myTD'></td></tr></table>");309 value_of(context.SELECT(wrapper, '[id=myTD]') [0]).should_not_be_undefined();310 value_of(context.SELECT(wrapper, '#myTD') [0]).should_not_be_undefined();311 value_of(context.SELECT(wrapper, 'td') [0]).should_not_be_undefined();312 value_of($$('#myTD').length == 0, 'should not turn up in document-rooted search');313 window.debug = false;314 };315 it['should DescendantSelectorBuggy'] = function(){316 var el = document.createElement('div');317 el.innerHTML = '<ul><li></li></ul><div><ul><li></li></ul></div>';318 document.body.appendChild(el);319 value_of( context.SELECT(el, 'ul li').length ).should_be( 2 );320 document.body.removeChild(el);321 };322/*323 // fabiomcosta: theres no node extension tests on slick324 it['should SelectorExtendsAllNodes'] = function(){325 var element = document.createElement('div');326 element.appendChild(document.createElement('div'));327 element.appendChild(document.createElement('div'));328 element.appendChild(document.createElement('div'));329 element.setAttribute('id','scratch_element');330 $$('body')[0].appendChild(element);331 var results = $$('#scratch_element div');332 value_of(typeof results[0].show == 'function');333 value_of(typeof results[1].show == 'function');334 value_of(typeof results[2].show == 'function');335 };336*/ 337/*338 replace descendants functionality339 it['should CountedIsNotAnAttribute'] = function(){340 var el = $('list');341 Selector.handlers.mark([el]);342 value_of(!el.innerHTML.include("_counted"));343 Selector.handlers.unmark([el]);344 value_of(!el.innerHTML.include("_counted")); 345 };346*/347/*348 replace descendants functionality349 it['should CopiedNodesGetIncluded'] = function(){350 this.assertElementsMatch(351 context.MATCH($('counted_container').descendants(), 'div'),352 'div.is_counted'353 );354 $('counted_container').innerHTML += $('counted_container').innerHTML;355 this.assertElementsMatch(356 context.MATCH($('counted_container').descendants(), 'div'), 'div.is_counted', 357 'div.is_counted'358 );359 };360*/361/*362 Prototype-specific test363 it['should ElementDown'] = function(){364 var a = $('dupL4'); 365 var b = $('dupContainer').down('#dupL4');366 this.assertEqual(a, b);367 };368*/369/*370 Prototype-specific test371 it['should ElementDownWithDotAndColon'] = function(){372 var a = $('dupL4_dotcolon'); 373 var b = $('dupContainer.withdot:active').down('#dupL4_dotcolon'); 374 var c = $('dupContainer.withdot:active').select('#dupL4_dotcolon');375 376 this.assertEqual(a, b);377 compareArrays([a], c);378 };379*/380 });...

Full Screen

Full Screen

prototype.js

Source:prototype.js Github

copy

Full Screen

...30 return context.SELECT(root, expression, append||[]);31 };32 describe('Select', function(){33 it('should SelectorWithTagName', function(){34 compareArrays([$('strong')], $$('strong'));35 compareArrays([], $$('nonexistent'));36 var allNodesArray = [], i;37 var allNodes = context.document.getElementsByTagName('*');38 for(i = 0; i < allNodes.length; i++){39 if(allNodes[i].nodeType === 1) allNodesArray.push(allNodes[i]);40 }41 compareArrays(allNodesArray, $$('*'));42 });43 it('should SelectorWithId', function(){44 compareArrays([$('fixtures')], $$('#fixtures'));45 compareArrays([], $$('nonexistent'));46 compareArrays([$('troubleForm')], $$('#troubleForm'));47 });48 it('should SelectorWithClassName', function(){49 compareArrays($('p', 'link_1', 'item_1'), $$('.first'));50 compareArrays([], $$('.second'));51 });52 it('should SelectorWithTagNameAndId', function(){53 compareArrays([$('strong')], $$('strong#strong'));54 compareArrays([], $$('p#strong'));55 });56 it('should SelectorWithTagNameAndClassName', function(){57 compareArrays($('link_1', 'link_2'), $$('a.internal'));58 compareArrays([$('link_2')], $$('a.internal.highlight'));59 compareArrays([$('link_2')], $$('a.highlight.internal'));60 compareArrays([], $$('a.highlight.internal.nonexistent'));61 });62 it('testSelectorWithIdAndClassName', function(){63 compareArrays([$('link_2')], $$('#link_2.internal'));64 compareArrays([$('link_2')], $$('.internal#link_2'));65 compareArrays([$('link_2')], $$('#link_2.internal.highlight'));66 compareArrays([], $$('#link_2.internal.nonexistent'));67 });68 it('should SelectorWithTagNameAndIdAndClassName', function(){69 compareArrays([$('link_2')], $$('a#link_2.internal'));70 compareArrays([$('link_2')], $$('a.internal#link_2'));71 compareArrays([$('item_1')], $$('li#item_1.first'));72 compareArrays([], $$('li#item_1.nonexistent'));73 compareArrays([], $$('li#item_1.first.nonexistent'));74 });75 it('should $$MatchesAncestryWithTokensSeparatedByWhitespace', function(){76 compareArrays($('em2', 'em', 'span'), $$('#fixtures a *'));77 compareArrays([$('p')], $$('div#fixtures p'));78 });79 it('should SelectorWithTagNameAndAttributeExistence', function(){80 compareArrays($$('#fixtures h1'), $$('h1[class]'), 'h1[class]');81 compareArrays($$('#fixtures h1'), $$('h1[CLASS]'), 'h1[CLASS]');82 83 // the element has class=""84 // this test assumes that you would want to return the element, even though the value is blank85 // expect(context.document.querySelectorAll('li#item_3[class]')).toEqual([$('item_3')]);86 expect( context.SELECT(context.document, 'li#item_3[class]', []) ).toEqual([$('item_3')]);87 // compareArrays([$('item_3')], $$('li#item_3[class]'), 'li#item_3[class]');88 });89 it('should SelectorWithTagNameAndSpecificAttributeValue', function(){90 compareArrays($('link_1', 'link_2', 'link_3'), $$('a[href="#"]'));91 compareArrays($('link_1', 'link_2', 'link_3'), $$('a[href=#]'));92 });93 it('should SelectorWithTagNameAndWhitespaceTokenizedAttributeValue', function(){94 compareArrays($('link_1', 'link_2'), $$('a[class~="internal"]'));95 compareArrays($('link_1', 'link_2'), $$('a[class~=internal]'));96 });97 it('should SelectorWithAttributeAndNoTagName', function(){98 compareArrays($$('a[href]', $(context.document.body)), $$('[href]', $(context.document.body)));99 compareArrays($$('a[class~="internal"]'), $$('[class~=internal]'));100 compareArrays($$('*[id]'), $$('[id]'));101 compareArrays($$('#checked_radio, #unchecked_radio'), $$('[type=radio]'));102 compareArrays($$('*[type=checkbox]'), $$('[type=checkbox]'));103 compareArrays($$('#with_title, #commaParent'), $$('[title]'));104 compareArrays($$('#troubleForm *[type=radio]'), $$('#troubleForm [type=radio]'));105 compareArrays($$('#troubleForm *[type]'), $$('#troubleForm [type]'));106 });107 it('should SelectorWithAttributeContainingDash', function(){108 compareArrays([$('attr_with_dash')], $$('[foo-bar]'));109 });110 it('should SelectorWithUniversalAndHyphenTokenizedAttributeValue', function(){111 compareArrays([$('item_3')], $$('*[xml:lang|="es"]'));112 // dont agree with this spec, based on this: http://www.w3.org/TR/css3-selectors/#attribute-selectors113 // i dont see why it should ignore the case114 //compareArrays([$('item_3')], $$('*[xml:lang|="ES"]'));115 });116 it('should SelectorWithTagNameAndNegatedAttributeValue', function(){117 compareArrays([], $$('a[href!="#"]'));118 });119 it('should SelectorWithBracketAttributeValue', function(){120 compareArrays($('chk_1', 'chk_2'), $$('#troubleForm2 input[name="brackets[5][]"]'));121 compareArrays([$('chk_1')], $$('#troubleForm2 input[name="brackets[5][]"]:checked'));122 compareArrays([$('chk_2')], $$('#troubleForm2 input[name="brackets[5][]"][value=2]'));123 compareArrays([], $$('#troubleForm2 input[name=brackets[5][]]'));124 });125 it('should $$WithNestedAttributeSelectors', function(){126 compareArrays([$('strong')], $$('div[style] p[id] strong'));127 });128 it('should SelectorWithMultipleConditions', function(){129 compareArrays([$('link_3')], $$('a[class~=external][href="#"]'));130 compareArrays([], $$('a[class~=external][href!="#"]'));131 });132 it('should ElementMatch', function(){133 var span = $('dupL1');134 // tests that should pass135 136 expect(context.MATCH(span, 'span')).toEqual(true);137 expect(context.MATCH(span, 'span#dupL1')).toEqual(true);138 expect(context.MATCH(span, 'div > span'), 'child combinator').toEqual(true);139 expect(context.MATCH(span, '#dupContainer span'), 'descendant combinator').toEqual(true);140 expect(context.MATCH(span, '#dupL1'), 'ID only').toEqual(true);141 expect(context.MATCH(span, 'span.span_foo'), 'class name 1').toEqual(true);142 expect(context.MATCH(span, 'span.span_bar'), 'class name 2').toEqual(true);143 expect(context.MATCH(span, 'span:first-child'), 'first-child pseudoclass').toEqual(true);144 145 expect(!context.MATCH(span, 'span.span_wtf'), 'bogus class name').toEqual(true);146 expect(!context.MATCH(span, '#dupL2'), 'different ID').toEqual(true);147 expect(!context.MATCH(span, 'div'), 'different tag name').toEqual(true);148 expect(!context.MATCH(span, 'span span'), 'different ancestry').toEqual(true);149 expect(!context.MATCH(span, 'span > span'), 'different parent').toEqual(true);150 expect(!context.MATCH(span, 'span:nth-child(5)'), 'different pseudoclass').toEqual(true);151 152 expect(!context.MATCH($('link_2'), 'a[rel^=external]')).toEqual(true);153 expect(context.MATCH($('link_1'), 'a[rel^=external]')).toEqual(true);154 expect(context.MATCH($('link_1'), 'a[rel^="external"]')).toEqual(true);155 expect(context.MATCH($('link_1'), "a[rel^='external']")).toEqual(true);156 157 //expect(context.MATCH(span, { match: function(element) { return true }}), 'custom selector').toEqual(true);158 //expect(!context.MATCH(span, { match: function(element) { return false }}), 'custom selector').toEqual(true);159 });160 it('should SelectorWithSpaceInAttributeValue', function(){161 compareArrays([$('with_title')], $$('cite[title="hello world!"]'));162 });163 // AND NOW COME THOSE NEW TESTS AFTER ANDREW'S REWRITE!164 165 it('should SelectorWithNamespacedAttributes', function(){166 // if (Prototype.BrowserFeatures.XPath) {167 // this.assertUndefined(new Selector('html[xml:lang]').xpath);168 // this.assertUndefined(new Selector('body p[xml:lang]').xpath);169 // } else170 // this.info("Could not test XPath bypass: no XPath to begin with!");171 // this.assertElementsMatch($$('[xml:lang]') , 'html', '#item_3');172 // this.assertElementsMatch($$('*[xml:lang]'), 'html', '#item_3');173 expect( $$('[xml:lang]') ).toEqual([ context.document.documentElement, context.document.getElementById('item_3') ]);174 expect( $$('*[xml:lang]') ).toEqual([ context.document.documentElement, context.document.getElementById('item_3') ]);175 });176 it('should SelectorWithChild', function(){177 compareArrays($('link_1', 'link_2'), $$('p.first > a'));178 compareArrays($('father', 'uncle'), $$('div#grandfather > div'));179 compareArrays($('level2_1', 'level2_2'), $$('#level1>span'));180 compareArrays($('level2_1', 'level2_2'), $$('#level1 > span'));181 compareArrays($('level3_1', 'level3_2'), $$('#level2_1 > *'));182 compareArrays([], $$('div > #nonexistent'));183 });184 it('should SelectorWithAdjacence', function(){185 compareArrays([$('uncle')], $$('div.brothers + div.brothers'));186 compareArrays([$('uncle')], $$('div.brothers + div')); 187 expect($('level2_2') === reduce($$('#level2_1+span'))).toEqual(true);188 expect($('level2_2') === reduce($$('#level2_1 + span'))).toEqual(true);189 expect($('level2_2') === reduce($$('#level2_1 + *'))).toEqual(true);190 compareArrays([], $$('#level2_2 + span'));191 expect($('level3_2') === reduce($$('#level3_1 + span'))).toEqual(true);192 expect($('level3_2') === reduce($$('#level3_1 + *'))).toEqual(true);193 compareArrays([], $$('#level3_2 + *'));194 compareArrays([], $$('#level3_1 + em'));195 });196 it('should SelectorWithLaterSibling', function(){197 compareArrays([$('list')], $$('h1 ~ ul'));198 expect($('level2_2') === reduce($$('#level2_1 ~ span'))).toEqual(true);199 compareArrays($('level2_2', 'level2_3'), reduce($$('#level2_1 ~ *')));200 compareArrays([], $$('#level2_2 ~ span'));201 compareArrays([], $$('#level3_2 ~ *'));202 compareArrays([], $$('#level3_1 ~ em'));203 compareArrays([$('level3_2')], $$('#level3_1 ~ #level3_2'));204 compareArrays([$('level3_2')], $$('span ~ #level3_2'));205 compareArrays([], $$('div ~ #level3_2'));206 compareArrays([], $$('div ~ #level2_3'));207 });208 it('should SelectorWithNewAttributeOperators', function(){209 compareArrays($('father', 'uncle'), $$('div[class^=bro]'));210 compareArrays($('father', 'uncle'), $$('div[class$=men]'));211 compareArrays($('father', 'uncle'), $$('div[class*="ers m"]'));212 compareArrays($('level2_1', 'level2_2', 'level2_3'), $$('#level1 *[id^="level2_"]'));213 compareArrays($('level2_1', 'level2_2', 'level2_3'), $$('#level1 *[id^=level2_]'));214 compareArrays($('level2_1', 'level3_1'), $$('#level1 *[id$="_1"]'));215 compareArrays($('level2_1', 'level3_1'), $$('#level1 *[id$=_1]'));216 compareArrays($('level2_1', 'level3_2', 'level2_2', 'level2_3'), $$('#level1 *[id*="2"]'));217 compareArrays($('level2_1', 'level3_2', 'level2_2', 'level2_3'), $$('#level1 *[id*=2]'));218 });219 it('should SelectorWithDuplicates', function(){220 //compareArrays($$('div div'), $$('div div').uniq());221 compareArrays($('dupL2', 'dupL3', 'dupL4', 'dupL5'), $$('#dupContainer span span'));222 });223 it('should SelectorWithFirstLastOnlyNthNthLastChild', function(){224 compareArrays([$('level2_1')], $$('#level1>*:first-child'));225 compareArrays($('level2_1', 'level3_1', 'level_only_child'), $$('#level1 *:first-child'));226 compareArrays([$('level2_3')], $$('#level1>*:last-child'));227 compareArrays($('level3_2', 'level_only_child', 'level2_3'), $$('#level1 *:last-child'));228 compareArrays([$('level2_3')], $$('#level1>div:last-child'));229 compareArrays([$('level2_3')], $$('#level1 div:last-child'));230 compareArrays([], $$('#level1>div:first-child'));231 compareArrays([], $$('#level1>span:last-child'));232 compareArrays($('level2_1', 'level3_1'), $$('#level1 span:first-child'));233 compareArrays([], $$('#level1:first-child'));234 compareArrays([], $$('#level1>*:only-child'));235 compareArrays([$('level_only_child')], $$('#level1 *:only-child'));236 compareArrays([], $$('#level1:only-child'));237 //compareArrays([$('link_2')], $$('#p *:last-child(2)'), 'nth-last-child');238 compareArrays([$('link_2')], $$('#p *:nth-child(3)'), 'nth-child');239 compareArrays([$('link_2')], $$('#p a:nth-child(3)'), 'nth-child');240 compareArrays($('item_2', 'item_3'), $$('#list > li:nth-child(n+2)'));241 compareArrays($('item_1', 'item_2'), $$('#list > li:nth-child(-n+2)'));242 });243 244 it('should SelectorWithFirstLastNthNthLastOfType', function(){245 compareArrays([$('link_2')], $$('#p a:nth-of-type(2)'), 'nth-of-type');246 compareArrays([$('link_1')], $$('#p a:nth-of-type(1)'), 'nth-of-type');247 compareArrays([$('link_2')], $$('#p a:nth-last-of-type(1)'), 'nth-last-of-type');248 compareArrays([$('link_1')], $$('#p a:first-of-type'), 'first-of-type');249 compareArrays([$('link_2')], $$('#p a:last-of-type'), 'last-of-type');250 });251 it('should SelectorWithNot', function(){252 //compareArrays([$('link_2')], $$('#p a:not(a:first-of-type)'), 'first-of-type');253 //compareArrays([$('link_1')], $$('#p a:not(a:last-of-type)'), 'last-of-type');254 //compareArrays([$('link_2')], $$('#p a:not(a:nth-of-type(1))'), 'nth-of-type');255 //compareArrays([$('link_1')], $$('#p a:not(a:nth-last-of-type(1))'), 'nth-last-of-type');256 compareArrays([$('link_2')], $$('#p a:not([rel~=nofollow])'), 'attribute 1');257 compareArrays([$('link_2')], $$('#p a:not(a[rel^=external])'), 'attribute 2');258 compareArrays([$('link_2')], $$('#p a:not(a[rel$=nofollow])'), 'attribute 3');259 compareArrays([$('em')], $$('#p a:not(a[rel$="nofollow"]) > em'), 'attribute 4');260 compareArrays([$('item_2')], $$('#list li:not(#item_1):not(#item_3)'), 'adjacent :not clauses');261 compareArrays([$('son')], $$('#grandfather > div:not(#uncle) #son'));262 compareArrays([$('em')], $$('#p a:not(a[rel$="nofollow"]) em'), 'attribute 4 + all descendants');263 compareArrays([$('em')], $$('#p a:not(a[rel$="nofollow"])>em'), 'attribute 4 (without whitespace)');264 });265 it('should SelectorWithEnabledDisabledChecked', function(){266 compareArrays([$('disabled_text_field')], $$('#troubleForm > *:disabled'));267 //compareArrays($('troubleForm').getInputs().without($('disabled_text_field'), $('hidden')), $$('#troubleForm > *:enabled'));268 compareArrays($('checked_box', 'checked_radio'), $$('#troubleForm *:checked'));269 });270 it('should SelectorWithEmpty', function(){271 $('level3_1').innerHTML = '';272 compareArrays($('level3_1', 'level3_2', 'level2_3'), $$('#level1 *:empty'), '#level1 *:empty');273 compareArrays([], $$('#level_only_child:empty'), 'newlines count as content!');274 });275 it('should IdenticalResultsFromEquivalentSelectors', function(){276 compareArrays($$('div.brothers'), $$('div[class~=brothers]'));277 compareArrays($$('div.brothers'), $$('div[class~=brothers].brothers'));278 compareArrays($$('div:not(.brothers)'), $$('div:not([class~=brothers])'));279 compareArrays($$('li ~ li'), $$('li:not(:first-child)'));280 compareArrays($$('ul > li'), $$('ul > li:nth-child(n)'));281 compareArrays($$('ul > li:nth-child(even)'), $$('ul > li:nth-child(2n)'));282 compareArrays($$('ul > li:nth-child(odd)'), $$('ul > li:nth-child(2n+1)'));283 compareArrays($$('ul > li:first-child'), $$('ul > li:nth-child(1)'));284 compareArrays($$('ul > li:last-child'), $$('ul > li:nth-last-child(1)'));285 // buggy in Opera286 compareArrays($$('ul > li:nth-child(n-999)'), $$('ul > li'));287 compareArrays($$('ul>li'), $$('ul > li'));288 compareArrays($$('#p a:not(a[rel$="nofollow"])>em'), $$('#p a:not(a[rel$="nofollow"]) > em'));289 });290 it('should SelectorsThatShouldReturnNothing', function(){291 compareArrays([], $$('span:empty > *'));292 compareArrays([], $$('div.brothers:not(.brothers)'));293 compareArrays([], $$('#level2_2 :only-child:not(:last-child)'));294 compareArrays([], $$('#level2_2 :only-child:not(:first-child)'));295 });296 it('should CommasFor$$', function(){297 compareArrays($$('#list, #p, #link_1, #item_1, #item_3, #troubleForm'), $$('#list, .first,*[xml:lang="es-us"] , #troubleForm'));298 compareArrays($$('#commaParent, #commaChild'), $$('form[title*="commas,"], input[value="#commaOne,#commaTwo"]'));299 });300 it('should $$CombinesResultsWhenMultipleExpressionsArePassed', function(){301 compareArrays($$('#link_1, #link_2, #item_1, #item_2, #item_3'), $$('#p a', null, $$(' ul#list li ')));302 });303 304 it('should SelectorNotInsertedNodes', function(){305 window.debug = true;306 var wrapper = context.document.createElement('div');307 wrapper.innerHTML = ("<table><tr><td id='myTD'></td></tr></table>");308 expect(context.SELECT(wrapper, '[id=myTD]') [0]).toBeDefined();309 expect(context.SELECT(wrapper, '#myTD') [0]).toBeDefined();310 expect(context.SELECT(wrapper, 'td') [0]).toBeDefined();311 expect($$('#myTD').length == 0, 'should not turn up in document-rooted search');312 window.debug = false;313 });314 it('should DescendantSelectorBuggy', function(){315 var el = document.createElement('div');316 el.innerHTML = '<ul><li></li></ul><div><ul><li></li></ul></div>';317 document.body.appendChild(el);318 expect( context.SELECT(el, 'ul li').length ).toEqual( 2 );319 document.body.removeChild(el);320 });321/*322 // fabiomcosta: theres no node extension tests on slick323 it('should SelectorExtendsAllNodes', function(){324 var element = document.createElement('div');325 element.appendChild(document.createElement('div'));326 element.appendChild(document.createElement('div'));327 element.appendChild(document.createElement('div'));328 element.setAttribute('id','scratch_element');329 $$('body')[0].appendChild(element);330 var results = $$('#scratch_element div');331 expect(typeof results[0].show == 'function');332 expect(typeof results[1].show == 'function');333 expect(typeof results[2].show == 'function');334 });335*/ 336/*337 replace descendants functionality338 it('should CountedIsNotAnAttribute', function(){339 var el = $('list');340 Selector.handlers.mark([el]);341 expect(!el.innerHTML.include("_counted"));342 Selector.handlers.unmark([el]);343 expect(!el.innerHTML.include("_counted"));344 });345*/346/*347 replace descendants functionality348 it('should CopiedNodesGetIncluded', function(){349 this.assertElementsMatch(350 context.MATCH($('counted_container').descendants(), 'div'),351 'div.is_counted'352 );353 $('counted_container').innerHTML += $('counted_container').innerHTML;354 this.assertElementsMatch(355 context.MATCH($('counted_container').descendants(), 'div'), 'div.is_counted', 356 'div.is_counted'357 );358 });359*/360/*361 Prototype-specific test362 it('should ElementDown', function(){363 var a = $('dupL4'); 364 var b = $('dupContainer').down('#dupL4');365 this.assertEqual(a, b);366 });367*/368/*369 Prototype-specific test370 it('should ElementDownWithDotAndColon', function(){371 var a = $('dupL4_dotcolon'); 372 var b = $('dupContainer.withdot:active').down('#dupL4_dotcolon'); 373 var c = $('dupContainer.withdot:active').select('#dupL4_dotcolon');374 375 this.assertEqual(a, b);376 compareArrays([a], c);377 });378*/379 });...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('wpt');2var compareArrays = wpt.compareArrays;3var array1 = [1,2,3,4,5];4var array2 = [1,2,3,4,5];5var result = compareArrays(array1, array2);6console.log(result);7var wpt = require('wpt');8var compareArrays = wpt.compareArrays;9var array1 = [1,2,3,4,5];10var array2 = [1,2,3,4,6];11var result = compareArrays(array1, array2);12console.log(result);13var wpt = require('wpt');14var compareArrays = wpt.compareArrays;15var array1 = [1,2,3,4,[5,6]];16var array2 = [1,2,3,4,[5,6]];17var result = compareArrays(array1, array2);18console.log(result);19var wpt = require('wpt');20var compareArrays = wpt.compareArrays;21var array1 = [1,2,3,4,[5,6]];22var array2 = [1,2,3,4,[5,7]];23var result = compareArrays(array1, array2);24console.log(result);25var wpt = require('wpt');26var compareArrays = wpt.compareArrays;27var array1 = [1,2,3,4,[5,6]];28var array2 = [1,2,3,4,[5]];29var result = compareArrays(array1, array2);30console.log(result);31var wpt = require('wpt');32var compareArrays = wpt.compareArrays;33var array1 = [1,2,3,4,[5,6]];

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('wpt');2var arr1 = [1, 2, 3];3var arr2 = [1, 2, 3];4wpt.compareArrays(arr1, arr2, function (err, data) {5 if (err) {6 console.log(err);7 } else {8 console.log(data);9 }10});

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('./wpt.js');2var array1 = [1,2,3,4,5];3var array2 = [1,2,3,4,5];4var result = wpt.compareArrays(array1, array2);5console.log(result);6var wpt = require('./wpt.js');7var array1 = [1,2,3,4,5];8var array2 = [1,2,3,4,5,6];9var result = wpt.compareArrays(array1, array2);10console.log(result);11var wpt = require('./wpt.js');12var array1 = [1,2,3,4,5];13var array2 = [1,2,3,4,5,6];14var result = wpt.compareArrays(array1, array2, true);15console.log(result);16var wpt = require('./wpt.js');17var array1 = [1,2,3,4,5];18var array2 = [1,2,3,4,5,6];19var result = wpt.compareArrays(array1, array2, false);20console.log(result);21var wpt = require('./wpt.js');22var array1 = [1,2,3,4,5];23var array2 = [1,2,3,4,5,6];24var result = wpt.compareArrays(array1, array2, false, true);25console.log(result);26var wpt = require('./wpt.js');27var array1 = [1,2,3,4,5];28var array2 = [1,2,3,4,5,6];29var result = wpt.compareArrays(array1, array2, false, false);30console.log(result);

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('./wpt');2var arr1 = [1,2,3];3var arr2 = [1,2,3];4var result = wpt.compareArrays(arr1,arr2);5console.log(result);6var compareArrays = function(arr1,arr2){7 if(arr1.length != arr2.length){8 return false;9 }10 for(var i=0;i<arr1.length;i++){11 if(arr1[i] != arr2[i]){12 return false;13 }14 }15 return true;16}17module.exports.compareArrays = compareArrays;

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('wpt.js');2var arr1 = [1,2,3,4,5,6,7,8,9,10];3var arr2 = [1,2,3,4,5,6,7,8,9,10];4var arr3 = [1,2,3,4,5,6,7,8,9,10,11];5var arr4 = [1,2,3,4,5,6,7,8,9,10,11];6var arr5 = [1,2,3,4,5,6,7,8,9,10,11];7var arr6 = [1,2,3,4,5,6,7,8,9,10,11];8var arr7 = [1,2,3,4,5,6,7,8,9,10,11];9var arr8 = [1,2,3,4,5,6,7,8,9,10,11];10var arr9 = [1,2,3,4,5,6,7,8,9,10,11];11var arr10 = [1,2,3,4,5,6,7,8,9,10,11];12var arr11 = [1,2,3,4,5,6,7,8,9,10,11];13var arr12 = [1,2,3,4,5,6,7,8,9,10,11];14var arr13 = [1,2,3,4,5,6,7,8,9,10,11];15var arr14 = [1,2,3,4,5,6,7,8,9,10,11];16var arr15 = [1,2,3,4,5,6,7,8,9,10,11];17var arr16 = [1,2,3,4,5,6,7,8,9,10,11];18var arr17 = [1,2,3,4,5,6,7,8,9,10,11];19var arr18 = [1,2,3,4,5,6,7,8,9,10,11];

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptools = require('wp-tools');2var array1 = [1, 2, 3, 4, 5, 6, 7, 8, 9];3var array2 = [1, 2, 3, 4, 5, 6, 7, 8, 9];4var array3 = [1, 2, 3, 4, 5, 6, 7, 8, 9];5var array4 = [1, 2, 3, 4, 5, 6, 7, 8, 9];6var array5 = [1, 2, 3, 4, 5, 6, 7, 8, 9];7var array6 = [1, 2, 3, 4, 5, 6, 7, 8, 9];8var array7 = [1, 2, 3, 4, 5, 6, 7, 8, 9];9var array8 = [1, 2, 3, 4, 5, 6, 7, 8, 9];10var array9 = [1, 2, 3, 4, 5, 6, 7, 8, 9];11var array10 = [1, 2, 3, 4, 5, 6, 7, 8, 9];12var array11 = [1, 2, 3, 4, 5, 6, 7, 8, 9];13var array12 = [1, 2, 3, 4, 5, 6, 7, 8, 9];14var array13 = [1, 2, 3, 4, 5, 6, 7, 8, 9];15var array14 = [1, 2, 3, 4, 5, 6, 7, 8, 9];16var array15 = [1, 2, 3, 4, 5, 6, 7, 8, 9];

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('wpt');2wpt.compareArrays([1,2,3],[1,2,3]);3var wpt = require('wpt');4wpt.compareArrays([1,2,3],[1,2,3],function(err,result){5 if(err){6 }7 else{8 }9});10var wpt = require('wpt');11wpt.compareArrays([1,2,3],[1,2,3],function(err,result){12 if(err){13 }14 else{15 }16});17var wpt = require('wpt');18wpt.compareObjects({a:1,b:2},{a:1,b:2},function(err,result){19 if(err){20 }21 else{22 }23});24var wpt = require('wpt');25wpt.compareStrings("test","test",function(err,result){26 if(err){27 }28 else{29 }30});31var wpt = require('wpt');32wpt.compareNumbers(1,1,function(err,result){33 if(err){34 }35 else{36 }37});

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var api = new wpt('API_KEY');3var options = {4};5api.runTest(options, function(err, data) {6 if (err) return console.error(err);7 api.getTestResults(data.data.testId, function(err, data) {8 if (err) return console.error(err);9 console.log(data.data.median);10 }, function(err, data) {11 if (err) return console.error(err);12 console.log(data.data.median);13 });14 });15});

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('wpt');2var compare = wpt.compareArrays([1,2,3], [1,2,3]);3console.log(compare);4compareArrays()5compareArrays(array1, array2)6var wpt = require('wpt');7var compare = wpt.compareArrays([1,2,3], [1,2,3]);8console.log(compare);

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 wpt 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