Best JavaScript code snippet using testcafe
othello.js
Source:othello.js  
...288      }289    }290    return positions;291  }292  function shiftUp(u, l) {293    return (u << N) |294           (l >>> (N * (N2 - 1)));295  }296  function shiftDown(u, l) {297    return (l >>> N) |298           ((u & 0x000000ff) << (N * (N2 - 1)));299  }300  function listAttackableBitsAtUp(ou, ol, _du, _dl, eu, el) {301    var du = _du & 0x00ffffff;302    var dl = _dl & 0xffffff00;303    var tu = du & shiftUp(ou, ol);304    var tl = dl & shiftUp(ol, 0);305    tu |= du & shiftUp(tu, tl);306    tl |= dl & shiftUp(tl, 0);307    tu |= du & shiftUp(tu, tl);308    tl |= dl & shiftUp(tl, 0);309    tu |= du & shiftUp(tu, tl);310    tl |= dl & shiftUp(tl, 0);311    tu |= du & shiftUp(tu, tl);312    tl |= dl & shiftUp(tl, 0);313    tu |= du & shiftUp(tu, tl);314    tl |= dl & shiftUp(tl, 0);315    return {316      upper: eu & shiftUp(tu, tl),317      lower: el & shiftUp(tl, 0)318    };319  }320  function listAttackableBitsAtRightUp(ou, ol, _du, _dl, eu, el) {321    var du = _du & 0x007e7e7e;322    var dl = _dl & 0x7e7e7e00;323    var tu = du & (shiftUp(ou, ol) >>> 1);324    var tl = dl & (shiftUp(ol, 0) >>> 1);325    tu |= du & (shiftUp(tu, tl) >>> 1);326    tl |= dl & (shiftUp(tl, 0) >>> 1);327    tu |= du & (shiftUp(tu, tl) >>> 1);328    tl |= dl & (shiftUp(tl, 0) >>> 1);329    tu |= du & (shiftUp(tu, tl) >>> 1);330    tl |= dl & (shiftUp(tl, 0) >>> 1);331    tu |= du & (shiftUp(tu, tl) >>> 1);332    tl |= dl & (shiftUp(tl, 0) >>> 1);333    tu |= du & (shiftUp(tu, tl) >>> 1);334    tl |= dl & (shiftUp(tl, 0) >>> 1);335    return {336      upper: eu & (shiftUp(tu, tl) >>> 1),337      lower: el & (shiftUp(tl, 0) >>> 1)338    };339  }340  function listAttackableBitsAtRight(o, _d, e) {341    var d = _d & 0x7e7e7e7e;342    var t = d & (o >>> 1);343    t |= d & (t >>> 1);344    t |= d & (t >>> 1);345    t |= d & (t >>> 1);346    t |= d & (t >>> 1);347    t |= d & (t >>> 1);348    return e & (t >>> 1);349  }350  function listAttackableBitsAtRightDown(ou, ol, _du, _dl, eu, el) {351    var du = _du & 0x007e7e7e;352    var dl = _dl & 0x7e7e7e00;353    var tl = dl & (shiftDown(ou, ol) >>> 1);354    var tu = du & (shiftDown(0, ou) >>> 1);355    tl |= dl & (shiftDown(tu, tl) >>> 1);356    tu |= du & (shiftDown(0, tu) >>> 1);357    tl |= dl & (shiftDown(tu, tl) >>> 1);358    tu |= du & (shiftDown(0, tu) >>> 1);359    tl |= dl & (shiftDown(tu, tl) >>> 1);360    tu |= du & (shiftDown(0, tu) >>> 1);361    tl |= dl & (shiftDown(tu, tl) >>> 1);362    tu |= du & (shiftDown(0, tu) >>> 1);363    tl |= dl & (shiftDown(tu, tl) >>> 1);364    tu |= du & (shiftDown(0, tu) >>> 1);365    return {366      upper: eu & (shiftDown(0, tu) >>> 1),367      lower: el & (shiftDown(tu, tl) >>> 1)368    };369  }370  function listAttackableBitsAtDown(ou, ol, _du, _dl, eu, el) {371    var du = _du & 0x00ffffff;372    var dl = _dl & 0xffffff00;373    var tl = dl & shiftDown(ou, ol);374    var tu = du & shiftDown(0, ou);375    tl |= dl & shiftDown(tu, tl);376    tu |= du & shiftDown(0, tu);377    tl |= dl & shiftDown(tu, tl);378    tu |= du & shiftDown(0, tu);379    tl |= dl & shiftDown(tu, tl);380    tu |= du & shiftDown(0, tu);381    tl |= dl & shiftDown(tu, tl);382    tu |= du & shiftDown(0, tu);383    tl |= dl & shiftDown(tu, tl);384    tu |= du & shiftDown(0, tu);385    return {386      upper: eu & shiftDown(0, tu),387      lower: el & shiftDown(tu, tl)388    };389  }390  function listAttackableBitsAtLeftDown(ou, ol, _du, _dl, eu, el) {391    var du = _du & 0x007e7e7e;392    var dl = _dl & 0x7e7e7e00;393    var tl = dl & (shiftDown(ou, ol) << 1);394    var tu = du & (shiftDown(0, ou) << 1);395    tl |= dl & (shiftDown(tu, tl) << 1);396    tu |= du & (shiftDown(0, tu) << 1);397    tl |= dl & (shiftDown(tu, tl) << 1);398    tu |= du & (shiftDown(0, tu) << 1);399    tl |= dl & (shiftDown(tu, tl) << 1);400    tu |= du & (shiftDown(0, tu) << 1);401    tl |= dl & (shiftDown(tu, tl) << 1);402    tu |= du & (shiftDown(0, tu) << 1);403    tl |= dl & (shiftDown(tu, tl) << 1);404    tu |= du & (shiftDown(0, tu) << 1);405    return {406      upper: eu & (shiftDown(0, tu) << 1),407      lower: el & (shiftDown(tu, tl) << 1)408    };409  }410  function listAttackableBitsAtLeft(o, _d, e) {411    var d = _d & 0x7e7e7e7e;412    var t = d & (o << 1);413    t |= d & (t << 1);414    t |= d & (t << 1);415    t |= d & (t << 1);416    t |= d & (t << 1);417    t |= d & (t << 1);418    return e & (t << 1);419  }420  function listAttackableBitsAtLeftUp(ou, ol, _du, _dl, eu, el) {421    var du = _du & 0x007e7e7e;422    var dl = _dl & 0x7e7e7e00;423    var tu = du & (shiftUp(ou, ol) << 1);424    var tl = dl & (shiftUp(ol, 0) << 1);425    tu |= du & (shiftUp(tu, tl) << 1);426    tl |= dl & (shiftUp(tl, 0) << 1);427    tu |= du & (shiftUp(tu, tl) << 1);428    tl |= dl & (shiftUp(tl, 0) << 1);429    tu |= du & (shiftUp(tu, tl) << 1);430    tl |= dl & (shiftUp(tl, 0) << 1);431    tu |= du & (shiftUp(tu, tl) << 1);432    tl |= dl & (shiftUp(tl, 0) << 1);433    tu |= du & (shiftUp(tu, tl) << 1);434    tl |= dl & (shiftUp(tl, 0) << 1);435    return {436      upper: eu & (shiftUp(tu, tl) << 1),437      lower: el & (shiftUp(tl, 0) << 1)438    };439  }440  // AI {{{1441  var aiMakers = {442    mcts: makeMonteCarloTreeSearchBasedAI,443    pmc: makePrimitiveMonteCarloBasedAI444  };445  function makeAI(playerType) {446    if (playerType in externalAITable) {447      return externalAITable[playerType];448    } else {449      var tokens = playerType.split('-');450      var aiType = tokens[0];451      var level = parseInt(tokens[1]);...common.js
Source:common.js  
1const rowKeys1 = [2    {3        class: ['Backquote'],4        eng: {5            shiftUp: '`',6            shiftDown: '~',7        },8        ru: {9            shiftUp: 'Ñ',10            shiftDown: 'Ð',11        },12    },13    {14        class: ['Digit1'],15        eng: {16            shiftUp: '1',17            shiftDown: '!',18        },19        ru: {20            shiftUp: '1',21            shiftDown: '!',22        },23    },24    {25        class: ['Digit2'],26        eng: {27            shiftUp: '2',28            shiftDown: '@',29        },30        ru: {31            shiftUp: '2',32            shiftDown: '"',33        },34    },35    {36        class: ['Digit3'],37        eng: {38            shiftUp: '3',39            shiftDown: '#',40        },41        ru: {42            shiftUp: '3',43            shiftDown: 'â',44        },45    },46    {47        class: ['Digit4'],48        eng: {49            shiftUp: '4',50            shiftDown: '$',51        },52        ru: {53            shiftUp: '4',54            shiftDown: ';',55        },56    },57    {58        class: ['Digit5'],59        eng: {60            shiftUp: '5',61            shiftDown: '%',62        },63        ru: {64            shiftUp: '5',65            shiftDown: '%',66        },67    },68    {69        class: ['Digit6'],70        eng: {71            shiftUp: '6',72            shiftDown: '^',73        },74        ru: {75            shiftUp: '6',76            shiftDown: ':',77        },78    },79    {80        class: ['Digit7'],81        eng: {82            shiftUp: '7',83            shiftDown: '&',84        },85        ru: {86            shiftUp: '7',87            shiftDown: '?',88        },89    },90    {91        class: ['Digit8'],92        eng: {93            shiftUp: '8',94            shiftDown: '*',95        },96        ru: {97            shiftUp: '8',98            shiftDown: '*',99        },100    },101    {102        class: ['Digit9'],103        eng: {104            shiftUp: '9',105            shiftDown: '(',106        },107        ru: {108            shiftUp: '9',109            shiftDown: '(',110        },111    },112    {113        class: ['Digit0'],114        eng: {115            shiftUp: '0',116            shiftDown: ')',117        },118        ru: {119            shiftUp: '0',120            shiftDown: ')',121        },122    },123    {124        class: ['Minus'],125        eng: {126            shiftUp: '-',127            shiftDown: '_',128        },129        ru: {130            shiftUp: '-',131            shiftDown: '_',132        },133    },134    {135        class: ['Equal'],136        eng: {137            shiftUp: '=',138            shiftDown: '+',139        },140        ru: {141            shiftUp: '=',142            shiftDown: '+',143        },144    },145    {146        class: ['Backspace', 'accent'],147        eng: {148            shiftUp: 'Backspace',149            shiftDown: 'Backspace',150        },151        ru: {152            shiftUp: 'Backspace',153            shiftDown: 'Backspace',154        },155    },156];157const rowKeys2 = [158    {159        class: ['Tab', 'accent'],160        eng: {161            shiftUp: 'Tab',162            shiftDown: 'Tab',163        },164        ru: {165            shiftUp: 'Tab',166            shiftDown: 'Tab',167        },168    },169    {170        class: ['KeyQ'],171        eng: {172            shiftUp: 'q',173            shiftDown: 'Q',174        },175        ru: {176            shiftUp: 'й',177            shiftDown: 'Ð',178        },179    },180    {181        class: ['KeyW'],182        eng: {183            shiftUp: 'w',184            shiftDown: 'W',185        },186        ru: {187            shiftUp: 'Ñ',188            shiftDown: 'Ц',189        },190    },191    {192        class: ['KeyE'],193        eng: {194            shiftUp: 'e',195            shiftDown: 'E',196        },197        ru: {198            shiftUp: 'Ñ',199            shiftDown: 'У',200        },201    },202    {203        class: ['KeyR'],204        eng: {205            shiftUp: 'r',206            shiftDown: 'R',207        },208        ru: {209            shiftUp: 'к',210            shiftDown: 'Ð',211        },212    },213    {214        class: ['KeyT'],215        eng: {216            shiftUp: 't',217            shiftDown: 'T',218        },219        ru: {220            shiftUp: 'е',221            shiftDown: 'Ð',222        },223    },224    {225        class: ['KeyY'],226        eng: {227            shiftUp: 'y',228            shiftDown: 'Y',229        },230        ru: {231            shiftUp: 'н',232            shiftDown: 'Ð',233        },234    },235    {236        class: ['KeyU'],237        eng: {238            shiftUp: 'u',239            shiftDown: 'U',240        },241        ru: {242            shiftUp: 'г',243            shiftDown: 'Ð',244        },245    },246    {247        class: ['KeyI'],248        eng: {249            shiftUp: 'i',250            shiftDown: 'I',251        },252        ru: {253            shiftUp: 'Ñ',254            shiftDown: 'Ш',255        },256    },257    {258        class: ['KeyO'],259        eng: {260            shiftUp: 'o',261            shiftDown: 'O',262        },263        ru: {264            shiftUp: 'Ñ',265            shiftDown: 'Щ',266        },267    },268    {269        class: ['KeyP'],270        eng: {271            shiftUp: 'p',272            shiftDown: 'P',273        },274        ru: {275            shiftUp: 'з',276            shiftDown: 'Ð',277        },278    },279    {280        class: ['BracketLeft'],281        eng: {282            shiftUp: '[',283            shiftDown: '{',284        },285        ru: {286            shiftUp: 'Ñ
',287            shiftDown: 'Ð¥',288        },289    },290    {291        class: ['BracketRight'],292        eng: {293            shiftUp: ']',294            shiftDown: '}',295        },296        ru: {297            shiftUp: 'Ñ',298            shiftDown: 'Ъ',299        },300    },301    {302        class: ['Delete', 'accent'],303        eng: {304            shiftUp: 'Delete',305            shiftDown: 'Delete',306        },307        ru: {308            shiftUp: 'Delete',309            shiftDown: 'Delete',310        },311    },312];313const rowKeys3 = [314    {315        class: ['CapsLock', 'accent'],316        eng: {317            shiftUp: 'CapsLock',318            shiftDown: 'CapsLock',319        },320        ru: {321            shiftUp: 'CapsLock',322            shiftDown: 'CapsLock',323        },324    },325    {326        class: ['KeyA'],327        eng: {328            shiftUp: 'a',329            shiftDown: 'A',330        },331        ru: {332            shiftUp: 'Ñ',333            shiftDown: 'Ф',334        },335    },336    {337        class: ['KeyS'],338        eng: {339            shiftUp: 's',340            shiftDown: 'S',341        },342        ru: {343            shiftUp: 'Ñ',344            shiftDown: 'Ы',345        },346    },347    {348        class: ['KeyD'],349        eng: {350            shiftUp: 'd',351            shiftDown: 'D',352        },353        ru: {354            shiftUp: 'в',355            shiftDown: 'Ð',356        },357    },358    {359        class: ['KeyF'],360        eng: {361            shiftUp: 'f',362            shiftDown: 'F',363        },364        ru: {365            shiftUp: 'а',366            shiftDown: 'Ð',367        },368    },369    {370        class: ['KeyG'],371        eng: {372            shiftUp: 'g',373            shiftDown: 'G',374        },375        ru: {376            shiftUp: 'п',377            shiftDown: 'Ð',378        },379    },380    {381        class: ['KeyH'],382        eng: {383            shiftUp: 'h',384            shiftDown: 'H',385        },386        ru: {387            shiftUp: 'Ñ',388            shiftDown: 'Р',389        },390    },391    {392        class: ['KeyJ'],393        eng: {394            shiftUp: 'j',395            shiftDown: 'J',396        },397        ru: {398            shiftUp: 'о',399            shiftDown: 'Ð',400        },401    },402    {403        class: ['KeyK'],404        eng: {405            shiftUp: 'k',406            shiftDown: 'K',407        },408        ru: {409            shiftUp: 'л',410            shiftDown: 'Ð',411        },412    },413    {414        class: ['KeyL'],415        eng: {416            shiftUp: 'l',417            shiftDown: 'L',418        },419        ru: {420            shiftUp: 'д',421            shiftDown: 'Ð',422        },423    },424    {425        class: ['Semicolon'],426        eng: {427            shiftUp: ';',428            shiftDown: ':',429        },430        ru: {431            shiftUp: 'ж',432            shiftDown: 'Ð',433        },434    },435    {436        class: ['Quote'],437        eng: {438            shiftUp: "'",439            shiftDown: '"',440        },441        ru: {442            shiftUp: 'Ñ',443            shiftDown: 'Ð',444        },445    },446    {447        class: ['Enter', 'accent'],448        eng: {449            shiftUp: 'Enter',450            shiftDown: 'Enter',451        },452        ru: {453            shiftUp: 'Enter',454            shiftDown: 'Enter',455        },456    },457];458const rowKeys4 = [459    {460        class: ['ShiftLeft', 'accent'],461        eng: {462            shiftUp: 'Shift',463            shiftDown: 'Shift',464        },465        ru: {466            shiftUp: 'Shift',467            shiftDown: 'Shift',468        },469    },470    {471        class: ['KeyZ'],472        eng: {473            shiftUp: 'z',474            shiftDown: 'Z',475        },476        ru: {477            shiftUp: 'Ñ',478            shiftDown: 'Я',479        },480    },481    {482        class: ['KeyX'],483        eng: {484            shiftUp: 'x',485            shiftDown: 'X',486        },487        ru: {488            shiftUp: 'Ñ',489            shiftDown: 'Ч',490        },491    },492    {493        class: ['KeyC'],494        eng: {495            shiftUp: 'c',496            shiftDown: 'C',497        },498        ru: {499            shiftUp: 'Ñ',500            shiftDown: 'С',501        },502    },503    {504        class: ['KeyV'],505        eng: {506            shiftUp: 'v',507            shiftDown: 'V',508        },509        ru: {510            shiftUp: 'м',511            shiftDown: 'Ð',512        },513    },514    {515        class: ['KeyB'],516        eng: {517            shiftUp: 'b',518            shiftDown: 'B',519        },520        ru: {521            shiftUp: 'и',522            shiftDown: 'Ð',523        },524    },525    {526        class: ['KeyN'],527        eng: {528            shiftUp: 'n',529            shiftDown: 'N',530        },531        ru: {532            shiftUp: 'Ñ',533            shiftDown: 'Т',534        },535    },536    {537        class: ['KeyM'],538        eng: {539            shiftUp: 'm',540            shiftDown: 'M',541        },542        ru: {543            shiftUp: 'Ñ',544            shiftDown: 'Ь',545        },546    },547    {548        class: ['Comma'],549        eng: {550            shiftUp: ',',551            shiftDown: '<',552        },553        ru: {554            shiftUp: 'б',555            shiftDown: 'Ð',556        },557    },558    {559        class: ['Period'],560        eng: {561            shiftUp: '.',562            shiftDown: '>',563        },564        ru: {565            shiftUp: 'Ñ',566            shiftDown: 'Ю',567        },568    },569    {570        class: ['Slash'],571        eng: {572            shiftUp: '/',573            shiftDown: '?',574        },575        ru: {576            shiftUp: '.',577            shiftDown: ',',578        },579    },580    {581        class: ['ArrowUp', 'accent'],582        eng: {583            shiftUp: 'â²',584            shiftDown: 'â²',585        },586        ru: {587            shiftUp: 'â²',588            shiftDown: 'â²',589        },590    },591    {592        class: ['ShiftRight', 'accent'],593        eng: {594            shiftUp: 'Shift',595            shiftDown: 'Shift',596        },597        ru: {598            shiftUp: 'Shift',599            shiftDown: 'Shift',600        },601    },602];603const rowKeys5 = [604    {605        class: ['ControlLeft', 'accent'],606        eng: {607            shiftUp: 'Ctrl',608            shiftDown: 'Ctrl',609        },610        ru: {611            shiftUp: 'Ctrl',612            shiftDown: 'Ctrl',613        },614    },615    {616        class: ['MetaLeft', 'accent'],617        eng: {618            shiftUp: 'Win',619            shiftDown: 'Win',620        },621        ru: {622            shiftUp: 'Win',623            shiftDown: 'Win',624        },625    },626    {627        class: ['AltLeft', 'accent'],628        eng: {629            shiftUp: 'Alt',630            shiftDown: 'Alt',631        },632        ru: {633            shiftUp: 'Alt',634            shiftDown: 'Alt',635        },636    },637    {638        class: ['Space', 'accent'],639        eng: {640            shiftUp: ' ',641            shiftDown: ' ',642        },643        ru: {644            shiftUp: ' ',645            shiftDown: ' ',646        },647    },648    {649        class: ['AltRight', 'accent'],650        eng: {651            shiftUp: 'Alt',652            shiftDown: 'Alt',653        },654        ru: {655            shiftUp: 'Alt',656            shiftDown: 'Alt',657        },658    },659    {660        class: ['ArrowLeft', 'accent'],661        eng: {662            shiftUp: 'â',663            shiftDown: 'â',664        },665        ru: {666            shiftUp: 'â',667            shiftDown: 'â',668        },669    },670    {671        class: ['ArrowDown', 'accent'],672        eng: {673            shiftUp: 'â¼',674            shiftDown: 'â¼',675        },676        ru: {677            shiftUp: 'â¼',678            shiftDown: 'â¼',679        },680    },681    {682        class: ['ArrowRight', 'accent'],683        eng: {684            shiftUp: 'âº',685            shiftDown: 'âº',686        },687        ru: {688            shiftUp: 'âº',689            shiftDown: 'âº',690        },691    },692    {693        class: ['ControlRight', 'accent'],694        eng: {695            shiftUp: 'Ctrl',696            shiftDown: 'Ctrl',697        },698        ru: {699            shiftUp: 'Ctrl',700            shiftDown: 'Ctrl',701        },702    },...player.js
Source:player.js  
1var voteDate;2var mousePosition = {3	x: null,4	y: null5};6var clickPosition = {7	x: null,8	y: null9}10var mouseFireButtonDown = false;11var shiftDown = false;12var backspaceDown = false;13var lastAction = null;14var givePlayerPet = function givePlayerPet(){15	var billPick = 5;16	ThePlayer.pet = Bills[billPick];17	ThePlayer.petLock = ThePlayer.pet;18	ThePlayer.pet.pets.push(ThePlayer);19	var mySupport = ThePlayer.pet.peopleSupport[ThePlayer.id];20	if (mySupport) mySupport = "Pass";21	else mySupport = "Kill";22	23	voteDate = month+(billPick);24	if (voteDate > 11) voteDate -= 12;25	for (var i in TheReps){26		ThePlayer.pet.announcedRepSupport[i] = undefined;27	}28}29var Fax = function Fax(){30	this.p1 = "";31	this.p2 = "";32	this.goal = false;33	this.timer = 5;34}35Fax.prototype = new GameObj();36Fax.prototype.constructor = Fax;37var untangle = function untangle(array, bill){38	var text = "";39	for(var i in array){40		if (array[i] == "%name%") text += bill.name;41		else if (array[i] == "%prefix%") text += bill.prefix;42		else if (array[i] == "%month%") text += monthFullNames[voteDate];43		else text += array[i];44	}45	return text;46};47var createFax = function createFax(oldPet, newPet, result, success){48	var newFax = new Fax();49	newFax.goal = newPet.peopleSupport[ThePlayer.id];50	51	var faxText = faxSalutation+"\n\n\n";52	if (oldPet) {53		faxText += "\t";54		if (success) {55			faxText += faxP1Win[randomNumber(0,4)];56			if (result) faxText += untangle(faxP1WinPass[randomNumber(0,4)],oldPet);57			else faxText += untangle(faxP1WinKill[randomNumber(0,4)],oldPet);58			faxText += faxP1WinFlourish[randomNumber(0,4)];59			faxText += "\n\n\n\t";60			faxText += faxP2WinSegue[randomNumber(0,4)];61		}62		else {63			faxText += faxP1Lose[randomNumber(0,4)];64			if (result) faxText += untangle(faxP1LosePass[randomNumber(0,4)],oldPet);65			else faxText += untangle(faxP1LoseKill[randomNumber(0,4)],oldPet);66			faxText += faxP1LoseFlourish[randomNumber(0,4)];67			faxText += "\n\n\n\t";68			faxText += faxP2LoseSegue[randomNumber(0,4)];69		}70	}71	else faxText += "\t\t\t";72	73	if (newFax.goal) {74		faxText += untangle(faxP2PassIntro[randomNumber(0,4)],newPet);75		faxText += faxP2PassFlourish[randomNumber(0,4)];76	}77	else {78			faxText += untangle(faxP2KillIntro[randomNumber(0,4)],newPet);79			faxText += faxP2KillFlourish[randomNumber(0,4)];80	}81	faxText += "\n\n\n"82	faxText += untangle(faxP2Instruction,newPet);83	84	newFax.text = faxText;85	newFax.visible = true;86	return newFax;87}88var shiftUp = [];89shiftUp[100] = ")";90shiftUp[101] = "!";91shiftUp[102] = "@";92shiftUp[103] = "#";93shiftUp[104] = "$";94shiftUp[105] = "%";95shiftUp[106] = "^";96shiftUp[107] = "&";97shiftUp[108] = "*";98shiftUp[109] = "(";99shiftUp[500] = "~";100shiftUp[501] = "_";101shiftUp[502] = "+";102shiftUp[503] = "{";103shiftUp[504] = "}";104shiftUp[505] = ":";105shiftUp[506] = "\"";106shiftUp[507] = "<";107shiftUp[508] = ">";108var onKeyDown = function onKeyDownFn(keycode)109{110	if ( (keycode == 300) || (keycode == 301) ){111		shiftDown = true;112	}113	if (gameScene == "game") {114		if (keycode === keyCodes.SPACE)115			togglePause();116	}117	else if (gameScene == "menu") {118		if ( (mousePosition.y > 490) && (showAdvanced) ) {119			if (keycode == keyCodes.BACKSPACE){120				Sound.play("bong");121				if (randomSeed.length > 1)122					randomSeed = randomSeed.substring(0, randomSeed.length - 1);123				else124					randomSeed = undefined;125			} 126			else if ( (keycode <= 109) || ( (keycode <= 500) && (keycode >= 508) ) ){127				Sound.play("bong");128				var key = inputDevice.convertToUnicode([keycode]);129				key = key[keycode];130				if (shiftDown) {131					if (keycode > 26) {132						key = shiftUp[keycode];133					}134				}135				if (randomSeed == undefined) randomSeed = "";136				randomSeed += key;137				138			}139		}140	}141};142var onKeyUp = function onKeyUpFn(keycode){143	if ( (keycode == 300) || (keycode == 301) ){144		shiftDown = false;145	}146}147var onMouseOver = function onMouseOver(x, y){148	mousePosition.x = x;149	mousePosition.y = y;150	if(navigator.userAgent.toLowerCase().indexOf('firefox') > -1)151	{152		mousePosition.x -= document.getElementById('turbulenz_game_engine_canvas').offsetLeft;153		mousePosition.y -= document.getElementById('turbulenz_game_engine_canvas').offsetTop;154	}155};156var onMouseDown = function onMouseDownFn(mouseCode, x, y)157{158    clickPosition.x = x;159    clickPosition.y = y;160	if(navigator.userAgent.toLowerCase().indexOf('firefox') > -1)161	{162		clickPosition.x -= document.getElementById('turbulenz_game_engine_canvas').offsetLeft;163		clickPosition.y -= document.getElementById('turbulenz_game_engine_canvas').offsetTop;164	}165	166    if (mouseCode === mouseCodes.BUTTON_0)167    {168        mouseFireButtonDown = true;169    }170};171var onMouseUp = function onMouseUp(mouseCode, x, y)172{173    clickPosition.x = x;174    clickPosition.y = y;175	if(navigator.userAgent.toLowerCase().indexOf('firefox') > -1)176	{177		clickPosition.x -= document.getElementById('turbulenz_game_engine_canvas').offsetLeft;178		clickPosition.y -= document.getElementById('turbulenz_game_engine_canvas').offsetTop;179	}180    if (mouseCode === mouseCodes.BUTTON_0)181    {182        mouseFireButtonDown = false;183		if (gameScene == "game") clickAction();184		else if (gameScene == "menu") clickMenu();185		else if (gameScene == "outro") clickOutro();186    }187};188Draw2DSprite.prototype.getBounds = function(padding){189	var array = [];190	padding = padding || 0;191	array.push(this.x - (this.getWidth()/2) - padding);192	array.push(this.y - (this.getHeight()/2) - padding);193	array.push(this.x + (this.getWidth()/2) + padding);194	array.push(this.y + (this.getHeight()/2) + padding);195	return array;196}197var isMouseInBox = function isMouseInBox(coords, position){198	position = position || mousePosition;199	if ( 200		(position.x > coords[0]) 201		&& (position.y > coords[1])202		&& (position.x < coords[2])203		&& (position.y < coords[3])204	) return true;205	else return false;206}207var clickMenu = function clickMenu(){208	Sound.play("bong");209	if (clickPosition.y <= 390){210		gameScene = "game";211		startGame();212	}213	else if (clickPosition.y <= 430){214		if (tutorial) tutorial = false;215		else tutorial = true;216	}217	else if (clickPosition.y <= 460){218		if (colorBlind) colorBlind = false;219		else colorBlind = true;220		initTextures();221		Graphics.initGameSprites();222	}223	else if (showAdvanced){224		if (clickPosition.y <= 490){225			if (skipFaxes) skipFaxes = false;226			else skipFaxes = true;227		}228		else if (clickPosition.y > 490){229			if (!randomSeed) randomSeed = "ENTER A RANDOM SEED";230			else randomSeed = undefined;231		}232	}233	else if (clickPosition.y > 460){234		showAdvanced = true;235	}236}237var clickOutro = function clickOutro(){238	if ( (clickPosition.y > 470) && (clickPosition.y <= 498) ) {239		window.open("https://en.wikipedia.org/wiki/Liquid_democracy","_blank");240	}241	else if ( (mousePosition.y > 498) && (mousePosition.y < 650) && (mousePosition.x < 526) ){242		window.open("https://en.wikipedia.org/wiki/Participatory_politics","_blank");243	}244	else if ( (mousePosition.y > 498) && (mousePosition.y < 650) && (mousePosition.x >= 526) && (mousePosition.x < 700)) {245		window.open("https://en.wikipedia.org/wiki/Sociocracy","_blank");246	}247	else if ( (mousePosition.y > 498) && (mousePosition.y < 650) && (mousePosition.x >= 700) ) {248		window.open("https://en.wikipedia.org/wiki/Consensus_decision-making","_blank");249	}250	else if (clickPosition.y >= 650){251		gameScene = "menu";252	}253}254var clickAction = function clickAction(){255	if (isMouseInBox(okFaxBtn.getBounds(),clickPosition)){256		if (fax.visible) Sound.play("click");257		fax.visible = false;258		paused = false;259	}260	if (tutorialPopupCounter == 99) {261		tutorialPopupCounter = -1;262		tutorial = false;263	}264	if (paused) togglePause();265	if (isMouseInBox(pause.getBounds(),clickPosition)){266		togglePause();267		lastAction = null;268	}269	else if ( (tutorial) && (tutorialPopupCounter < 10) ) clickActionTutorial();270	else if(gameState == "election"){271		rep = ThePlayer.district.rep;272		if (isMouseInBox(redBtn.getBounds(),clickPosition)){273			ThePlayer.hasVoted = true;274			if (rep.party) rep.constituentSupport[ThePlayer.id] = false;275			else rep.constituentSupport[ThePlayer.id] = true;276			Sound.play("bong");277			lastAction = null;278		}279		else if (isMouseInBox(bluBtn.getBounds(),clickPosition)){280			ThePlayer.hasVoted = true;281			if (rep.party) rep.constituentSupport[ThePlayer.id] = true;282			else rep.constituentSupport[ThePlayer.id] = false;283			Sound.play("bong");284			lastAction = null;285		}286		287	}288	else if(gameState == "bill") {289		if (isMouseInBox(ThePlayer.district.tv.getBounds(), clickPosition)){290			if ( (!ThePlayer.actionBubble) && (Bills[0] != ThePlayer.pet) ) {291				lastAction = "rep";292				ThePlayer.callRep(ThePlayer.pet);293				repCalls++;294				Sound.play("blip");295			}296		} 297		else {298			lastAction = null;299			for (var i in TheDistricts){300				me = TheDistricts[i];301				if (isMouseInBox(me.tv.getBounds(), clickPosition)){302					if ( (!ThePlayer.actionBubble) && (Bills[0] != ThePlayer.pet) ) {303						me.rep.callError();304					}305				}306			}307			for(var i in ThePlayer.friends){308				me = ThePlayer.friends[i];309				if (isMouseInBox(me.sprite.getBounds(3), clickPosition)){310					if ( (!ThePlayer.actionBubble) && (Bills[0] != ThePlayer.pet) ) {311						ThePlayer.callFriend(me,ThePlayer.pet);312						if (!me.active) ThePlayer.rallyFriend(me);313						friendCalls++;314						Sound.play("bong");315						lastAction = "friend";316					}317				}318			}319		}320	}...utils.mjs
Source:utils.mjs  
1export function addTextToBody(text) {2    console.log("hello")3    const div = document.createElement('div');4    div.textContent = text;5    document.body.appendChild(div);6  7    var dataset = [];8var dataset2 = [];9d3.csv("./cities.csv", function (data) {10    data.forEach(function (d) {11        // console.log(d); // Not needed.12        // console.log(d['land area']); // Not needed.13        dataset.push(parseInt(d['land area']));14        dataset2.push(d);15    });16    // *** Define Our Variables ***17    var svgWidth = 800, svgHeight = 300, barPadding = 10, shiftRight = 0, shiftUp = 0; // 'shiftRight' shifts the axis, bars, and text right. 'shiftUp' shift the axis, bars, and text up. 'barWidth' makes the bars more narrow.18    var barWidth = ((svgWidth / dataset.length) + (barPadding / 2));19    var svg = d3.select('svg')20        .style('margin-top', '20')21        .style('padding', '40')22        .attr("width", svgWidth)23        .attr("height", svgHeight)24        .attr("display", "block");25    var yScale = d3.scaleLinear()26        .domain([0, d3.max(dataset)])27        .range([0, svgHeight]);28    // *** The bar chart ***29    var barChart = svg.selectAll("rect")30        .data(dataset)31        .enter()32        .append("rect")33        .attr("y", function (d) {34            return svgHeight - yScale(d);35        })36        .attr("height", function (d) {37            return yScale(d);38        })39        .attr("width", barWidth - (barPadding / 2)) // I replaced 'barWidth' with 'barWidth - (barPadding/2)'.40        .attr("transform", function (d, i) {41            var translate = [(barWidth * i) + shiftRight, - shiftUp]; // 'shiftRight' moves the bars right. 42            // var translate = [((barWidth * i) + (barPadding) / 2) + shiftRight - 0, - shiftUp]; // 'shiftRight' moves the bars right. 'shiftUp' brings the bars up.43            return "translate(" + translate + ")";44        });45    // *** Bar height text *** see https://scrimba.com/p/pb4WsX/c4WLes846    var text = svg.selectAll('text')47        .data(dataset)48        .enter()49        .append('text')50        .text(function (d) {51            return d;52        })53        .attr('y', function (d, i) {54            return svgHeight - yScale(d) - shiftUp - 5; // -shiftUp shifts the text up.55        })56        .attr('x', function (d, i) {57            return ((barWidth * i) + (barWidth - barPadding) / 2) + shiftRight; // 'shiftRight' shifts the text right. Replaced '(barWidth * i)' with '((barWidth * i) ) + shiftRight'.58        })59        .attr("fill", "#A64C38");60    // *** The Axes *** see https://scrimba.com/p/pb4WsX/c6rwbhr61    var xScaleAxis = d3.scaleLinear()62        .domain([0, d3.max(dataset)])63        .range([0, svgWidth]);64    var yScaleAxis = d3.scaleLinear()65        .domain([0, d3.max(dataset)])66        .range([svgHeight, 0]);67    // The following is not used for this example.68    // var x_axis = d3.axisBottom() // .axisBottom returns a function which we chain with another function, .scale69    // .scale(xScaleAxis); // We then pass xScale through our function, .scale.70    var y_axis = d3.axisLeft()71        .scale(yScaleAxis);72    svg.append("g") // "g" for group element.73        .attr("transform", "translate(" + shiftRight + ", -" + shiftUp + ")") // 'shiftRight' moves the y-axis right. 'shiftUp' shifts the y-axis up.74        .call(y_axis);75    var xAxisTranslate = svgHeight - shiftUp; // 'shiftUp' moves the x-axis down. 'xAxisTranslate' brings the x-axis down from the top of the svg.76    // The following is not used for this example.77    // svg.append("g")78    // .attr("transform", "translate(" + shiftRight + "," + xAxisTranslate + ")") // 'shiftRight' moves the x-axis right. 'xAxisTranslate' shifts the x-axis in.79    // .call(x_axis);80    // *** The Pie Chart *** see https://scrimba.com/p/pb4WsX/cPyPVAr81    var data2 = [82        { "platform": "Android", "percentage": 40.11 },83        { "platform": "Windows", "percentage": 36.69 },84        { "platform": "iOS", "percentage": 13.06 }85    ];86    var svgWidth2 = 500, svgHeight2 = 300, radius = Math.min(svgWidth2, svgHeight2) / 2;87    var svg2 = d3.select('.pie-chart')88        .attr("width", svgWidth2)89        .attr("height", svgHeight2);90    //Create group element to hold pie chart    91    var g = svg2.append("g")92        .attr("transform", "translate(" + radius + "," + radius + ")");93    var color = d3.scaleOrdinal(d3.schemeCategory10);94    var pie = d3.pie().value(function (d) {95        return d.percentage;96    });97    var path = d3.arc()98        .outerRadius(radius)99        .innerRadius(0);100    var arc = g.selectAll("arc")101        .data(pie(data2))102        .enter()103        .append("g");104    arc.append("path")105        .attr("d", path)106        .attr("fill", function (d) { return color(d.data.percentage); });107    var label = d3.arc()108        .outerRadius(radius)109        .innerRadius(0);110    arc.append("text")111        .attr("transform", function (d) {112            return "translate(" + label.centroid(d) + ")";113        })114        .attr("text-anchor", "middle")115        .text(function (d) { return d.data.platform + ":" + d.data.percentage + "%"; });116        // displaying the data.117        console.log("The dataset:");118        console.log(dataset);119        console.log("The second dataset:");120        dataset2.forEach(element => {121            let cityArray = [];122            console.log(element.city);123            124        });125        // console.log(dataset2);126    // console.log('../../Data/NationalBabyNames/citiesObject.js/myObect[0]');127    // console.log(test);128});...cumulative.js
Source:cumulative.js  
1module.exports = function (opt) {2	var options = {3		reversed: false,4		shiftup: false,5		shiftdown: false,6		row: false,7		column: true8	};9	this.setField.wrap((prev, field, tables, fieldLookup) => {10		prev(field, tables, fieldLookup);11		this.outColumn.label = "Cumulative " + this.outColumn.label;12		return this;13	});14	opt.forEach(function (option) {15		option = option.trim().toLowerCase();16		if (option === "row" || option === "horizontal") {17			options.row = true;18			options.column = false;19		} else if (option === "reversed" || option === "reverse") {20			options.reversed = true;21		} else if (option === "up") {22			options.shiftup = true;23		} else if (option === "down") {24			options.shiftdown = true;25		}26	});27	this.postProcess.wrap(function (parent, data, mapping, out) {28		parent(data, mapping, out);29		var columns = [];30		var alias = this.alias;31		mapping.forEach(function (col, i) {32			if (col.alias === alias) {33				columns.push(i);34			}35		});36		if (options.row) {37			processRows(data, columns, out.totals.rows);38		} else {39			processColumns(data, columns, out.totals.columns);40		}41	});42	function processColumns(data, columns, totals) {43		var rowsLength = data.length;44		var columnLength = columns.length;45		var prev = [];46		var i, x, j, p, t, val, row;47		for (i = 0; i < columnLength; i++) {48			x = columns[i];49			prev[x] = 0;50		}51		var lastRow = [];52		if (options.reversed) {53			for (i = rowsLength - 1; i >= 0; i--) {54				row = data[i];55				for (j = 0; j < columnLength; j++) {56					x = columns[j];57					val = row[x];58					if (!val || isNaN(val)) {59						val = 0;60					}61					if (options.shiftup) {62						row[x] = prev[x];63						prev[x] = prev[x] + val;64					} else if (options.shiftdown) {65						prev[x] = lastRow[x] = val + prev[x];66					} else {67						prev[x] = row[x] = prev[x] + val;68					}69				}70				lastRow = row;71			}72			if (options.shiftdown) {73				data[0] = prev;74			}75		} else {76			for (i = 0; i < rowsLength; i++) {77				row = data[i];78				for (j = 0; j < columnLength; j++) {79					x = columns[j];80					val = row[x];81					if (!val || isNaN(val)) {82						val = 0;83					}84					if (options.shiftup) {85						prev[x] = lastRow[x] = val + prev[x];86					} else if (options.shiftdown) {87						row[x] = prev[x];88						prev[x] = prev[x] + val;89					} else {90						prev[x] = row[x] = prev[x] + val;91					}92				}93				lastRow = row;94			}95			if (options.shiftup) {96				for (j = 0; j < columnLength; j++) {97					x = columns[j];98					data[i - 1][x] = prev[x];99				}100			}101		}102	}103	function processRows(data, columns, rowTotals) {104		var rowsLength = data.length;105		var columnLength = columns.length;106		var prev = [];107		var i, x, j, p, t, val, row;108		var lastx = null;109		if (options.reversed) {110			for (i = 0; i < rowsLength; i++) {111				row = data[i];112				p = 0;113				for (j = columnLength - 1; j >= 0; j--) {114					x = columns[j];115					val = row[x];116					if (!val || isNaN(val)) {117						val = 0;118					}119					if (options.shiftup) {120						row[x] = p;121						p = p + val;122					} else if (options.shiftdown) {123						if (lastx) {124							p = row[lastx] = val + p;125						}126					} else {127						p = row[x] = p + val;128					}129					lastx = x;130				}131				if (options.shiftdown) {132					row[columns[0]] = p;133				}134			}135		} else {136			for (i = 0; i < rowsLength; i++) {137				row = data[i];138				p = 0;139				for (j = 0; j < columnLength; j++) {140					x = columns[j];141					val = row[x];142					if (!val || isNaN(val)) {143						val = 0;144					}145					if (options.shiftup) {146						p = row[lastx] = val + p;147					} else if (options.shiftdown) {148						row[x] = p;149						p = p + val;150					} else {151						p = row[x] = p + val;152					}153					lastx = x;154				}155				if (options.shiftup) {156					row[x] = p;157				}158			}159		}160	}...ScrollBtn.js
Source:ScrollBtn.js  
1import React, { Component } from "react";2import classNames from "classnames";3import { FaArrowUp } from "react-icons/fa";4import { FaArrowDown } from "react-icons/fa";5export default class ScrollBtn extends Component {6  constructor(props) {7    super(props);8    this.state = {9      targetId: props.targetId,10      behavior: props.behavior,11      iconType: props.iconType,12      shiftUp: false,13      showButton: false14    };15    this.handleScroll = this.handleScroll.bind(this);16    this.handleClick = this.handleClick.bind(this);17  }18  componentDidMount() {19    window.addEventListener("scroll", this.handleScroll);20  }21  // Detect when the scroll up button should appear22  handleScroll() {23    let showButton = this.state.showButton;24    if (!showButton) {25      if (window.scrollY > 90) {26        this.setState({27          showButton: true28        });29      }30    } else {31      if (window.scrollY < 90) {32        this.setState({33          showButton: false34        });35      }36    }37    let shiftUp = this.state.shiftUp;38    let targetDiv = document.getElementsByTagName("FOOTER")[0];39    let button = document.getElementById("scroll-btn");40    let btnMarginBottom = window.getComputedStyle(button).marginBottom;41    btnMarginBottom = parseFloat(btnMarginBottom);42    if (!shiftUp) {43      if ((window.innerHeight + window.scrollY) > (targetDiv.offsetTop + btnMarginBottom)) {44        this.setState({45          shiftUp: true46        });47      }48    } else {49      if ((window.innerHeight + window.scrollY) < (targetDiv.offsetTop + btnMarginBottom)) {50        this.setState({51          shiftUp: false52        });53      }54    }55  }56  // If a targetId was supplied, scroll to target; else scroll to top of page57  handleClick() {58    let targetId = this.state.targetId;59    let behavior = this.state.behavior || "auto";60    if (targetId !== null && targetId !== undefined && targetId.trim().length > 0) {61      let targetDiv = document.getElementById("" + targetId);62      targetDiv.scrollIntoView({ behavior: behavior });63    } else {64      window.scrollTo({ top: 0, behavior: behavior })65    }66  }67  render() {68    const classes = classNames({69        circle: true, // always add this class70        active: this.state.showButton, // only add this class if the state says so71        shift: this.state.shiftUp 72    });73    const arrows = {74        "arrow-up" : <FaArrowUp className="circle-arrow"/>,75        "arrow-down" : <FaArrowDown className="circle-arrow"/>76    };77    return (78      <button type="button" name="scroll top" id="scroll-btn" className={classes} onClick={this.handleClick} aria-label="scroll top">79        <span className="circle circle-top"></span>80        {arrows[this.state.iconType]}81        <span className="circle circle-bottom"></span>82      </button>83    );84  }...keymap.js
Source:keymap.js  
1const keyToNote = {2  a: "F",3  s: "G",4  d: "A",5  f: "B",6  g: "C",7  h: "D",8  j: "E",9  k: "F",10  l: "G",11  ";": "A",12  "'": "B",13  q: "F#",14  w: "F#",15  e: "G#",16  r: "A#",17  t: "C#",18  y: "C#",19  u: "D#",20  i: "F#",21  o: "F#",22  p: "G#",23  "[": "A#",24};25const allKeys = {26  blackkeys: [27    { id: "q  w", pressed: false, shiftUp: false },28    { id: "e", pressed: false, shiftUp: false },29    { id: "r", pressed: false, shiftUp: false },30    { id: "t  y", pressed: false, shiftUp: true },31    { id: "u", pressed: false, shiftUp: true },32    { id: "i  o", pressed: false, shiftUp: true },33    { id: "p", pressed: false, shiftUp: true },34    { id: "[", pressed: false, shiftUp: true },35  ],36  whitekeys: [37    { id: "a", pressed: false, shiftUp: false },38    { id: "s", pressed: false, shiftUp: false },39    { id: "d", pressed: false, shiftUp: false },40    { id: "f", pressed: false, shiftUp: false },41    { id: "g", pressed: false, shiftUp: true },42    { id: "h", pressed: false, shiftUp: true },43    { id: "j", pressed: false, shiftUp: true },44    { id: "k", pressed: false, shiftUp: true },45    { id: "l", pressed: false, shiftUp: true },46    { id: ";", pressed: false, shiftUp: true },47    { id: "'", pressed: false, shiftUp: true },48  ],49};50const drumKeys = {51  blackkeys: [52    { id: "q  w", pressed: false, disabled: true },53    { id: "e", pressed: false, disabled: true },54    { id: "r", pressed: false, disabled: true },55    { id: "t  y hihat", pressed: false, disabled: false },56    { id: "u", pressed: false, disabled: true },57    { id: "i  o", pressed: false, disabled: true },58    { id: "p", pressed: false, disabled: true },59    { id: "[", pressed: false, disabled: true },60  ],61  whitekeys: [62    { id: "a kick", pressed: false, disabled: false },63    { id: "s snare", pressed: false, disabled: false },64    { id: "d", pressed: false, disabled: true },65    { id: "f", pressed: false, disabled: true },66    { id: "g", pressed: false, disabled: true },67    { id: "h", pressed: false, disabled: true },68    { id: "j", pressed: false, disabled: true },69    { id: "k", pressed: false, disabled: true },70    { id: "l", pressed: false, disabled: true },71    { id: ";", pressed: false, disabled: true },72    { id: "'", pressed: false, disabled: true },73  ],74};...state-machine-test.js
Source:state-machine-test.js  
1import Ember from 'ember';2import StateMachine from 'ivy-stateful/state-machine';3import { module, test } from 'qunit';4module('unit/state-machine');5var Vehicle = StateMachine.extend({6  initialState: 'parked',7  isParked: Ember.computed.readOnly('currentState.isParked'),8  speed: Ember.computed.readOnly('currentState.speed'),9  rootState: {10    speed: 0,11    firstGear: {12      speed: 10,13      shiftUp: function(vehicle) {14        vehicle.transitionTo('secondGear');15      }16    },17    secondGear: {18      speed: 20,19      shiftDown: function(vehicle) {20        vehicle.transitionTo('firstGear');21      }22    },23    idling: {24      speed: 0,25      shiftUp: function(vehicle) {26        vehicle.transitionTo('firstGear');27      }28    },29    parked: {30      isParked: true,31      enter: function(vehicle) {32        vehicle.set('seatbeltOn', false);33      },34      exit: function(vehicle) {35        vehicle.set('seatbeltOn', true);36      },37      ignite: function(vehicle) {38        vehicle.transitionTo('idling');39      }40    }41  }42});43test('should send action to current state', function(assert) {44  var vehicle = Vehicle.create();45  assert.equal(vehicle.get('speed'), 0);46  vehicle.send('ignite');47  vehicle.send('shiftUp');48  assert.equal(vehicle.get('speed'), 10);49  vehicle.send('shiftUp');50  assert.equal(vehicle.get('speed'), 20);51});52test('should throw on an invalid transition', function(assert) {53  var vehicle = Vehicle.create();54  vehicle.send('ignite');55  vehicle.send('shiftUp');56  vehicle.send('shiftUp');57  assert.throws(function() {58    vehicle.send('park');59  }, /Attempted to handle event "park" on .*? while in state rootState.secondGear/);60});61test('should fire enter hook when entering a state', function(assert) {62  var vehicle = Vehicle.create();63  assert.equal(vehicle.get('seatbeltOn'), false);64});65test('should fire exit hook when exiting a state', function(assert) {66  var vehicle = Vehicle.create();67  vehicle.send('ignite');68  assert.equal(vehicle.get('seatbeltOn'), true);...Using AI Code Generation
1import { Selector } from 'testcafe';2test('My first test', async t => {3        .typeText('#developer-name', 'John Smith')4        .click('#submit-button')5        .click('#tried-test-cafe')6        .click('#remote-testing')7        .click('#reusing-js-code')8        .click('#background-parallel-testing')9        .click('#continuous-integration-embedding')10        .click('#traffic-markup-analysis')11        .click('#test-execution-dashboard')12        .click('#using-concurrency')13        .click('#run-in-docker')14        .click('#testcafe-studio')15        .click('#testcafe-browser-provider-crossbrowsertesting')16        .click('#testcafe-browser-provider-browserstack')17        .click('#testcafe-browser-provider-saucelabs')18        .click('#testcafe-community-contributed-plugins')19        .click('#testcafe-support')20        .click('#testcafe-tutorials')21        .click('#testcafe-faq')22        .click('#testcafe-features');23});Using AI Code Generation
1import { Selector } from 'testcafe';2test('My first test', async t => {3        .typeText('#developer-name', 'John Smith')4        .click('#submit-button')5        .expect(Selector('#article-header').innerText).eql('Thank you, John Smith!');6});Using AI Code Generation
1import { Selector } from 'testcafe';2test('My first test', async t => {3        .click('#populate')4        .click('#submit-button')5        .expect(Selector('#article-header').innerText).eql('Thank you, John Smith!');6});Using AI Code Generation
1import { Selector } from 'testcafe';2test('My first test', async t => {3        .typeText('#developer-name', 'John Smith')4        .click('#submit-button')5        .expect(Selector('#article-header').innerText).eql('Thank you, John Smith!');6});7import { Selector } from 'testcafe';8test('My first test', async t => {9        .typeText('#developer-name', 'John Smith')10        .click('#submit-button')11        .expect(Selector('#article-header').innerText).eql('Thank you, John Smith!');12});13import { Selector } from 'testcafe';14test('My first test', async t => {15        .typeText('#developer-name', 'John Smith')16        .click('#submit-button')17        .expect(Selector('#article-header').innerText).eql('Thank you, John Smith!');18});19import { Selector } from 'testcafe';20test('My first test', async t => {21        .typeText('#developer-name', 'John Smith')22        .click('#submit-button')23        .expect(Selector('#article-header').innerText).eql('Thank you, John Smith!');24});25import { Selector } from 'testcafe';26test('My first test', async tUsing AI Code Generation
1import { Selector } from 'testcafe';2test('My first test', async t => {3        .typeText('#developer-name', 'John Smith')4        .click('#macos')5        .click('#submit-button');6});7import { Selector } from 'testcafe';8test('My first test', async t => {9        .typeText('#developer-name', 'John Smith')10        .click('#macos')11        .click('#submit-button');12});13import { Selector } from 'testcafe';14test('My first test', async t => {15        .typeText('#developer-name', 'John Smith')16        .click('#macos')17        .click('#submit-button');18});19import { Selector } from 'testcafe';20test('My first test', async t => {21        .typeText('#developer-name', 'John Smith')22        .click('#macos')23        .click('#submit-button');24});25import { Selector } from 'testcafe';26test('My first test', async t => {27        .typeText('#developer-name', 'John Smith')28        .click('#macos')29        .click('#submit-button');30});31import { Selector } from 'testcafe';32test('My first test', async t => {33        .typeText('#developer-name', 'John Smith')34        .click('#macos')35        .click('#submit-button');36});Using AI Code Generation
1import { Selector } from 'testcafe';2test('My first test', async t => {3        .typeText('#developer-name', 'John Smith')4        .click('#tried-test-cafe')5        .click('#submit-button');6});7import { Selector } from 'testcafe';8test('My first test', async t => {9        .typeText('#developer-name', 'John Smith')10        .click('#tried-test-cafe')11        .click('#submit-button');12});13import { Selector } from 'testcafe';14test('My first test', async t => {15        .typeText('#developer-name', 'John Smith')16        .click('#tried-test-cafe')17        .click('#submit-button');18});19import { Selector } from 'testcafe';20test('My first test', async t => {21        .typeText('#developer-name', 'John Smith')22        .click('#tried-test-cafe')23        .click('#submit-button');24});25import { Selector } from 'testcafe';26test('My first test', async t => {27        .typeText('#developer-name', 'John Smith')28        .click('#tried-test-cafe')29        .click('#submit-button');30});31import { Selector } from 'testcafe';32test('My first test', async t => {33        .typeText('#developer-name', 'John Smith')34        .click('#triedUsing AI Code Generation
1import { Selector } from 'testcafe';2test('My first test', async t => {3    const developerNameInput = Selector('#developer-name');4        .typeText(developerNameInput, 'Peter')5        .click('#submit-button')6        .expect(Selector('#article-header').innerText).eql('Thank you, Peter!');7});8* [Supertest](Using AI Code Generation
1test('Testcafe test', async t => {2        .click(Selector('button').withText('Click me'))3        .expect(Selector('span').withText('1').exists).ok()4        .click(Selector('button').withText('Click me'))5        .expect(Selector('span').withText('2').exists).ok()6        .click(Selector('button').withText('Click me'))7        .expect(Selector('span').withText('3').exists).ok()8        .click(Selector('button').withText('Click me'))9        .expect(Selector('span').withText('4').exists).ok()10        .click(Selector('button').withText('Click me'))11        .expect(Selector('span').withText('5').exists).ok()12        .click(Selector('button').withText('Click me'))13        .expect(Selector('span').withText('6').exists).ok()14        .click(Selector('button').withText('Click me'))15        .expect(Selector('span').withText('7').exists).ok()16        .click(Selector('button').withText('Click me'))17        .expect(Selector('span').withText('8').exists).ok()18        .click(Selector('button').withText('Click me'))19        .expect(Selector('span').withText('9').exists).ok()20        .click(Selector('button').withText('Click me'))21        .expect(Selector('span').withText('10').exists).ok()22        .click(Selector('button').withText('Click me'))23        .expect(Selector('span').withText('11').exists).ok()24        .click(Selector('button').withText('Click me'))25        .expect(Selector('span').withText('12').exists).ok()26        .click(Selector('button').withText('Click me'))27        .expect(Selector('span').withText('13').exists).ok()28        .click(Selector('button').withText('Click me'))29        .expect(Selector('span').withText('14').exists).ok()30        .click(Selector('button').withText('Click me'))31        .expect(Selector('span').withText('15').exists).ok()32        .click(Selector('button').withText('Click me'))33        .expect(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!!
