How to use testOutput method in wpt

Best JavaScript code snippet using wpt

from0427.test.js

Source:from0427.test.js Github

copy

Full Screen

1test('From 0427', () => {2 const song = [3 "a partridge in a pear tree",4 "two turtle doves",5 "three French hens",6 "four calling birds",7 "five golden rings",8 "six geese a-laying",9 "seven swans a-swimming",10 "eight maids a-milking",11 "nine ladies dancing",12 "ten lords a-leaping",13 "eleven pipers piping",14 "twelve drummers drumming"15 ]16 expect(song[0]).toBe["a partridge in a pear tree"];17 expect(song[11]).toBe["twelve drummers drumming"];18 let names = ["Alpha", "Bravo", "Charlie", "Delta", "Echo", "Foxtrot", "George", "Hotel"];19 let letters = ["A", "B", "C", "D", "E", "F", "G", "H"];20 let word = "CAB";21 function spellOut (value) {22 let result = "";23 for (let i=0; i < value.length; i++) {24 let letter = value[i];25 testOutput[testOutputLine++] = "My letter is " + letter;26 let index = letters.findIndex ( element => element === letter );27 testOutput[testOutputLine++] = "Index of this letter is " + index;28 let word = names[index];29 testOutput[testOutputLine++] = "Word is " + word;30 result = result + word + " ";31 }32 return result;33 }34 let testOutput = [];35 let testOutputLine = 0;36 37 // let spellResult = spellOut ("CAB");38 let spellResult = spellOut (word);39 40 expect(testOutput[0]).toBe("My letter is C");41 expect(testOutput[1]).toBe("Index of this letter is 2");42 expect(testOutput[2]).toBe("Word is Charlie");43 expect(testOutput[3]).toBe("My letter is A");44 expect(testOutput[4]).toBe("Index of this letter is 0");45 expect(testOutput[5]).toBe("Word is Alpha");46 expect(testOutput[6]).toBe("My letter is B");47 expect(testOutput[7]).toBe("Index of this letter is 1");48 expect(testOutput[8]).toBe("Word is Bravo");49 50 expect(spellResult).toBe("Charlie Alpha Bravo ");51 52 // Remove the G word to show risk of using arrays in future updates and53 // human error54 55 names = ["Alpha", "Bravo", "Charlie", "Delta", "Echo", "Foxtrot", "Hotel"];56 57 testOutput = [];58 testOutputLine = 0;59 60 spellResult = spellOut ("GEF");61 62 // Results expected would be "George Echo Foxtrot"63 // expect(spellResult).toBe("George Echo Foxtrot ");64 // But actually receive65 66 expect(spellResult).toBe("Hotel Echo Foxtrot ");67 68 // arrays should be same length69 // expect(names.length === letters.length).toBeTruthy();70 // But actually receive71 72 expect(names.length === letters.length).toBeFalsy();73 74 names.push("George");75 76 // "George" added back in but in wrong order.77 // Not all tests would detect the error as following are true78 // and accurate, but still an error.79 80 expect(names.length === letters.length).toBeTruthy();81 expect(names.includes("George")).toBeTruthy();82 expect(letters.includes("G")).toBeTruthy();83 84 testOutput = [];85 testOutputLine = 0;86 87 spellResult = spellOut ("GHEC");88 89 // Results expected would be "George Hotel Echo Charlie"90 // expect(spellResult).toBe("George Hotel Echo Charlie");91 // But actually receive92 93 expect(spellResult).toBe("Hotel George Echo Charlie ");94 expect(testOutput[0]).toBe("My letter is G");95 expect(testOutput[1]).toBe("Index of this letter is 6");96 expect(testOutput[2]).toBe("Word is Hotel");97 expect(testOutput[3]).toBe("My letter is H");98 expect(testOutput[4]).toBe("Index of this letter is 7");99 expect(testOutput[5]).toBe("Word is George");100 let superAlphabet = { 101 "A": "Alpha", "B": "Bravo", "C": "Charlie", "D": "Delta", 102 "E": "Echo", "F": "Foxtrot", "G": "George", "H":"Hotel"}103 // Dictionary key : value pairs104 expect(superAlphabet).toEqual({ 105 "A": "Alpha", "B": "Bravo", "C": "Charlie", "D": "Delta", 106 "E": "Echo", "F": "Foxtrot", "G": "George", "H":"Hotel"});107 expect(superAlphabet["A"]).toBe("Alpha");108 expect(superAlphabet.A).toBe("Alpha");109 110 // case sensitive so lower case results undefined111 112 expect(superAlphabet.a).toBeUndefined();113 let requiredKey = "F";114 expect(superAlphabet[requiredKey]).toBe("Foxtrot");115 116 // The following are invalid references and will117 // result in errors: Syntax or result in undefined.118 //119 // expect(superAlphabet[0]).toBe("Alpha");120 // expect(superAlphabet.requiredKey).toBe("Foxtrot");121 122 expect(superAlphabet[0]).toBeUndefined();123 // Better to use a dictionary within an array, mostly so you can use124 // all the functions available for array.125 let ultraAlphabet = [126 {"Letter": "A", "Word": "Alpha"},127 {"Letter": "B", "Word": "Bravo"}, 128 {"Letter": "C", "Word": "Charlie"}, 129 {"Letter": "D", "Word": "Delta"}, 130 {"Letter": "E", "Word": "Echo"}, 131 {"Letter": "F", "Word": "Foxtrot"}, 132 {"Letter": "G", "Word": "Golf"}, 133 {"Letter": "H", "Word": "Hotel"}];134 135 expect(ultraAlphabet.length).toBe(8);136 expect(ultraAlphabet[0]).toEqual({"Letter": "A", "Word": "Alpha"});137 expect(ultraAlphabet[7]).toEqual({"Letter": "H", "Word": "Hotel"});138 139 ultraAlphabet = [140 {"Letter": "A", "Word": "Alpha", "GermanWord": "Anton"},141 {"Letter": "B", "Word": "Bravo", "GermanWord": "Berta"}, 142 {"Letter": "C", "Word": "Charlie", "GermanWord": "Cäsar"}, 143 {"Letter": "D", "Word": "Delta", "GermanWord": "Dora"}, 144 {"Letter": "E", "Word": "Echo", "GermanWord": "Emil"}, 145 {"Letter": "F", "Word": "Foxtrot", "GermanWord": "Friedrich"}, 146 {"Letter": "G", "Word": "Golf", "GermanWord": "Gustav"}, 147 {"Letter": "H", "Word": "Hotel", "GermanWord": "Heinrich"}];148 expect(ultraAlphabet[0]).toEqual({"Letter": "A", "Word": "Alpha", "GermanWord": "Anton"});149 // Equivalent Dictionary multi-level without arrays.150 let superAltAlphabet = {151 "A": {"English": "Alpha", "German": "Anton"},152 "B": {"English": "Bravo", "German": "Berta"}, 153 "C": {"English": "Charlie", "German": "Cäsar"}, 154 "D": {"English": "Delta", "German": "Dora"}, 155 "E": {"English": "Echo", "German": "Emil"}, 156 "F": {"English": "Foxtrot", "German": "Friedrich"}, 157 "G": {"English": "Golf", "German": "Gustav"}, 158 "H": {"English": "Hotel", "German": "Heinrich"}}159 expect(superAltAlphabet["A"]).toEqual({"English": "Alpha", "German": "Anton"});160 expect(superAltAlphabet.A.English).toBe("Alpha");161 expect(superAltAlphabet.A.German).toBe("Anton");162 163 expect(superAltAlphabet[requiredKey].German).toBe("Friedrich");164 let languageKey = "German";165 expect(superAltAlphabet[requiredKey][languageKey]).toBe("Friedrich");166 //167 let germanNames = ["Anton", "Ärger", "Berta", "Cäsar", "Charlotte", "Dora", "Emil", "Friedrich", "Gustav", "Heinrich"];168 169 function spellOutGerman (value) {170 let result = "";171 for (let i=0; i < value.length; i++) {172 let letter = value[i];173 testOutput[testOutputLine++] = "My letter is " + letter;174 let index = letters.findIndex ( element => element === letter );175 testOutput[testOutputLine++] = "Index of this letter is " + index;176 let word = germanNames[index];177 testOutput[testOutputLine++] = "Word is " + word;178 result = result + word + " ";179 }180 return result;181 }182 183 testOutput = [];184 testOutputLine = 0;185 spellResult = spellOutGerman("CAB");186 187 // Results expected would be "Cäsar Anton Berta"188 // expect(spellResult).toBe("Cäsar Anton Berta");189 // But actually receive due to human error in keeping190 // lists. Using dictionaries it easier to see and 191 // visualize that the relationship to the key is192 // correct193 194 expect(spellResult).toBe("Berta Anton Ärger ");195 expect(testOutput[0]).toBe("My letter is C");196 expect(testOutput[1]).toBe("Index of this letter is 2");197 expect(testOutput[2]).toBe("Word is Berta");198 expect(testOutput[3]).toBe("My letter is A");199 expect(testOutput[4]).toBe("Index of this letter is 0");200 expect(testOutput[5]).toBe("Word is Anton");201 expect(testOutput[6]).toBe("My letter is B");202 expect(testOutput[7]).toBe("Index of this letter is 1");203 expect(testOutput[8]).toBe("Word is Ärger");204 205 testOutput = [];206 testOutputLine = 0;207 208 for (const letter of letters) {testOutput[testOutputLine++] = letter}209 210 expect(testOutput).toEqual(["A", "B", "C", "D", "E", "F", "G", "H"]);211 212 testOutput = [];213 testOutputLine = 0;214 215 letters.forEach (function (letter) {testOutput[testOutputLine++] = letter});216 217 expect(testOutput).toEqual(["A", "B", "C", "D", "E", "F", "G", "H"]);218 219 testOutput = [];220 testOutputLine = 0;221 222 for (const letterIndex in letters) {testOutput[testOutputLine++] = letterIndex}223 224 expect(testOutput).toEqual(["0", "1", "2", "3", "4", "5", "6", "7"]);225 226 testOutput = [];227 testOutputLine = 0;228 229 for (const letterIndex in letters) {testOutput[testOutputLine++] = letters[letterIndex]}230 231 expect(testOutput).toEqual(["A", "B", "C", "D", "E", "F", "G", "H"]);232 233 // Cannot do the following equivalent with dictionaries:234 //235 // for (const letter of superAlphabet) {testOutput[testOutputLine++] = letter}236 // superAlphabet.forEach (function (letter) {testOutput[testOutputLine++] = letter});237 //238 // Following works. But returns undefined 8 times, but probably undefined because239 // of console.log.240 //241 // for (const letterIndex in superAlphabet) {testOutput[testOutputLine++] = letters[letterIndex]}242 243 testOutput = [];244 testOutputLine = 0;245 246 for (const something in superAlphabet) {testOutput[testOutputLine++] = something}247 248 expect(testOutput).toEqual(["A", "B", "C", "D", "E", "F", "G", "H"]);249 testOutput = [];250 testOutputLine = 0;251 252 for (const something in superAlphabet) {testOutput[testOutputLine++] = superAlphabet[something]}253 254 expect(testOutput).toEqual(["Alpha", "Bravo", "Charlie", "Delta", "Echo", "Foxtrot", "George", "Hotel"]);255 superAlphabet.something = "What are you trying to do?";256 expect(superAlphabet.something).toBe("What are you trying to do?");257 expect(superAlphabet["something"]).toBe("What are you trying to do?");258 testOutput = [];259 testOutputLine = 0;260 261 // Code executes but is incorrect result. Showing confusion between variable 262 // "something" and key reference of ".something", and how it is not best way263 // to reference the dictionary264 for (const something in superAlphabet) {testOutput[testOutputLine++] = superAlphabet.something}265 266 expect(testOutput[0]).toEqual("What are you trying to do?");267 expect(testOutput[1]).toEqual("What are you trying to do?");268 expect(testOutput[2]).toEqual("What are you trying to do?");269 expect(testOutput[3]).toEqual("What are you trying to do?");270 expect(testOutput[4]).toEqual("What are you trying to do?");271 expect(testOutput[5]).toEqual("What are you trying to do?");272 expect(testOutput[6]).toEqual("What are you trying to do?");273 expect(testOutput[7]).toEqual("What are you trying to do?");274 expect(testOutput[8]).toEqual("What are you trying to do?");275 expect(testOutput[9]).toBeUndefined();276 testOutput = [];277 testOutputLine = 0;278 279 for (const something in superAlphabet) {testOutput[testOutputLine++] = superAlphabet[something]}280 281 expect(testOutput).toEqual(["Alpha", "Bravo", "Charlie", "Delta", "Echo", "Foxtrot", "George", 282 "Hotel", "What are you trying to do?"]);283 // Note human error in not fixing order of "Hotel" and "George" for demo of spellOut of "CAFE".284 // It works because those letters are not being used for that call to spellOut. Not to critisize285 // Roman, rather to enforce and support his message that arrays present that potential for human 286 // error, compared to using dictionaries.287 expect(names).toEqual(["Alpha", "Bravo", "Charlie", "Delta", "Echo", "Foxtrot", "Hotel", "George"]);288 expect(letters).toEqual(["A", "B", "C", "D", "E", "F", "G", "H"]);289 testOutput = [];290 testOutputLine = 0;291 expect(spellOut("CAFE")).toBe("Charlie Alpha Foxtrot Echo ");292 testOutput = [];293 testOutputLine = 0;294 295 // Demonstrates ease of going between languages, but also human error potential296 // since German word array was adjusted early for different demonstration.297 298 expect(spellOutGerman("CAFE")).toBe("Berta Anton Dora Charlotte ");299 300 function spellOutDict (letter, dict) {301 let result = "";302 for (const key in dict) {303 testOutput[testOutputLine++] = "My key is " + key;304 if (key === letter) {305 result = dict[key];306 }307 }308 return result;309 }310 testOutput = [];311 testOutputLine = 0;312 spellResult = spellOutDict("F", superAlphabet);313 expect(spellResult).toBe("Foxtrot");314 expect(testOutput[0]).toBe("My key is A");315 expect(testOutput[1]).toBe("My key is B");316 expect(testOutput[2]).toBe("My key is C");317 expect(testOutput[3]).toBe("My key is D");318 expect(testOutput[4]).toBe("My key is E");319 expect(testOutput[5]).toBe("My key is F");320 expect(testOutput[6]).toBe("My key is G");321 expect(testOutput[7]).toBe("My key is H");322 expect(testOutput[8]).toBe("My key is something");323 let spell = function (letter, dict) {324 let result = "";325 testOutput[testOutputLine++] = "I am trying to find " + letter;326 for (const key in dict) {327 testOutput[testOutputLine++] = "My key is " + key;328 if (key === letter) {329 testOutput[testOutputLine++] = "I found the right key! " + key;330 result = dict[key];331 }332 }333 return result;334 }335 336 testOutput = [];337 testOutputLine = 0;338 spellResult = spell("F", superAlphabet);339 expect(spellResult).toBe("Foxtrot");340 expect(testOutput[0]).toBe("I am trying to find F");341 expect(testOutput[1]).toBe("My key is A");342 expect(testOutput[2]).toBe("My key is B");343 expect(testOutput[3]).toBe("My key is C");344 expect(testOutput[4]).toBe("My key is D");345 expect(testOutput[5]).toBe("My key is E");346 expect(testOutput[6]).toBe("My key is F");347 expect(testOutput[7]).toBe("I found the right key! F");348 expect(testOutput[8]).toBe("My key is G");349 expect(testOutput[9]).toBe("My key is H");350 expect(testOutput[10]).toBe("My key is something");351 testOutput = [];352 testOutputLine = 0;353 for (const something of ultraAlphabet) testOutput[testOutputLine++] = something;354 expect(testOutput[0]).toEqual({"Letter": "A", "Word": "Alpha", "GermanWord": "Anton"});355 expect(testOutput[7]).toEqual({"Letter": "H", "Word": "Hotel", "GermanWord": "Heinrich"});356 testOutput = [];357 testOutputLine = 0;358 for (const something in ultraAlphabet) testOutput[testOutputLine++] = something;359 360 expect(testOutput).toEqual(["0", "1", "2", "3", "4", "5", "6", "7"]);361 362 expect(ultraAlphabet[0]).toEqual({"Letter": "A", "Word": "Alpha", "GermanWord": "Anton"});363 expect(ultraAlphabet[0].Letter).toBe("A");364 expect(ultraAlphabet[0].Word).toBe("Alpha");365 expect(ultraAlphabet[0].GermanWord).toBe("Anton");366 367 testOutput = [];368 testOutputLine = 0;369 370 for (const something of ultraAlphabet) testOutput[testOutputLine++] = something.Letter;371 372 expect(testOutput).toEqual(["A", "B", "C", "D", "E", "F", "G", "H"]);373 374 testOutput = [];375 testOutputLine = 0;376 377 for (const something of ultraAlphabet) testOutput[testOutputLine++] = something.Word;378 379 expect(testOutput).toEqual(["Alpha", "Bravo", "Charlie", "Delta", "Echo", "Foxtrot", "Golf", "Hotel"]);380 testOutput = [];381 testOutputLine = 0;382 383 for (const something of ultraAlphabet) testOutput[testOutputLine++] = something.GermanWord;384 385 expect(testOutput).toEqual(["Anton", "Berta", "Cäsar", "Dora", "Emil", "Friedrich", "Gustav", "Heinrich"]);386 387 let language = "Word";388 389 testOutput = [];390 testOutputLine = 0;391 392 for (const something of ultraAlphabet) testOutput[testOutputLine++] = something[language];393 394 expect(testOutput).toEqual(["Alpha", "Bravo", "Charlie", "Delta", "Echo", "Foxtrot", "Golf", "Hotel"]);395 396 language = "GermanWord";397 398 testOutput = [];399 testOutputLine = 0;400 401 for (const something of ultraAlphabet) testOutput[testOutputLine++] = something[language];402 403 expect(testOutput).toEqual(["Anton", "Berta", "Cäsar", "Dora", "Emil", "Friedrich", "Gustav", "Heinrich"]);404 // Break405 let phrases = [406 {"lang": "en", "words": {"greet": "Hello", "farewell": "Goodbye"}}, 407 {"lang": "de", "words": {"greet": "Hallo", "farewell": "Auf wierdersehen"}},408 {"lang": "es", "words": {"greet": "Hola", "farewell": "Hasta luego"}},409 {"lang": "pt", "words": {"greet": "Olá", "farewell": "Tchau"}},410 {"lang": "it", "words": {"greet": "Ciao", "farewell": "Addio"}}411 ]412 testOutput = [];413 testOutputLine = 0;414 for (const something in phrases) testOutput[testOutputLine++] = something;415 416 expect(testOutput).toEqual(["0", "1", "2", "3", "4"]);417 testOutput = [];418 testOutputLine = 0;419 for (const something in phrases[0]) testOutput[testOutputLine++] = something;420 421 expect(testOutput).toEqual(["lang", "words"]);422 423 testOutput = [];424 testOutputLine = 0;425 426 for (const something of phrases) testOutput[testOutputLine++] = something;427 428 expect(testOutput[0]).toEqual({"lang": "en", "words": {"greet": "Hello", "farewell": "Goodbye"}});429 expect(testOutput[1]).toEqual({"lang": "de", "words": {"greet": "Hallo", "farewell": "Auf wierdersehen"}});430 expect(testOutput[2]).toEqual({"lang": "es", "words": {"greet": "Hola", "farewell": "Hasta luego"}});431 expect(testOutput[3]).toEqual({"lang": "pt", "words": {"greet": "Olá", "farewell": "Tchau"}});432 expect(testOutput[4]).toEqual({"lang": "it", "words": {"greet": "Ciao", "farewell": "Addio"}});433 434 testOutput = [];435 testOutputLine = 0;436 437 for (const something of phrases) testOutput[testOutputLine++] = something.lang;438 439 expect(testOutput).toEqual(["en", "de", "es", "pt", "it"]);440 441 testOutput = [];442 testOutputLine = 0;443 444 for (const something of phrases) testOutput[testOutputLine++] = something.words;445 446 expect(testOutput[0]).toEqual({"greet": "Hello", "farewell": "Goodbye"});447 expect(testOutput[1]).toEqual({"greet": "Hallo", "farewell": "Auf wierdersehen"});448 expect(testOutput[2]).toEqual({"greet": "Hola", "farewell": "Hasta luego"});449 expect(testOutput[3]).toEqual({"greet": "Olá", "farewell": "Tchau"});450 expect(testOutput[4]).toEqual({"greet": "Ciao", "farewell": "Addio"});451 452 testOutput = [];453 testOutputLine = 0;454 455 for (const something of phrases) testOutput[testOutputLine++] = something.words.greet;456 expect(testOutput).toEqual(["Hello", "Hallo", "Hola", "Olá", "Ciao"]);457 expect(phrases[4].words.farewell).toBe("Addio");458 let utter = function (what, language) {459 testOutput[testOutputLine++] = what + " " + language}460 461 testOutput = [];462 testOutputLine = 0;463 464 utter ("greet", "it");465 466 expect(testOutput[0]).toBe("greet it");467 468 utter = function (what, language) {469 const phrases = [470 {"lang": "en", "words": {"greet": "Hello", "farewell": "Goodbye"}}, 471 {"lang": "de", "words": {"greet": "Hallo", "farewell": "Auf wierdersehen"}},472 {"lang": "es", "words": {"greet": "Hola", "farewell": "Hasta luego"}},473 {"lang": "pt", "words": {"greet": "Olá", "farewell": "Tchau"}},474 {"lang": "it", "words": {"greet": "Ciao", "farewell": "Addio"}}475 ]476 testOutput[testOutputLine++] = what + " " + language;477 for (const someLanguage of phrases) {478 testOutput[testOutputLine++] = "Next language is " + someLanguage;479 if (someLanguage.lang === language) {480 testOutput[testOutputLine++] = "Oh! I found my language! " + someLanguage;481 } else {482 testOutput[testOutputLine++] = "Nope, that is not what I want ";483 }484 }485 }486 testOutput = [];487 testOutputLine = 0;488 489 utter ("whatever", "en");490 491 expect(testOutput[0]).toBe("whatever en");492 expect(testOutput[1]).toBe("Next language is [object Object]");493 expect(testOutput[2]).toBe("Oh! I found my language! [object Object]");494 expect(testOutput[3]).toBe("Next language is [object Object]");495 expect(testOutput[4]).toBe("Nope, that is not what I want ");496 expect(testOutput[9]).toBe("Next language is [object Object]");497 expect(testOutput[10]).toBe("Nope, that is not what I want ");498 testOutput = [];499 testOutputLine = 0;500 501 utter ("whatever", "it");502 503 expect(testOutput[0]).toBe("whatever it");504 expect(testOutput[1]).toBe("Next language is [object Object]");505 expect(testOutput[2]).toBe("Nope, that is not what I want ");506 expect(testOutput[3]).toBe("Next language is [object Object]");507 expect(testOutput[4]).toBe("Nope, that is not what I want ");508 expect(testOutput[9]).toBe("Next language is [object Object]");509 expect(testOutput[10]).toBe("Oh! I found my language! [object Object]");510 utter = function (what, language) {511 const phrases = [512 {"lang": "en", "words": {"greet": "Hello", "farewell": "Goodbye"}}, 513 {"lang": "de", "words": {"greet": "Hallo", "farewell": "Auf wierdersehen"}},514 {"lang": "es", "words": {"greet": "Hola", "farewell": "Hasta luego"}},515 {"lang": "pt", "words": {"greet": "Olá", "farewell": "Tchau"}},516 {"lang": "it", "words": {"greet": "Ciao", "farewell": "Addio"}}517 ]518 testOutput[testOutputLine++] = what + " " + language;519 for (const someLanguage of phrases) {520 testOutput[testOutputLine++] = "Next language is " + someLanguage;521 if (someLanguage.lang === language) {522 testOutput[testOutputLine++] = "Oh! I found my language! " + someLanguage;523 break;524 } else {525 testOutput[testOutputLine++] = "Nope, that is not what I want ";526 }527 }528 }529 testOutput = [];530 testOutputLine = 0;531 532 utter ("whatever", "en");533 534 expect(testOutput[0]).toBe("whatever en");535 expect(testOutput[1]).toBe("Next language is [object Object]");536 expect(testOutput[2]).toBe("Oh! I found my language! [object Object]");537 expect(testOutput[3]).toBeUndefined();538 utter = function (what, language) {539 const phrases = [540 {"lang": "en", "words": {"greet": "Hello", "farewell": "Goodbye"}}, 541 {"lang": "de", "words": {"greet": "Hallo", "farewell": "Auf wierdersehen"}},542 {"lang": "es", "words": {"greet": "Hola", "farewell": "Hasta luego"}},543 {"lang": "pt", "words": {"greet": "Olá", "farewell": "Tchau"}},544 {"lang": "it", "words": {"greet": "Ciao", "farewell": "Addio"}}545 ]546 testOutput[testOutputLine++] = what + " " + language;547 for (const someLanguage of phrases) {548 testOutput[testOutputLine++] = "Next language is " + someLanguage;549 if (someLanguage.lang === language) {550 testOutput[testOutputLine++] = "Oh! I found my language! " + someLanguage;551 testOutput[testOutputLine++] = "My words are " + someLanguage.words;552 break;553 } else {554 testOutput[testOutputLine++] = "Nope, that is not what I want ";555 }556 }557 }558 559 testOutput = [];560 testOutputLine = 0;561 562 utter ("whatever", "pt");563 564 expect(testOutput[0]).toBe("whatever pt");565 expect(testOutput[1]).toBe("Next language is [object Object]");566 expect(testOutput[2]).toBe("Nope, that is not what I want ");567 expect(testOutput[3]).toBe("Next language is [object Object]");568 expect(testOutput[4]).toBe("Nope, that is not what I want ");569 expect(testOutput[5]).toBe("Next language is [object Object]");570 expect(testOutput[6]).toBe("Nope, that is not what I want ");571 expect(testOutput[7]).toBe("Next language is [object Object]");572 expect(testOutput[8]).toBe("Oh! I found my language! [object Object]");573 expect(testOutput[9]).toBe("My words are [object Object]");574 expect(testOutput[10]).toBeUndefined();575 utter = function (what, language) {576 const phrases = [577 {"lang": "en", "words": {"greet": "Hello", "farewell": "Goodbye"}}, 578 {"lang": "de", "words": {"greet": "Hallo", "farewell": "Auf wierdersehen"}},579 {"lang": "es", "words": {"greet": "Hola", "farewell": "Hasta luego"}},580 {"lang": "pt", "words": {"greet": "Olá", "farewell": "Tchau"}},581 {"lang": "it", "words": {"greet": "Ciao", "farewell": "Addio"}}582 ]583 testOutput[testOutputLine++] = what + " " + language;584 for (const someLanguage of phrases) {585 testOutput[testOutputLine++] = "Next language is " + someLanguage;586 if (someLanguage.lang === language) {587 testOutput[testOutputLine++] = "Oh! I found my language! " + someLanguage;588 testOutput[testOutputLine++] = "The word I am looking for is " + someLanguage.words[what];589 break;590 } else {591 testOutput[testOutputLine++] = "Nope, that is not what I want ";592 }593 }594 }595 596 testOutput = [];597 testOutputLine = 0;598 599 utter ("greet", "pt");600 601 expect(testOutput[0]).toBe("greet pt");602 expect(testOutput[1]).toBe("Next language is [object Object]");603 expect(testOutput[2]).toBe("Nope, that is not what I want ");604 expect(testOutput[3]).toBe("Next language is [object Object]");605 expect(testOutput[4]).toBe("Nope, that is not what I want ");606 expect(testOutput[5]).toBe("Next language is [object Object]");607 expect(testOutput[6]).toBe("Nope, that is not what I want ");608 expect(testOutput[7]).toBe("Next language is [object Object]");609 expect(testOutput[8]).toBe("Oh! I found my language! [object Object]");610 expect(testOutput[9]).toBe("The word I am looking for is Olá");611 expect(testOutput[10]).toBeUndefined();612 utter = function (what, language) {613 // Environment614 const phrases = [615 {"lang": "en", "words": {"greet": "Hello", "farewell": "Goodbye"}}, 616 {"lang": "de", "words": {"greet": "Hallo", "farewell": "Auf wierdersehen"}},617 {"lang": "es", "words": {"greet": "Hola", "farewell": "Hasta luego"}},618 {"lang": "pt", "words": {"greet": "Olá", "farewell": "Tchau"}},619 {"lang": "it", "words": {"greet": "Ciao", "farewell": "Addio"}}620 ]621 // Logic622 // null is better because indicates it was processed and not found. undefined is more doesn't exist.623 // perhaps "" might indicate same for strings624 let result = null;625 testOutput[testOutputLine++] = what + " " + language;626 for (const someLanguage of phrases) {627 testOutput[testOutputLine++] = "Next language is " + someLanguage;628 if (someLanguage.lang === language) {629 testOutput[testOutputLine++] = "Oh! I found my language! " + someLanguage;630 testOutput[testOutputLine++] = "The word I am looking for is " + someLanguage.words[what];631 result = someLanguage.words[what];632 break;633 } else {634 testOutput[testOutputLine++] = "Nope, that is not what I want ";635 }636 }637 return result;638 }639 640 testOutput = [];641 testOutputLine = 0;642 643 let utterResult = utter ("greet", "pt");644 645 expect (utterResult).toBe("Olá");646 647 testOutput = [];648 testOutputLine = 0;649 650 utterResult = utter ("farewell", "it");651 652 expect (utterResult).toBe("Addio");653 utter = function (what, language) {654 // Environment655 const phrases = [656 {"lang": "en", "words": {"greet": "Hello", "farewell": "Goodbye"}}, 657 {"lang": "de", "words": {"greet": "Hallo", "farewell": "Auf wierdersehen"}},658 {"lang": "es", "words": {"greet": "Hola", "farewell": "Hasta luego"}},659 {"lang": "pt", "words": {"greet": "Olá", "farewell": "Tchau"}},660 {"lang": "it", "words": {"greet": "Ciao", "farewell": "Addio"}}661 ]662 // Logic663 // null is better because indicates it was processed and not found. undefined is more doesn't exist.664 // perhaps "" might indicate same for strings665 let result = null;666 // testOutput[testOutputLine++] = what + " " + language;667 for (const someLanguage of phrases) {668 // testOutput[testOutputLine++] = "Next language is " + someLanguage;669 if (someLanguage.lang === language) {670 // testOutput[testOutputLine++] = "Oh! I found my language! " + someLanguage;671 // testOutput[testOutputLine++] = "The word I am looking for is " + someLanguage.words[what];672 result = someLanguage.words[what];673 break;674 } else {675 // testOutput[testOutputLine++] = "Nope, that is not what I want ";676 }677 }678 return result;679 }680 expect (utter("greet", "de") + ", Klaus").toBe("Hallo, Klaus");681 expect (utter("greet", "it") + ", Giovanni").toBe("Ciao, Giovanni");682 expect (utter("farewell", "pt") + ", Joao").toBe("Tchau, Joao");683 phrases = [684 {"lang": "en", "words": {"greet": "Hello", "farewell": "Goodbye"},685 "action": function(name) {return name + " buddy"}}, 686 {"lang": "de", "words": {"greet": "Hallo", "farewell": "Auf wierdersehen"}, "action": ""},687 {"lang": "es", "words": {"greet": "Hola", "farewell": "Hasta luego"}, "action": ""},688 {"lang": "pt", "words": {"greet": "Olá", "farewell": "Tchau"}, "action": ""},689 {"lang": "it", "words": {"greet": "Ciao", "farewell": "Addio"}, "action": ""}690 ]691 // Note: Could not get expect to work for phrases[0] or phrases[0].action692 expect(phrases.length).toBe(5);693 // expect(phrases[0]).toEqual({"lang": "en", "words": {"greet": "Hello", "farewell": "Goodbye"},694 // "action": function(name) {return name + " buddy"}});695 expect(phrases[0].words).toEqual({"greet": "Hello", "farewell": "Goodbye"});696 // expect(phrases[0].action).toEqual([Function action]);697 expect(phrases[0].action("John")).toBe("John buddy");698 let translate = function (what, sourceLanguage, targetLanguage) {699 // environment700 let phrases = [701 {"lang": "en", "words": { "greet": "Hello", "farewell": "Goodbye"}},702 {"lang": "de", "words": { "greet": "Hallo", "farewell": "Auf wiedersehen"}},703 {"lang": "es", "words": { "greet": "Hola", "farewell": "Hasta luego"}},704 {"lang": "pt", "words": { "greet": "Olá", "farewell": "Tchau"}},705 {"lang": "it", "words": { "greet": "Ciao", "farewell": "Addio"}}706 ];707 708 // logic709 let result = null;710 // console.log (what, language)711 for (const somelanguage of phrases) {712 // console.log('Next language is', somelanguage)713 if (somelanguage.lang === sourceLanguage) {714 testOutput[testOutputLine++] = 'Oh! I found my language' + somelanguage;715 // console.log("The word i'm looking for is", somelanguage.words[what])716 break;717 } else {718 // console.log('Nope, that is not what I want')719 }720 }721 return result;722 }723 testOutput = [];724 testOutputLine = 0;725 let translateResult = translate('', 'en', '');726 expect(testOutput[0]).toBe("Oh! I found my language[object Object]");727 translate = function (what, sourceLanguage, targetLanguage) {728 // environment729 let phrases = [730 {"lang": "en", "words": { "greet": "Hello", "farewell": "Goodbye"}},731 {"lang": "de", "words": { "greet": "Hallo", "farewell": "Auf wiedersehen"}},732 {"lang": "es", "words": { "greet": "Hola", "farewell": "Hasta luego"}},733 {"lang": "pt", "words": { "greet": "Olá", "farewell": "Tchau"}},734 {"lang": "it", "words": { "greet": "Ciao", "farewell": "Addio"}}735 ];736 737 // logic738 let result = null;739 // console.log (what, language)740 for (const somelanguage of phrases) {741 // console.log('Next language is', somelanguage)742 if (somelanguage.lang === sourceLanguage) {743 testOutput[testOutputLine++] = 'Oh! I found my language' + somelanguage;744 testOutput[testOutputLine++] = 'And my words are';745 for (word in somelanguage.words) {746 testOutput[testOutputLine++] = word;747 }748 // console.log("The word i'm looking for is", somelanguage.words[what])749 break;750 } else {751 // console.log('Nope, that is not what I want')752 }753 }754 return result;755 }756 757 testOutput = [];758 testOutputLine = 0;759 translateResult = translate('', 'en', '');760 expect(testOutput[0]).toBe("Oh! I found my language[object Object]");761 expect(testOutput[1]).toBe("And my words are");762 expect(testOutput[2]).toBe("greet");763 expect(testOutput[3]).toBe("farewell");764 translate = function (what, sourceLanguage, targetLanguage) {765 // environment766 let phrases = [767 {"lang": "en", "words": { "greet": "Hello", "farewell": "Goodbye"}},768 {"lang": "de", "words": { "greet": "Hallo", "farewell": "Auf wiedersehen"}},769 {"lang": "es", "words": { "greet": "Hola", "farewell": "Hasta luego"}},770 {"lang": "pt", "words": { "greet": "Olá", "farewell": "Tchau"}},771 {"lang": "it", "words": { "greet": "Ciao", "farewell": "Addio"}}772 ];773 774 // logic775 let result = null;776 // console.log (what, language)777 for (const somelanguage of phrases) {778 // console.log('Next language is', somelanguage)779 if (somelanguage.lang === sourceLanguage) {780 testOutput[testOutputLine++] = 'Oh! I found my language' + somelanguage;781 testOutput[testOutputLine++] = 'And my words are';782 for (word in somelanguage.words) {783 testOutput[testOutputLine++] = word + " " + somelanguage.words[word];784 }785 // console.log("The word i'm looking for is", somelanguage.words[what])786 break;787 } else {788 // console.log('Nope, that is not what I want')789 }790 }791 return result;792 }793 testOutput = [];794 testOutputLine = 0;795 translateResult = translate('', 'pt', '');796 expect(testOutput[0]).toBe("Oh! I found my language[object Object]");797 expect(testOutput[1]).toBe("And my words are");798 expect(testOutput[2]).toBe("greet Olá");799 expect(testOutput[3]).toBe("farewell Tchau");800 translate = function (what, sourceLanguage, targetLanguage) {801 // environment802 let phrases = [803 {"lang": "en", "words": { "greet": "Hello", "farewell": "Goodbye"}},804 {"lang": "de", "words": { "greet": "Hallo", "farewell": "Auf wiedersehen"}},805 {"lang": "es", "words": { "greet": "Hola", "farewell": "Hasta luego"}},806 {"lang": "pt", "words": { "greet": "Olá", "farewell": "Tchau"}},807 {"lang": "it", "words": { "greet": "Ciao", "farewell": "Addio"}}808 ];809 810 // logic811 let result = null;812 // console.log (what, language)813 for (const somelanguage of phrases) {814 // console.log('Next language is', somelanguage)815 if (somelanguage.lang === sourceLanguage) {816 testOutput[testOutputLine++] = 'Oh! I found my language' + somelanguage;817 for (word in somelanguage.words) {818 if (somelanguage.words[word] === what) {819 testOutput[testOutputLine++] = 'And here is the word';820 testOutput[testOutputLine++] = word + " " + somelanguage.words[word];821 }822 }823 // console.log("The word i'm looking for is", somelanguage.words[what])824 break;825 } else {826 // console.log('Nope, that is not what I want')827 }828 }829 return result;830 }831 testOutput = [];832 testOutputLine = 0;833 translateResult = translate('Olá', 'pt', '');834 expect(testOutput[0]).toBe("Oh! I found my language[object Object]");835 expect(testOutput[1]).toBe("And here is the word");836 expect(testOutput[2]).toBe("greet Olá");837 translate = function (what, sourceLanguage, targetLanguage) {838 // environment839 let phrases = [840 {"lang": "en", "words": { "greet": "Hello", "farewell": "Goodbye"}},841 {"lang": "de", "words": { "greet": "Hallo", "farewell": "Auf wiedersehen"}},842 {"lang": "es", "words": { "greet": "Hola", "farewell": "Hasta luego"}},843 {"lang": "pt", "words": { "greet": "Olá", "farewell": "Tchau"}},844 {"lang": "it", "words": { "greet": "Ciao", "farewell": "Addio"}}845 ];846 847 // logic848 let result = null;849 // console.log (what, language)850 for (const somelanguage of phrases) {851 // console.log('Next language is', somelanguage)852 if (somelanguage.lang === sourceLanguage) {853 testOutput[testOutputLine++] = 'Oh! I found my language' + somelanguage;854 for (const wordKey in somelanguage.words) {855 if (somelanguage.words[wordKey] === what) {856 testOutput[testOutputLine++] = 'And here is the word';857 testOutput[testOutputLine++] = somelanguage.words[wordKey];858 }859 }860 // console.log("The word i'm looking for is", somelanguage.words[what])861 break;862 } else {863 // console.log('Nope, that is not what I want')864 }865 }866 return result;867 }868 testOutput = [];869 testOutputLine = 0;870 translateResult = translate('Hallo', 'de', '');871 expect(testOutput[0]).toBe("Oh! I found my language[object Object]");872 expect(testOutput[1]).toBe("And here is the word");873 expect(testOutput[2]).toBe("Hallo");874 translate = function (what, sourceLanguage, targetLanguage) {875 // environment876 let phrases = [877 {"lang": "en", "words": { "greet": "Hello", "farewell": "Goodbye"}},878 {"lang": "de", "words": { "greet": "Hallo", "farewell": "Auf wiedersehen"}},879 {"lang": "es", "words": { "greet": "Hola", "farewell": "Hasta luego"}},880 {"lang": "pt", "words": { "greet": "Olá", "farewell": "Tchau"}},881 {"lang": "it", "words": { "greet": "Ciao", "farewell": "Addio"}}882 ];883 884 // logic885 let result = null;886 let keyWeNeed = null;887 // console.log (what, language)888 for (const somelanguage of phrases) {889 // console.log('Next language is', somelanguage)890 if (somelanguage.lang === sourceLanguage) {891 testOutput[testOutputLine++] = 'Oh! I found my language' + somelanguage;892 for (const wordKey in somelanguage.words) {893 if (somelanguage.words[wordKey] === what) {894 testOutput[testOutputLine++] = 'And here is the word';895 testOutput[testOutputLine++] = somelanguage.words[wordKey];896 keyWeNeed = wordKey;897 break;898 }899 }900 // console.log("The word i'm looking for is", somelanguage.words[what])901 break;902 } else {903 // console.log('Nope, that is not what I want')904 }905 }906 result = keyWeNeed;907 return result;908 }909 testOutput = [];910 testOutputLine = 0;911 translateResult = translate('Hallo', 'de', '');912 expect (translateResult).toBe("greet");913 expect(testOutput[0]).toBe("Oh! I found my language[object Object]");914 expect(testOutput[1]).toBe("And here is the word");915 expect(testOutput[2]).toBe("Hallo");916 translate = function (what, sourceLanguage, targetLanguage) {917 // environment918 let phrases = [919 {"lang": "en", "words": { "greet": "Hello", "farewell": "Goodbye"}},920 {"lang": "de", "words": { "greet": "Hallo", "farewell": "Auf wiedersehen"}},921 {"lang": "es", "words": { "greet": "Hola", "farewell": "Hasta luego"}},922 {"lang": "pt", "words": { "greet": "Olá", "farewell": "Tchau"}},923 {"lang": "it", "words": { "greet": "Ciao", "farewell": "Addio"}}924 ];925 926 // logic927 let result = null;928 let keyWeNeed = null;929 // console.log (what, language)930 for (const somelanguage of phrases) {931 // console.log('Next language is', somelanguage)932 if (somelanguage.lang === sourceLanguage) {933 testOutput[testOutputLine++] = 'Oh! I found my language' + somelanguage;934 for (const wordKey in somelanguage.words) {935 if (somelanguage.words[wordKey] === what) {936 testOutput[testOutputLine++] = 'And here is the word';937 testOutput[testOutputLine++] = somelanguage.words[wordKey];938 keyWeNeed = wordKey;939 break;940 }941 }942 // console.log("The word i'm looking for is", somelanguage.words[what])943 break;944 } else {945 // console.log('Nope, that is not what I want')946 }947 }948 // now that we have the key, we can translate949 for (const somelanguage of phrases) {950 if (somelanguage.lang === targetLanguage) {951 result = somelanguage.words[keyWeNeed];952 break;953 }954 }955 return result;956 }957 testOutput = [];958 testOutputLine = 0;959 translateResult = translate('Hallo', 'de', 'en');960 expect (translateResult).toBe("Hello");961 expect(testOutput[0]).toBe("Oh! I found my language[object Object]");962 expect(testOutput[1]).toBe("And here is the word");963 expect(testOutput[2]).toBe("Hallo");964 testOutput = [];965 testOutputLine = 0;966 translateResult = translate('Hasta luego', 'es', 'it');967 expect (translateResult).toBe("Addio");968 expect(testOutput[0]).toBe("Oh! I found my language[object Object]");969 expect(testOutput[1]).toBe("And here is the word");970 expect(testOutput[2]).toBe("Hasta luego");971 translate = function (what, sourceLanguage, targetLanguage) {972 // environment973 let phrases = [974 {"lang": "en", "words": { "greet": "Hello", "farewell": "Goodbye"}},975 {"lang": "de", "words": { "greet": "Hallo", "farewell": "Auf wiedersehen"}},976 {"lang": "es", "words": { "greet": "Hola", "farewell": "Hasta luego"}},977 {"lang": "pt", "words": { "greet": "Olá", "farewell": "Tchau"}},978 {"lang": "it", "words": { "greet": "Ciao", "farewell": "Addio"}}979 ];980 981 // logic982 let result = null;983 let keyWeNeed = null;984 // console.log (what, language)985 for (const somelanguage of phrases) {986 // console.log('Next language is', somelanguage)987 if (somelanguage.lang === sourceLanguage) {988 // testOutput[testOutputLine++] = 'Oh! I found my language' + somelanguage;989 for (const wordKey in somelanguage.words) {990 if (somelanguage.words[wordKey] === what) {991 // testOutput[testOutputLine++] = 'And here is the word';992 // testOutput[testOutputLine++] = somelanguage.words[wordKey];993 keyWeNeed = wordKey;994 break;995 }996 }997 // console.log("The word i'm looking for is", somelanguage.words[what])998 break;999 } else {1000 // console.log('Nope, that is not what I want')1001 }1002 }1003 // now that we have the key, we can translate1004 for (const somelanguage of phrases) {1005 if (somelanguage.lang === targetLanguage) {1006 result = somelanguage.words[keyWeNeed];1007 break;1008 }1009 }1010 return result;1011 }1012 translateResult = translate('Hello', 'en', 'pt');1013 expect (translateResult).toBe("Olá");1014 ...

Full Screen

Full Screen

stalenessStatusUtil.test.js

Source:stalenessStatusUtil.test.js Github

copy

Full Screen

1import { stalenessStatus } from './stalenessStatusUtil';2describe('stalenessStatus', () => {3 it(`should return correct color 'bg-red-600'`, () => {4 const testInput = stalenessStatus(3.095890410958904, 'color');5 const testOutput = 'bg-red-600';6 expect(testInput).toEqual(testOutput);7 });8 it(`should return correct color 'bg-lime-500'`, () => {9 const testInput = stalenessStatus(0.6712328767123288, 'color');10 const testOutput = 'bg-lime-500';11 expect(testInput).toEqual(testOutput);12 });13 it(`should return correct color 'bg-orange-500'`, () => {14 const testInput = stalenessStatus(2.4821917808219176, 'color');15 const testOutput = 'bg-orange-500';16 expect(testInput).toEqual(testOutput);17 });18 it(`should return correct color 'bg-orange-500'`, () => {19 const testInput = stalenessStatus(2.3095890410958906, 'color');20 const testOutput = 'bg-orange-500';21 expect(testInput).toEqual(testOutput);22 });23 it(`should return correct color 'bg-lime-400'`, () => {24 const testInput = stalenessStatus(0.04657534246575343, 'color');25 const testOutput = 'bg-lime-400';26 expect(testInput).toEqual(testOutput);27 });28 it(`should return correct color 'bg-red-700'`, () => {29 const testInput = stalenessStatus(3.252054794520548, 'color');30 const testOutput = 'bg-red-700';31 expect(testInput).toEqual(testOutput);32 });33 it(`should return correct color 'bg-lime-400'`, () => {34 const testInput = stalenessStatus(0.3561643835616438, 'color');35 const testOutput = 'bg-lime-400';36 expect(testInput).toEqual(testOutput);37 });38 it(`should return correct color 'bg-lime-400'`, () => {39 const testInput = stalenessStatus(0.0547945205479452, 'color');40 const testOutput = 'bg-lime-400';41 expect(testInput).toEqual(testOutput);42 });43 it(`should return correct color 'bg-red-600'`, () => {44 const testInput = stalenessStatus(3.0794520547945203, 'color');45 const testOutput = 'bg-red-600';46 expect(testInput).toEqual(testOutput);47 });48 it(`should return correct color 'bg-lime-400'`, () => {49 const testInput = stalenessStatus(0.03561643835616438, 'color');50 const testOutput = 'bg-lime-400';51 expect(testInput).toEqual(testOutput);52 });53 it(`should return correct color 'bg-amber-400'`, () => {54 const testInput = stalenessStatus(1.3506849315068492, 'color');55 const testOutput = 'bg-amber-400';56 expect(testInput).toEqual(testOutput);57 });58 it(`should return correct color 'bg-red-600'`, () => {59 const testInput = stalenessStatus(3.0602739726027397, 'color');60 const testOutput = 'bg-red-600';61 expect(testInput).toEqual(testOutput);62 });63 it(`should return correct color 'bg-red-800'`, () => {64 const testInput = stalenessStatus(3.7534246575342465, 'color');65 const testOutput = 'bg-red-800';66 expect(testInput).toEqual(testOutput);67 });68 it(`should return correct color 'bg-red-700'`, () => {69 const testInput = stalenessStatus(3.5287671232876714, 'color');70 const testOutput = 'bg-red-700';71 expect(testInput).toEqual(testOutput);72 });73 it(`should return correct color 'bg-lime-400'`, () => {74 const testInput = stalenessStatus(0.03561643835616438, 'color');75 const testOutput = 'bg-lime-400';76 expect(testInput).toEqual(testOutput);77 });78 it(`should return correct color 'bg-lime-400'`, () => {79 const testInput = stalenessStatus(0.10684931506849316, 'color');80 const testOutput = 'bg-lime-400';81 expect(testInput).toEqual(testOutput);82 });83 it(`should return correct color 'bg-amber-400'`, () => {84 const testInput = stalenessStatus(1.1972602739726028, 'color');85 const testOutput = 'bg-amber-400';86 expect(testInput).toEqual(testOutput);87 });88 it(`should return correct color 'bg-gray-900'`, () => {89 const testInput = stalenessStatus(5.227397260273973, 'color');90 const testOutput = 'bg-gray-900';91 expect(testInput).toEqual(testOutput);92 });93 it(`should return correct color 'bg-amber-500'`, () => {94 const testInput = stalenessStatus(1.7835616438356163, 'color');95 const testOutput = 'bg-amber-500';96 expect(testInput).toEqual(testOutput);97 });98 it(`should return correct color 'bg-lime-400'`, () => {99 const testInput = stalenessStatus(0.04657534246575343, 'color');100 const testOutput = 'bg-lime-400';101 expect(testInput).toEqual(testOutput);102 });103 it(`should return correct color 'bg-gray-900'`, () => {104 const testInput = stalenessStatus(4.917808219178082, 'color');105 const testOutput = 'bg-gray-900';106 expect(testInput).toEqual(testOutput);107 });108 it(`should return correct color 'bg-orange-500'`, () => {109 const testInput = stalenessStatus(2.4575342465753423, 'color');110 const testOutput = 'bg-orange-500';111 expect(testInput).toEqual(testOutput);112 });113 it(`should return correct color 'bg-amber-400'`, () => {114 const testInput = stalenessStatus(1.2, 'color');115 const testOutput = 'bg-amber-400';116 expect(testInput).toEqual(testOutput);117 });...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org');3 if (err) return console.error(err);4 console.log('Test Results for: ' + data.data.summary);5 wpt.testOutput(data.data.testId, function(err, data) {6 if (err) return console.error(err);7 console.log(data);8 });9});10var wpt = require('webpagetest');11var wpt = new WebPageTest('www.webpagetest.org');12 if (err) return console.error(err);13 console.log('Test Results for: ' + data.data.summary);14 wpt.testOutput(data.data.testId, function(err, data) {15 if (err) return console.error(err);16 console.log(data);17 });18});19var wpt = require('webpagetest');20var wpt = new WebPageTest('www.webpagetest.org');21 if (err) return console.error(err);22 console.log('Test Results for: ' + data.data.summary);23 wpt.testOutput(data.data.testId, function(err, data) {24 if (err) return console.error(err);25 console.log(data);26 });27});28var wpt = require('webpagetest');29var wpt = new WebPageTest('www.webpagetest.org');30 if (err) return console.error(err);31 console.log('Test Results for: ' + data.data.summary);32 wpt.testOutput(data.data.testId, function(err, data) {33 if (err) return console.error(err);34 console.log(data);35 });36});37var wpt = require('webpagetest');

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('wpt');2wpt.testOutput(function (data) {3 console.log(data);4});5exports.testOutput = function (callback) {6 var data = "Hello World";7 callback(data);8};

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('./wpt');2var wpt = new wpt('API_KEY');3wpt.testOutput(12345, function(err, data) {4 if (!err) {5 console.log(data);6 }7});8var wpt = require('./wpt');9var wpt = new wpt('API_KEY');10module.exports = {11 testOutput: function(testId, cb) {12 wpt.testOutput(testId, function(err, data) {13 if (err) {14 cb(err);15 } else {16 cb(null, data);17 }18 });19 }20};

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('./wpt.js');2var test = new wpt();3test.testOutput();4var testOutput = function(){5 console.log('test output');6}7module.exports = testOutput;8var testOutput = function(){9 console.log('test output');10}11module.exports = testOutput;12var wpt = require('./wpt.js');13var test = new wpt();14test();15var testOutput = function(){16 console.log('test output');17}18module.exports = testOutput;19var wpt = require('./wpt.js');20var test = new wpt();21test();

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('wpt');2var wptTest = new wpt();3 if (err) {4 console.log(err);5 }6 else {7 console.log(data);8 }9});10var wpt = require('wpt');11var wptTest = new wpt();12 if (err) {13 console.log(err);14 }15 else {16 console.log(data);17 }18});19var wpt = require('wpt');20var wptTest = new wpt();21 if (err) {22 console.log(err);23 }24 else {25 console.log(data);26 }27});

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org', 'A.0b7c0b2a8f9c1c0d0a0e0e0f0d0f0a0a');3 if (err) return console.error(err);4 wpt.getTestResults(data.data.testId, function(err, data) {5 if (err) return console.error(err);6 console.log(data);7 });8});9var wpt = require('webpagetest');10var wpt = new WebPageTest('www.webpagetest.org', 'A.0b7c0b2a8f9c1c0d0a0e0e0f0d0f0a0a');11 if (err) return console.error(err);12 wpt.getTestResults(data.data.testId, function(err, data) {13 if (err) return console.error(err);14 console.log(data);15 });16});17var wpt = require('webpagetest');18var wpt = new WebPageTest('www.webpagetest.org', 'A.0b7c0b2a8f9c1c0d0a0e0e0f0d0f0a0a');19 if (err) return console.error(err);20 wpt.getTestResults(data.data.testId, function(err, data) {21 if (err) return console.error(err);22 console.log(data);23 });24});25var wpt = require('webpagetest');26var wpt = new WebPageTest('www.webpagetest.org', 'A.0b7c0b2a8f9c1c0d0a0e0e0f0d0f0a0a');

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