Best JavaScript code snippet using ava
TP.dom.CollectionNode_Tests.js
Source:TP.dom.CollectionNode_Tests.js
1// ========================================================================2/**3 * @copyright Copyright (C) 1999 Technical Pursuit Inc. (TPI) All Rights4 * Reserved. Patents Pending, Technical Pursuit Inc. Licensed under the5 * OSI-approved Reciprocal Public License (RPL) Version 1.5. See the RPL6 * for your rights and responsibilities. Contact TPI to purchase optional7 * privacy waivers if you must keep your TIBET-based source code private.8 */9// ========================================================================10// ========================================================================11// TP.dom.CollectionNode12// ========================================================================13TP.dom.CollectionNode.Inst.describe('TP.dom.CollectionNode: templating',14function() {15 var unloadURI,16 loadURI;17 unloadURI = TP.uc(TP.sys.cfg('path.blank_page'));18 // ---19 this.before(20 function(suite, options) {21 this.getDriver().showTestGUI();22 });23 // ---24 this.after(25 function(suite, options) {26 this.getDriver().showTestLog();27 });28 // ---29 this.afterEach(30 async function(test, options) {31 // Unload the current page by setting it to the32 // blank33 await this.getDriver().setLocation(unloadURI);34 // Unregister the URI to avoid a memory leak35 loadURI.unregister();36 });37 // ---38 this.it('Simple custom markup - automatic tibet:tag stamping', async function(test, options) {39 var driver,40 contentElem;41 driver = test.getDriver();42 loadURI = TP.uc('~lib_test/src/tibet/templating/Templating1.xhtml');43 await driver.setLocation(loadURI);44 // Test for elements from the template45 contentElem = TP.byId(46 'hello1', test.getDriver().get('windowContext'), false);47 test.assert.isElement(contentElem);48 test.assert.isEqualTo(49 TP.nodeGetTextContent(contentElem).trim(),50 'Hello World 1');51 });52 // ---53 this.it('Pre-transformed custom markup - automatic tibet:tag stamping', async function(test, options) {54 var driver,55 contentElem;56 driver = test.getDriver();57 loadURI = TP.uc('~lib_test/src/tibet/templating/Templating2.xhtml');58 await driver.setLocation(loadURI);59 // Test for elements from the template60 contentElem = TP.byId(61 'hello1', test.getDriver().get('windowContext'), false);62 test.assert.isElement(contentElem);63 test.assert.isEqualTo(64 TP.nodeGetTextContent(contentElem).trim(),65 'Hello World 1');66 });67 // ---68 this.it('Simple custom markup - manual tibet:tag stamping', async function(test, options) {69 var driver,70 contentElem;71 driver = test.getDriver();72 loadURI = TP.uc('~lib_test/src/tibet/templating/Templating3.xhtml');73 await driver.setLocation(loadURI);74 // Test for elements from the template75 contentElem = TP.byId(76 'hello2', driver.get('windowContext'), false);77 test.assert.isElement(contentElem);78 test.assert.isEqualTo(79 TP.nodeGetTextContent(contentElem).trim(),80 'Hello World 2');81 });82 // ---83 this.it('Pre-transformed custom markup - manual tibet:tag stamping', async function(test, options) {84 var driver,85 contentElem;86 driver = test.getDriver();87 loadURI = TP.uc('~lib_test/src/tibet/templating/Templating4.xhtml');88 await driver.setLocation(loadURI);89 // Test for elements from the template90 contentElem = TP.byId(91 'hello2', driver.get('windowContext'), false);92 test.assert.isElement(contentElem);93 test.assert.isEqualTo(94 TP.nodeGetTextContent(contentElem).trim(),95 'Hello World 2');96 });97 // ---98 this.it('Custom markup producing further custom markup - automatic tibet:tag stamping', async function(test, options) {99 var driver,100 windowContext,101 contentElem,102 contentElem2,103 contentElem3;104 driver = test.getDriver();105 windowContext = driver.get('windowContext');106 loadURI = TP.uc('~lib_test/src/tibet/templating/Templating5.xhtml');107 await driver.setLocation(loadURI);108 // Test for elements from the templates109 contentElem = TP.byId('hello3', windowContext, false);110 test.assert.isElement(contentElem);111 contentElem2 = TP.byId('helloNested', windowContext, false);112 test.assert.isElement(contentElem2);113 test.assert.isChildNodeOf(114 contentElem,115 contentElem2);116 contentElem3 = TP.byId('hello1', windowContext, false);117 test.assert.isElement(contentElem3);118 test.assert.isEqualTo(119 TP.nodeGetTextContent(contentElem3).trim(),120 'Hello World 1');121 test.assert.isChildNodeOf(122 contentElem2,123 contentElem3);124 });125 // ---126 this.it('Pre-transformed custom markup producing further custom markup - automatic tibet:tag stamping', async function(test, options) {127 var driver,128 windowContext,129 contentElem,130 contentElem2,131 contentElem3;132 driver = test.getDriver();133 windowContext = driver.get('windowContext');134 loadURI = TP.uc('~lib_test/src/tibet/templating/Templating6.xhtml');135 await driver.setLocation(loadURI);136 // Test for elements from the templates137 contentElem = TP.byId('hello3', windowContext, false);138 test.assert.isElement(contentElem);139 contentElem2 = TP.byId('helloNested', windowContext, false);140 test.assert.isElement(contentElem2);141 test.assert.isChildNodeOf(142 contentElem,143 contentElem2);144 contentElem3 = TP.byId('hello1', windowContext, false);145 test.assert.isElement(contentElem3);146 test.assert.isEqualTo(147 TP.nodeGetTextContent(contentElem3).trim(),148 'Hello World 1');149 test.assert.isChildNodeOf(150 contentElem2,151 contentElem3);152 });153 // ---154 this.it('Custom markup producing further custom markup - manual tibet:tag stamping', async function(test, options) {155 var driver,156 windowContext,157 contentElem,158 contentElem2,159 contentElem3;160 driver = test.getDriver();161 loadURI = TP.uc('~lib_test/src/tibet/templating/Templating7.xhtml');162 await driver.setLocation(loadURI);163 windowContext = driver.get('windowContext');164 // Test for elements from the templates165 contentElem = TP.byId('hello4', windowContext, false);166 test.assert.isElement(contentElem);167 contentElem2 = TP.byId('helloNested', windowContext, false);168 test.assert.isElement(contentElem2);169 test.assert.isChildNodeOf(170 contentElem,171 contentElem2);172 contentElem3 = TP.byId('hello1', windowContext, false);173 test.assert.isElement(contentElem3, windowContext, false);174 test.assert.isEqualTo(175 TP.nodeGetTextContent(contentElem3).trim(),176 'Hello World 1');177 test.assert.isChildNodeOf(178 contentElem2,179 contentElem3);180 });181 // ---182 this.it('Pre-transformed custom markup producing further custom markup - manual tibet:tag stamping', async function(test, options) {183 var driver,184 windowContext,185 contentElem,186 contentElem2,187 contentElem3;188 driver = test.getDriver();189 loadURI = TP.uc('~lib_test/src/tibet/templating/Templating8.xhtml');190 await driver.setLocation(loadURI);191 windowContext = driver.get('windowContext');192 // Test for elements from the templates193 contentElem = TP.byId('hello4', windowContext, false);194 test.assert.isElement(contentElem);195 contentElem2 = TP.byId('helloNested', windowContext, false);196 test.assert.isElement(contentElem2);197 test.assert.isChildNodeOf(198 contentElem,199 contentElem2);200 contentElem3 = TP.byId('hello1', windowContext, false);201 test.assert.isElement(contentElem3);202 test.assert.isEqualTo(203 TP.nodeGetTextContent(contentElem3).trim(),204 'Hello World 1');205 test.assert.isChildNodeOf(206 contentElem2,207 contentElem3);208 });209});210// ------------------------------------------------------------------------211TP.dom.CollectionNode.Inst.describe('TP.dom.CollectionNode: templating attribute propagation',212function() {213 var unloadURI,214 loadURI;215 unloadURI = TP.uc(TP.sys.cfg('path.blank_page'));216 // ---217 this.before(218 function(suite, options) {219 this.getDriver().showTestGUI();220 });221 // ---222 this.after(223 function(suite, options) {224 this.getDriver().showTestLog();225 });226 // ---227 this.afterEach(228 async function(test, options) {229 // Unload the current page by setting it to the230 // blank231 await this.getDriver().setLocation(unloadURI);232 // Unregister the URI to avoid a memory leak233 loadURI.unregister();234 });235 // ---236 this.it('Custom markup producing further custom markup - attribute propagation', async function(test, options) {237 var driver,238 windowContext,239 contentElem,240 contentElem2,241 contentElem3;242 driver = test.getDriver();243 loadURI = TP.uc('~lib_test/src/tibet/templating/Templating9.xhtml');244 await driver.setLocation(loadURI);245 windowContext = driver.get('windowContext');246 // Test for elements from the templates247 contentElem = TP.byId('hello5', windowContext, false);248 test.assert.isElement(contentElem);249 contentElem2 = TP.byId('helloNested', windowContext, false);250 test.assert.isElement(contentElem2);251 test.assert.isChildNodeOf(252 contentElem,253 contentElem2);254 contentElem3 = TP.byId('hello1', windowContext, false);255 test.assert.isElement(contentElem3);256 test.assert.isEqualTo(257 TP.nodeGetTextContent(contentElem3).trim(),258 'Hello World 1');259 test.assert.isChildNodeOf(260 contentElem2,261 contentElem3);262 // Check the attributes263 test.assert.hasAttribute(contentElem, 'no-nsattr');264 test.assert.hasAttribute(contentElem, 'tmp:attr1');265 test.assert.hasAttribute(contentElem, 'html:attr2');266 test.assert.isEmpty(267 TP.nodeGetNSURI(268 TP.elementGetAttributeNode(contentElem, 'no-nsattr')));269 test.assert.isEqualTo(270 TP.nodeGetNSURI(271 TP.elementGetAttributeNode(272 contentElem, 'tmp:attr1')),273 'urn:tibet:tmp');274 test.assert.isEqualTo(275 TP.nodeGetNSURI(276 TP.elementGetAttributeNode(contentElem, 'html:attr2')),277 TP.w3.Xmlns.XHTML);278 });279 // ---280 this.it('Pre-transformed custom markup producing further custom markup - attribute propagation', async function(test, options) {281 var driver,282 windowContext,283 contentElem,284 contentElem2,285 contentElem3;286 driver = test.getDriver();287 loadURI = TP.uc('~lib_test/src/tibet/templating/Templating10.xhtml');288 await driver.setLocation(loadURI);289 windowContext = driver.get('windowContext');290 // Test for elements from the templates291 contentElem = TP.byId('hello5', windowContext, false);292 test.assert.isElement(contentElem);293 contentElem2 = TP.byId('helloNested', windowContext, false);294 test.assert.isElement(contentElem2);295 test.assert.isChildNodeOf(296 contentElem,297 contentElem2);298 contentElem3 = TP.byId('hello1', windowContext, false);299 test.assert.isElement(contentElem3);300 test.assert.isEqualTo(301 TP.nodeGetTextContent(contentElem3).trim(),302 'Hello World 1');303 test.assert.isChildNodeOf(304 contentElem2,305 contentElem3);306 // Check the attributes307 test.assert.hasAttribute(contentElem, 'no-nsattr');308 test.assert.hasAttribute(contentElem, 'tmp:attr1');309 test.assert.hasAttribute(contentElem, 'html:attr2');310 test.assert.isEmpty(311 TP.nodeGetNSURI(312 TP.elementGetAttributeNode(contentElem, 'no-nsattr')));313 test.assert.isEqualTo(314 TP.nodeGetNSURI(315 TP.elementGetAttributeNode(316 contentElem, 'tmp:attr1')),317 'urn:tibet:tmp');318 test.assert.isEqualTo(319 TP.nodeGetNSURI(320 TP.elementGetAttributeNode(contentElem, 'html:attr2')),321 TP.w3.Xmlns.XHTML);322 });323});324// ------------------------------------------------------------------------325TP.dom.CollectionNode.Inst.describe('TP.dom.CollectionNode: templating with substitutions',326function() {327 var unloadURI,328 loadURI;329 unloadURI = TP.uc(TP.sys.cfg('path.blank_page'));330 // ---331 this.before(332 function(suite, options) {333 this.getDriver().showTestGUI();334 });335 // ---336 this.after(337 function(suite, options) {338 this.getDriver().showTestLog();339 });340 // ---341 this.afterEach(342 async function(test, options) {343 // Unload the current page by setting it to the344 // blank345 await this.getDriver().setLocation(unloadURI);346 // Unregister the URI to avoid a memory leak347 loadURI.unregister();348 });349 // ---350 this.it('Substitutions having variables within standard markup', async function(test, options) {351 var driver,352 windowContext,353 contentElem,354 correctVal,355 testVal;356 driver = test.getDriver();357 loadURI = TP.uc('~lib_test/src/tibet/templating/Templating11.xhtml');358 await driver.setLocation(loadURI);359 windowContext = driver.get('windowContext');360 // Test for elements from the templates361 contentElem = TP.byId('textResults', windowContext, false);362 test.assert.isElement(contentElem);363 // The content of the element should be outer content of the364 // element itself365 correctVal = '<div xmlns="http://www.w3.org/1999/xhtml" id="textResults">{{$TAG.outerContent}}</div>';366 testVal = TP.nodeGetTextContent(contentElem);367 test.assert.isEqualTo(368 testVal,369 correctVal);370 contentElem = TP.byId('attrResults', windowContext, false);371 test.assert.isElement(contentElem);372 correctVal = 'html:div';373 testVal = TP.elementGetAttribute(contentElem, 'canonical', true);374 test.assert.isEqualTo(375 testVal,376 correctVal);377 });378 // ---379 this.it('Substitutions having variables within custom markup having substitutions', async function(test, options) {380 var driver,381 windowContext,382 contentElem,383 correctVal,384 testVal;385 driver = test.getDriver();386 loadURI = TP.uc('~lib_test/src/tibet/templating/Templating12.xhtml');387 await driver.setLocation(loadURI);388 windowContext = driver.get('windowContext');389 // Test for elements from the templates390 contentElem = TP.byId('textResults', windowContext, false);391 test.assert.isElement(contentElem);392 // The content of the element should be outer content of the393 // element itself, but uppercased after it ran through the394 // custom element template.395 correctVal = /<TMP:HELLO6_TEMPLATETEST.*XMLNS:TMP="URN:TIBET:TMP".*ID="TEXTRESULTS">\{\{\$TAG.OUTERCONTENT\}\}<\/TMP:HELLO6_TEMPLATETEST>/;396 testVal = TP.nodeGetTextContent(contentElem).trim();397 test.assert.matches(398 testVal,399 correctVal);400 contentElem = TP.nodeGetFirstChildElement(TP.byId('attrResults', windowContext, false));401 test.assert.isElement(contentElem);402 correctVal = 'TMP:HELLO6_TEMPLATETEST';403 testVal = TP.elementGetAttribute(contentElem, 'templateattr', true);404 test.assert.isEqualTo(405 testVal,406 correctVal);407 });408 // ---409 this.it('Substitutions having variables within pre-transformed custom markup having substitutions', async function(test, options) {410 var driver,411 windowContext,412 contentElem,413 correctVal,414 testVal;415 driver = test.getDriver();416 loadURI = TP.uc('~lib_test/src/tibet/templating/Templating13.xhtml');417 await driver.setLocation(loadURI);418 windowContext = driver.get('windowContext');419 // Test for elements from the templates420 contentElem = TP.byId('textResults', windowContext, false);421 test.assert.isElement(contentElem);422 // The content of the element should be outer content of the423 // element itself, but uppercased after it ran through the424 // custom element template.425 testVal = TP.nodeGetTextContent(contentElem).trim();426 // NOTE: We have to test these pieces individually, since427 // different engines will have different serialization428 // mechanisms.429 correctVal = /<DIV.*/;430 test.assert.matches(431 testVal,432 correctVal);433 correctVal = /.*XMLNS="HTTP:\/\/WWW.W3.ORG\/1999\/XHTML".*/;434 test.assert.matches(435 testVal,436 correctVal);437 correctVal = /.*XMLNS:TIBET="HTTP:\/\/WWW.TECHNICALPURSUIT.COM\/1999\/TIBET".*/;438 test.assert.matches(439 testVal,440 correctVal);441 correctVal = /.*TIBET:TAG="TMP:HELLO6_TEMPLATETEST".*/;442 test.assert.matches(443 testVal,444 correctVal);445 correctVal = /.*ID="TEXTRESULTS".*/;446 test.assert.matches(447 testVal,448 correctVal);449 correctVal = /.*\{\{\$TAG.OUTERCONTENT\}\}.*/;450 test.assert.matches(451 testVal,452 correctVal);453 correctVal = /.*<\/DIV>/;454 test.assert.matches(455 testVal,456 correctVal);457 // Test the attribute substitutions458 contentElem = TP.nodeGetFirstChildElement(TP.byId('attrResults', windowContext, false));459 test.assert.isElement(contentElem);460 correctVal = 'TMP:HELLO6_TEMPLATETEST';461 testVal = TP.elementGetAttribute(contentElem, 'templateattr', true);462 test.assert.isEqualTo(463 testVal,464 correctVal);465 });466 // ---467 this.it('Substitutions having variables within custom markup producing further custom markup having substitutions', async function(test, options) {468 var driver,469 windowContext,470 contentElem,471 correctVal,472 testVal;473 driver = test.getDriver();474 loadURI = TP.uc('~lib_test/src/tibet/templating/Templating14.xhtml');475 await driver.setLocation(loadURI);476 windowContext = driver.get('windowContext');477 // Test for elements from the templates478 contentElem = TP.byId('textResults', windowContext, false);479 test.assert.isElement(contentElem);480 // The content of the element should be outer content of the481 // element itself, but uppercased after it ran through the482 // custom element template.483 correctVal = /<TMP:HELLO7_TEMPLATETEST.*XMLNS:TMP="URN:TIBET:TMP".*ID="TEXTRESULTS">\{\{\$TAG.OUTERCONTENT\}\}<\/TMP:HELLO7_TEMPLATETEST>/;484 testVal = TP.nodeGetTextContent(contentElem).trim();485 test.assert.matches(486 testVal,487 correctVal);488 contentElem = TP.byCSSPath(489 '*[nestedtemplateattr]',490 TP.byId('attrResults', windowContext, false), true, false);491 test.assert.isElement(contentElem);492 correctVal = 'tmp:hello7_templatetest';493 testVal = TP.elementGetAttribute(contentElem, 'nestedtemplateattr', true);494 test.assert.isEqualTo(495 testVal,496 correctVal);497 });498 // ---499 this.it('Substitutions having variables within pre-transformed custom markup producing further custom markup having substitutions', async function(test, options) {500 var driver,501 windowContext,502 contentElem,503 correctVal,504 testVal;505 driver = test.getDriver();506 loadURI = TP.uc('~lib_test/src/tibet/templating/Templating15.xhtml');507 await driver.setLocation(loadURI);508 windowContext = driver.get('windowContext');509 // Test for elements from the templates510 contentElem = TP.byId('textResults', windowContext, false);511 test.assert.isElement(contentElem);512 // The content of the element should be outer content of the513 // element itself, but uppercased after it ran through the514 // custom element template.515 testVal = TP.nodeGetTextContent(contentElem).trim();516 // NOTE: We have to test these pieces individually, since517 // different engines will have different serialization518 // mechanisms.519 correctVal = /<DIV.*/;520 test.assert.matches(521 testVal,522 correctVal);523 correctVal = /.*XMLNS="HTTP:\/\/WWW.W3.ORG\/1999\/XHTML".*/;524 test.assert.matches(525 testVal,526 correctVal);527 correctVal = /.*XMLNS:TIBET="HTTP:\/\/WWW.TECHNICALPURSUIT.COM\/1999\/TIBET".*/;528 test.assert.matches(529 testVal,530 correctVal);531 correctVal = /.*TIBET:TAG="TMP:HELLO7_TEMPLATETEST".*/;532 test.assert.matches(533 testVal,534 correctVal);535 correctVal = /.*ID="TEXTRESULTS".*/;536 test.assert.matches(537 testVal,538 correctVal);539 correctVal = /.*\{\{\$TAG.OUTERCONTENT\}\}.*/;540 test.assert.matches(541 testVal,542 correctVal);543 correctVal = /.*<\/DIV>/;544 test.assert.matches(545 testVal,546 correctVal);547 // Test the attribute substitutions548 contentElem = TP.byCSSPath(549 '*[nestedtemplateattr]',550 TP.byId('attrResults', windowContext, false), true, false);551 test.assert.isElement(contentElem);552 correctVal = 'tmp:hello7_templatetest';553 testVal = TP.elementGetAttribute(contentElem, 'nestedtemplateattr', true);554 test.assert.isEqualTo(555 testVal,556 correctVal);557 });558});559// ------------------------------------------------------------------------560TP.dom.CollectionNode.Inst.describe('TP.dom.CollectionNode: templating various system variable output',561function() {562 var unloadURI,563 loadURI;564 unloadURI = TP.uc(TP.sys.cfg('path.blank_page'));565 // ---566 this.before(567 function(suite, options) {568 // We use this in the tests below.569 TP.i18n.Locale.registerStrings(570 {571 HELLO: 'Hello World!'572 });573 this.getDriver().showTestGUI();574 });575 // ---576 this.after(577 function(suite, options) {578 this.getDriver().showTestLog();579 });580 // ---581 this.afterEach(582 async function(test, options) {583 // Unload the current page by setting it to the584 // blank585 await this.getDriver().setLocation(unloadURI);586 // Unregister the URI to avoid a memory leak587 loadURI.unregister();588 });589 // ---590 this.it('Substitutions having system variables within standard markup', async function(test, options) {591 var driver,592 windowContext,593 contentElem,594 correctVal,595 testVal;596 driver = test.getDriver();597 loadURI = TP.uc('~lib_test/src/tibet/templating/Templating16.xhtml');598 await driver.setLocation(loadURI);599 windowContext = driver.get('windowContext');600 // ---601 // Test for elements from the templates602 correctVal = 'lang';603 contentElem = TP.byId('textResults_1', windowContext, false);604 test.assert.isElement(contentElem);605 testVal = TP.nodeGetTextContent(contentElem);606 test.assert.isEqualTo(607 testVal,608 correctVal);609 contentElem = TP.byId('attrResults_1', windowContext, false);610 test.assert.isElement(contentElem);611 testVal = TP.elementGetAttribute(contentElem, 'value', true);612 test.assert.isEqualTo(613 testVal,614 correctVal);615 // ---616 correctVal = 'APP';617 contentElem = TP.byId('textResults_2', windowContext, false);618 test.assert.isElement(contentElem);619 testVal = TP.nodeGetTextContent(contentElem);620 test.assert.isEqualTo(621 testVal,622 correctVal);623 contentElem = TP.byId('attrResults_2', windowContext, false);624 test.assert.isElement(contentElem);625 testVal = TP.elementGetAttribute(contentElem, 'value', true);626 test.assert.isEqualTo(627 testVal,628 correctVal);629 // ---630 correctVal = 'Hello World!';631 contentElem = TP.byId('textResults_3', windowContext, false);632 test.assert.isElement(contentElem);633 testVal = TP.nodeGetTextContent(contentElem);634 test.assert.isEqualTo(635 testVal,636 correctVal);637 contentElem = TP.byId('attrResults_3', windowContext, false);638 test.assert.isElement(contentElem);639 testVal = TP.elementGetAttribute(contentElem, 'value', true);640 test.assert.isEqualTo(641 testVal,642 correctVal);643 });644});645// ------------------------------------------------------------------------646TP.dom.CollectionNode.Inst.describe('TP.dom.CollectionNode: tibet:template inline element - JS template',647function() {648 var unloadURI;649 unloadURI = TP.uc(TP.sys.cfg('path.blank_page'));650 // ---651 this.before(652 function(suite, options) {653 this.getDriver().showTestGUI();654 });655 // ---656 this.after(657 function(suite, options) {658 this.getDriver().showTestLog();659 });660 // ---661 this.afterEach(662 async function(test, options) {663 // Unload the current page by setting it to the664 // blank665 await this.getDriver().setLocation(unloadURI);666 // Unregister the URI to avoid a memory leak667 // loadURI.unregister();668 });669 // ---670 this.it('tibet:template producing standard markup', function(test, options) {671 // empty672 });673 // ---674 this.it('tibet:template producing custom markup', function(test, options) {675 // empty676 });677 // ---678 this.it('tibet:template producing pre-transformed custom markup', function(test, options) {679 // empty680 });681 // ---682 this.it('tibet:template producing custom markup producing further custom markup', function(test, options) {683 // empty684 });685 // ---686 this.it('tibet:template producing substitutions within standard markup', function(test, options) {687 // empty688 });689 // ---690 this.it('tibet:template producing substitutions within custom markup', function(test, options) {691 // empty692 });693 // ---694 this.it('tibet:template producing substitutions within custom markup producing further custom markup having substitutions', function(test, options) {695 // empty696 });697 // ---698 this.it('tibet:template producing substitutions within custom markup having variables', function(test, options) {699 // empty700 });701 // ---702 this.it('tibet:template producing substitutions within custom markup having variables producing further custom markup having substitutions', function(test, options) {703 // empty704 });705}).todo();706// ------------------------------------------------------------------------707TP.dom.CollectionNode.Inst.describe('TP.dom.CollectionNode: tibet:template inline element - XML template',708function() {709 var unloadURI;710 unloadURI = TP.uc(TP.sys.cfg('path.blank_page'));711 // ---712 this.before(713 function(suite, options) {714 this.getDriver().showTestGUI();715 });716 // ---717 this.after(718 function(suite, options) {719 this.getDriver().showTestLog();720 });721 // ---722 this.afterEach(723 async function(test, options) {724 // Unload the current page by setting it to the725 // blank726 await this.getDriver().setLocation(unloadURI);727 // Unregister the URI to avoid a memory leak728 // loadURI.unregister();729 });730 // ---731 this.it('tibet:template producing standard markup', function(test, options) {732 // empty733 });734 // ---735 this.it('tibet:template producing custom markup', function(test, options) {736 // empty737 });738 // ---739 this.it('tibet:template producing pre-transformed custom markup', function(test, options) {740 // empty741 });742 // ---743 this.it('tibet:template producing custom markup producing further custom markup', function(test, options) {744 // empty745 });746 // ---747 this.it('tibet:template producing substitutions within standard markup', function(test, options) {748 // empty749 });750 // ---751 this.it('tibet:template producing substitutions within custom markup', function(test, options) {752 // empty753 });754 // ---755 this.it('tibet:template producing substitutions within custom markup producing further custom markup having substitutions', function(test, options) {756 // empty757 });758 // ---759 this.it('tibet:template producing substitutions within custom markup having variables', function(test, options) {760 // empty761 });762 // ---763 this.it('tibet:template producing substitutions within custom markup having variables producing further custom markup having substitutions', function(test, options) {764 // empty765 });766}).todo();767// ------------------------------------------------------------------------768TP.dom.CollectionNode.Inst.describe('TP.dom.CollectionNode: tibet:template inline element - XSLT template',769function() {770 var unloadURI;771 unloadURI = TP.uc(TP.sys.cfg('path.blank_page'));772 // ---773 this.before(774 function(suite, options) {775 this.getDriver().showTestGUI();776 });777 // ---778 this.after(779 function(suite, options) {780 this.getDriver().showTestLog();781 });782 // ---783 this.afterEach(784 async function(test, options) {785 // Unload the current page by setting it to the786 // blank787 await this.getDriver().setLocation(unloadURI);788 // Unregister the URI to avoid a memory leak789 // loadURI.unregister();790 });791 // ---792 this.it('tibet:template producing standard markup', function(test, options) {793 // empty794 });795 // ---796 this.it('tibet:template producing custom markup', function(test, options) {797 // empty798 });799 // ---800 this.it('tibet:template producing pre-transformed custom markup', function(test, options) {801 // empty802 });803 // ---804 this.it('tibet:template producing custom markup producing further custom markup', function(test, options) {805 // empty806 });807 // ---808 this.it('tibet:template producing substitutions within standard markup', function(test, options) {809 // empty810 });811 // ---812 this.it('tibet:template producing substitutions within custom markup', function(test, options) {813 // empty814 });815 // ---816 this.it('tibet:template producing substitutions within custom markup producing further custom markup having substitutions', function(test, options) {817 // empty818 });819 // ---820 this.it('tibet:template producing substitutions within custom markup having variables', function(test, options) {821 // empty822 });823 // ---824 this.it('tibet:template producing substitutions within custom markup having variables producing further custom markup having substitutions', function(test, options) {825 // empty826 });827}).todo();828// ------------------------------------------------------------------------829// end...
service-worker.js
Source:service-worker.js
1/**2 * @license Copyright 2016 The Lighthouse Authors. All Rights Reserved.3 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.04 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.5 */6'use strict';7const Gatherer = require('./gatherer.js');8class ServiceWorker extends Gatherer {9 /**10 * @param {LH.Gatherer.PassContext} passContext11 * @return {Promise<LH.Artifacts['ServiceWorker']>}12 */13 async beforePass(passContext) {14 const {versions} = await passContext.driver.getServiceWorkerVersions();15 const {registrations} = await passContext.driver.getServiceWorkerRegistrations();16 return {17 versions,18 registrations,19 };20 }21}...
Using AI Code Generation
1test('Test 1', t => {2});3test('Test 2', t => {4});5test('Test 3', t => {6});7test('Test 4', t => {8});9test('Test 5', t => {10});11test('Test 6', t => {12});13test('Test 7', t => {14});15test('Test 8', t => {16});17test('Test 9', t => {18});19test('Test 10', t => {20});21test('Test 11', t => {22});23test('Test 12', t => {24});25test('Test 13', t => {26});27test('Test 14', t => {28});29test('Test 15', t => {30});31test('Test 16', t => {32});33test('Test 17', t => {34});35test('Test 18', t => {36});37test('Test 19', t => {38});39test('Test 20', t => {40});41test('Test 21', t => {42});43test('Test 22', t => {44});45test('Test 23', t => {
Using AI Code Generation
1const test = require('ava');2const webdriver = require('ava-webdriver');3const driver = webdriver();4test.beforeEach(async t => {5 t.context.driver = driver;6});7test('Test title', async t => {8 const title = await t.context.driver.getTitle();9 t.is(title, 'My App');10});11test('Test button', async t => {12 const button = await t.context.driver.findElement(By.css('button'));13 const text = await button.getText();14 t.is(text, 'Click Me');15});16test('Test button click', async t => {17 const button = await t.context.driver.findElement(By.css('button'));18 await button.click();19 const text = await button.getText();20 t.is(text, 'Clicked');21});22test('Test input', async t => {23 const input = await t.context.driver.findElement(By.css('input'));24 await input.sendKeys('Hello World');25 const text = await input.getAttribute('value');26 t.is(text, 'Hello World');27});28test('Test input change', async t => {29 const input = await t.context.driver.findElement(By.css('input'));30 await input.sendKeys('Hello World');31 const text = await input.getAttribute('value');32 t.is(text, 'Hello World');33 await input.clear();34 await input.sendKeys('Hello World 2');35 const text2 = await input.getAttribute('value');36 t.is(text2, 'Hello World 2');37});38test.afterEach.always(async t => {39 await t.context.driver.quit();40});
Using AI Code Generation
1test('my first test', async t => {2 const title = await t.context.driver.getTitle();3 t.is(title, 'Google');4});5test('my first test', async t => {6 const title = await t.context.driver.getTitle();7 t.is(title, 'Google');8});9test('my first test', async t => {10 const title = await t.context.driver.getTitle();11 t.is(title, 'Google');12});13test('my first test', async t => {14 const title = await t.context.driver.getTitle();15 t.is(title, 'Google');16});17test('my first test', async t => {18 const title = await t.context.driver.getTitle();19 t.is(title, 'Google');20});21test('my first test', async t => {22 const title = await t.context.driver.getTitle();23 t.is(title, 'Google');24});25test('my first test', async t => {26 const title = await t.context.driver.getTitle();27 t.is(title, 'Google');28});29test('my first test', async t => {30 const title = await t.context.driver.getTitle();31 t.is(title, 'Google');32});
Using AI Code Generation
1test('get method', async t => {2 t.plan(1);3 t.pass();4});5test('findElement method', async t => {6 t.plan(1);7 const element = await t.context.driver.findElement(By.name('q'));8 t.pass();9});10test('sendKeys method', async t => {11 t.plan(1);12 const element = await t.context.driver.findElement(By.name('q'));13 await element.sendKeys('webdriver', Key.RETURN);14 t.pass();15});16test('getTitle method', async t => {17 t.plan(1);18 const title = await t.context.driver.getTitle();19 t.is(title, 'webdriver - Google Search');20});21test('quit method', async t => {22 t.plan(1);23 await t.context.driver.quit();24 t.pass();25});26test('quit method', async t => {27 t.plan(1);28 await t.context.driver.quit();29 t.pass();30});
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!