How to use Hello method in Cypress

Best JavaScript code snippet using cypress

test-html-text-parser.js

Source:test-html-text-parser.js Github

copy

Full Screen

1/*global test, deepEqual, largeModule, strictEqual */2largeModule('HtmlTextParser');3var parser = new cc._Test.HtmlTextParser();4test('Basic Test', function() {5    var testStr1 = "hello world";6    deepEqual(parser.parse(testStr1),7                [{text: "hello world"}],8                'No Html string should be equal to original.');9    var testInvalidStr2 = "<x hello world";10    deepEqual(parser.parse(testInvalidStr2),11              [{text: "x hello world"}],12              'Invalid tag begin.');13    var testInvalidStr1 = "<x>hello world</x>";14    deepEqual(parser.parse(testInvalidStr1),15              [{text: "hello world", style: {}}],16                'Invalid tags');17    var testInvalidStr3 = "</b>hello world";18    deepEqual(parser.parse(testInvalidStr3),19              [{text: "hello world"}],20               "invalid tags end.");21    var testInvalidStr4 = "</>hello world";22    deepEqual(parser.parse(testInvalidStr4),23              [{text: "hello world"}],24             "Empty tags are emitted.");25    var testInvalidStr5 = "<b>hello world";26    deepEqual(parser.parse(testInvalidStr5),27              [{text: "hello world"}],28              "Empty tags are emitted.");29});30test('Color test', function(){31    var colorTestStr1 = "<color=#0xffff00>hello world</color>";32    deepEqual(parser.parse(colorTestStr1),33              [{text: "hello world", style: {color: "#0xffff00"}}],34              "Happy path.");35    var colorTestStr2 = "<color=#0xffff33>hello world</xxx>";36    deepEqual(parser.parse(colorTestStr2),37              [{text: "hello world", style: {color: "#0xffff33"}}],38              "Happy path two.");39    var colorTestStr3 = "<color#0xffff33>hello world</xxx>";40    deepEqual(parser.parse(colorTestStr3),41              [{text: "hello world", style: {}}],42              "Missing the = sign.");43    var colorTestStr4 = "<color=>hello world</xxx>";44    deepEqual(parser.parse(colorTestStr4),45              [{text: "hello world", style: {}}],46              "missing the color value.");47    var colorTestStr5 = "<c=#0xff4400>hello world</xxx>";48    deepEqual(parser.parse(colorTestStr5),49              [{text: "hello world", style: {}}],50              "tag name is invalid");51    var colorTestStr6 = "<color = #0xff4400>hello world";52    deepEqual(parser.parse(colorTestStr6),53              [{text: "hello world"}],54              "The close tag is missing.");55});56test('Size test', function() {57    var sizeTestStr1 = "<size = 20>hello world</size>";58    deepEqual(parser.parse(sizeTestStr1),59              [{text: "hello world", style: {size: 20}}],60              "Happy path 1.");61    var sizeTestStr2 = "<size = 20>hello world</xx>";62    deepEqual(parser.parse(sizeTestStr2),63              [{text: "hello world", style: {size: 20}}],64              "Happy path 2.");65    var sizeTestStr3 = "<size20>hello world</xxx>";66    deepEqual(parser.parse(sizeTestStr3),67              [{text: "hello world", style: {}}],68              "Missing the = sign.");69    var sizeTestStr4 = "<size=>hello world</xxx>";70    deepEqual(parser.parse(sizeTestStr4),71              [{text: "hello world", style: {}}],72              "missing the color value.");73    var sizeTestStr5 = "<s=20>hello world</xxx>";74    deepEqual(parser.parse(sizeTestStr5),75              [{text: "hello world", style: {}}],76              "tag name is invalid");77    var sizeTestStr6 = "<size=20>hello world";78    deepEqual(parser.parse(sizeTestStr6),79              [{text: "hello world"}],80              "The close tag is missing.");81});82test('Event test', function() {83    var eventTestString = "<on click=' event1' hoverin='event2 ' hoverout = 'event3'>hello world</on>";84    deepEqual(parser.parse(eventTestString),85              [{text: "hello world", style: {86                  event: {87                  click : "event1"88                  }}}], "Happy path 1");89    var eventTestStringFail1 = "<on click=' event1' hoverin'event2 ' hoverout=event3>hello world</on>";90    deepEqual(parser.parse(eventTestStringFail1),91              [{text: "hello world", style: {92                  event: {93                      click : "event1",94                  }}}], "Fail path 1");95    var eventTestStringFail2 = "<size=20 click=' event1' hoverin=event2 hoverout:event3>hello world</on>";96    deepEqual(parser.parse(eventTestStringFail2),97              [{text: "hello world", style: {98                  size: 20,99                  event: {100                      click : "event1",101                  }}}], "Fail path 2");102    var eventTestStringFail3 = "<size=20 click=event1 hoverin='event2' hoverout:event3>hello world</on>";103    deepEqual(parser.parse(eventTestStringFail3),104              [{text: "hello world", style: {105                  size: 20,106                  event: {107                  }}}], "Fail path 3");108    var eventTestString2 = "<color=#0xff0000 click=\"event1\">Super weapon</color>";109    deepEqual(parser.parse(eventTestString2),110              [{text: "Super weapon", style: {111                  color: "#0xff0000",112                  event: {113                  click : "event1",114                  }115              }}], "Color with event");116    var eventTestString3 = "<size=20 click='event1' hoverin='event2'>hello world</>";117    deepEqual(parser.parse(eventTestString3),118              [{text: "hello world",119                style: {120                    size: 20,121                    event: {122                        click : "event1",123                    }124                }}], "Size with event");125    var eventTestString4 = "<sie=20 click='event1' hoverin='event2'>hello world</>";126    deepEqual(parser.parse(eventTestString4),127              [{text: "hello world",128                style: {}129               }], "Failed path: Size with event");130    var invalidEventTestString4 = "<size=20 click='event1\">hello world</>";131    deepEqual(parser.parse(invalidEventTestString4),132              [{text: "hello world",133                style: {size: 20,134                        event: {}}135               }], "Failed path: event name quote not match.");136    var invalidEventTestString5 = "<size=20 click=\"event1'>hello world</>";137    deepEqual(parser.parse(invalidEventTestString5),138              [{text: "hello world",139                style: {size: 20,140                        event: {}}141               }], "Failed path: event name quote not match.");142});143test('Test special symbol escape', function() {144    var testLessThan = "<size=20>hello&lt;world</size>";145    deepEqual(parser.parse(testLessThan),146                [ {text: "hello<world",147                   style: {148                       size: 20149                   }150                  }],151                "The &lt; symbol should be correctly escaped.");152    var testGreatThan = "<on click='event1'> hello&gt;world</on>";153    deepEqual(parser.parse(testGreatThan),154                [{text: " hello>world",155                  style: {156                      event: {157                          click: 'event1'158                      }159                  }}],160                "The &gt; symbol should be correctly escaped.");161    var testAmp = "<color=#0xff00>hello&amp;world</>";162    deepEqual(parser.parse(testAmp),163              [{text: "hello&world",164                style: {165                    color: "#0xff00"166                }}],167                "The amp symbol should be correctly escaped.");168    var testQuot = "<on>hello&quot;world</on>";169    deepEqual(parser.parse(testQuot),170              [{text: "hello\"world",171                style: {}}],172                "The quot symbol should be correctly escaped.");173    var testApos = "<color=#0xffee>Hi, <size=20>hello&apos;world</s></c>";174    deepEqual(parser.parse(testApos),175              [{text: "Hi, ",176                style: {177                    color: "#0xffee"178                }},179               {text: "hello'world",180                style: {181                    color: "#0xffee",182                    size: 20183                }}],184                "The apos symbol should be correctly escaped.");185});186test('Integrate test', function() {187    var eventTestString = "hello <b>world</b>, <color=#0xff0000> Ni hao </color>";188    deepEqual(parser.parse(eventTestString),189              [{text: "hello "}, {text: "world", style: {bold: true}},190               {text: ", "},191               {text: " Ni hao ", style : {color: "#0xff0000"}}], "Happy path 1");192    var moreComplexString = "<size=20>大小<size=10>不一</size></size>,<color=#0xffeeaa>颜色</c><color=#0xffaaee>不同</c><on click='event1'>可点击</on>";193    deepEqual(parser.parse(moreComplexString),194              [{text: "大小", style: {size: 20}}, {text: "不一", style: {size: 10}}, {text:","},195               {text: "颜色", style: {color: "#0xffeeaa"}}, {text: "不同", style: {color: "#0xffaaee"}},196               {text: "可点击", style: {event: {click: 'event1'}}}], "more complex test");197});198test('bold/italic/underline test', function () {199    var stringWithBold = "<b></i><b>hello \n world</b>";200    deepEqual(parser.parse(stringWithBold),201              [{text: "hello \n world", style: {bold: true}}], "bold test");202    var stringWithItalic = "<i>hello world</i>";203    deepEqual(parser.parse(stringWithItalic),204              [{text: "hello world", style: {italic: true}}], "italic test");205    var stringWithUnderline = "<u>hello world</u>";206    deepEqual(parser.parse(stringWithUnderline),207              [{text: "hello world", style: {underline: true}}], "underline test");208});209test('test br tag', function () {210    var newlineTest = "<br/>";211    deepEqual(parser.parse(newlineTest),212              [{text: "", style: {newline: true}},], "newline element test");213    var newlineTest2 = "hello <b>a< br  /></b> world";214    deepEqual(parser.parse(newlineTest2),215              [{text: "hello "},216               {text: "a", style: {bold: true}},217               {text: "", style: {newline: true}},218               {text: " world"}219              ], "newline element test");220    var newlineTest3 = "< br />";221    deepEqual(parser.parse(newlineTest3),222              [{text: "", style: {newline: true}},], "newline element test");223    var newlineTest4 = "<br></br>";224    deepEqual(parser.parse(newlineTest4),225              [], "newline element test");226    var newlineTest5 = "hello <b>a<br></></b> world";227    deepEqual(parser.parse(newlineTest5),228              [{text: "hello "},229               {text: "a", style: {bold: true}},230               {text: " world"}231              ], "newline element test");232    var newlineTest6 = "hello <b>a<br /><br/ ></b> world";233    deepEqual(parser.parse(newlineTest6),234              [{text: "hello "},235               {text: "a", style: {bold: true}},236               {text: "", style: {newline: true}},237               {text: "", style: {newline: true}},238               {text: " world"}239              ], "newline element test");240    var newlineTest7 = "hello <b>a</b><br /><br/ >world";241    deepEqual(parser.parse(newlineTest7),242              [{text: "hello "},243               {text: "a", style: {bold: true}},244               {text: "", style: {newline: true}},245               {text: "", style: {newline: true}},246               {text: "world"}247              ], "newline element test");248});249test('test image tag', function () {250    var imageTest1 = "<img src='weapon' />";251    deepEqual(parser.parse(imageTest1),252              [253                  {text: "",254                   style: {isImage: true, src: "weapon"}}255              ], "image element test 1");256    var imageTest2 = '<img src = "weapon"/>';257    deepEqual(parser.parse(imageTest2),258              [259                  {text: "", style: {isImage: true, src: "weapon"}}260              ], "image element test 2");261    var imageTest3 = "hello, <b>world<img src='nihao' /></>";262    deepEqual(parser.parse(imageTest3),263              [264                  {text: "hello, "},265                  {text: "world", style : {bold: true}},266                  {text: "", style: {isImage: true, src: "nihao"}}267              ], "image element test");268    var imageTest4 = "hello, <b>world<img src=nihao /  ></>";269    deepEqual(parser.parse(imageTest4),270              [271                  {text: "hello, "},272                  {text: "world", style : {bold: true}},273              ], "image element test");274    var imageTest5 = "hello, <b>world<on click='handler'><img src=nihao /  ></on></b>";275    deepEqual(parser.parse(imageTest5),276              [277                  {text: "hello, "},278                  {text: "world", style : {bold: true}},279              ], "image element event test");280    var imageTest6 = "hello, <b>world<img src='head' click='handler' /></b>";281    deepEqual(parser.parse(imageTest6),282              [283                  {text: "hello, "},284                  {text: "world", style : {bold: true}},285                  {text: "", style: {isImage: true, src: "head",286                                     event: {click: "handler"}}}287              ], "image element event test");288    var invalidImageTest1 = "<img src='hello'></img>";289    deepEqual(parser.parse(invalidImageTest1),290              [], "image element invalid test");291    var invalidImageTest2 = "<img src='world'>";292    deepEqual(parser.parse(invalidImageTest2),293              [], "image element invalid test");294    var invalidImageTest3 = "<image src='world' />";295    deepEqual(parser.parse(invalidImageTest3),296              [], "image element invalid test");297    var nestedImageTest4 = "<b><u><img src='world' click='handler' /></b></u>";298    deepEqual(parser.parse(nestedImageTest4),299              [{text: "", style: {isImage: true, src: 'world',300                                  event: {click: 'handler'}}}], "image element invalid test");301});302test('test outline tag', function () {303    var outlineTest1 = "<outline color = #0f00ff width=2 >hello</outline>";304    deepEqual(parser.parse(outlineTest1),305              [306                  {text: "hello",307                   style: { outline: {308                       color: "#0f00ff",309                       width: 2310                   }}}311              ], "outline element test 1");312    var outlineTest2 = '<outline color= #0f00ff>hello</outline>';313    deepEqual(parser.parse(outlineTest2),314              [315                  {text: "hello", style: {316                      outline: {317                          color: "#0f00ff",318                          width: 1319                      }320                  }}321              ], "outline element test 2");322    var outlineTest3 = '<outline width =  4>hello</outline>';323    deepEqual(parser.parse(outlineTest3),324              [325                  {text: "hello", style: {326                      outline: {327                          color: "#ffffff",328                          width: 4329                      }330                  }}331              ], "outline element test 3");332    var outlineTest4 = '<outline >hello</outline>';333    deepEqual(parser.parse(outlineTest4),334              [335                  {text: "hello", style: {336                      outline: {337                          color: "#ffffff",338                          width: 1339                      }340                  }}341              ], "outline element test 4");342    var outlineTest5 = "<outline click=  'clickme' width =2 color=#0f00ff>hello</outline>";343    deepEqual(parser.parse(outlineTest5),344              [345                  {text: "hello",346                   style: {347                       outline: {348                           color: "#0f00ff",349                           width: 2350                       },351                       event: {352                           click: "clickme"353                       }354                   }}355              ], "outline element test 5");356    var outlineTest6 = "<outline  width =2 color=#0f00ff click='clickme'>hello</outline>";357    deepEqual(parser.parse(outlineTest6),358              [359                  {text: "hello",360                   style: {361                       outline: {362                           color: "#0f00ff",363                           width: 2364                       },365                       event: {366                           click: "clickme"367                       }368                   }}369              ], "outline element test 6");370    var outlineTest7 = "<outline  width =2 color=#0f00ff><on click='clickme'>hello</on></outline>";371    deepEqual(parser.parse(outlineTest7),372              [373                  {text: "hello",374                   style: {375                       outline: {376                           color: "#0f00ff",377                           width: 2378                       },379                       event: {380                           click: "clickme"381                       }382                   }}383              ], "outline element test 7");384    var outlineTest8 = "<b><outline  width =2 color=#0f00ff><on click='clickme'><u>hello</u></on></outline></b>";385    deepEqual(parser.parse(outlineTest8),386              [387                  {text: "hello",388                   style: {389                       bold: true,390                       underline: true,391                       outline: {392                           color: "#0f00ff",393                           width: 2394                       },395                       event: {396                           click: "clickme"397                       }398                   }}399              ], "outline element test 8");400    var invalidOutlineTest1 = "<outline  width=2 color #0f00ff click='clickme'>hello</outline>";401    deepEqual(parser.parse(invalidOutlineTest1),402              [403                  {text: "hello",404                   style: {405                       outline: {406                           color: "#ffffff",407                           width: 2408                       },409                       event: {410                           click: "clickme"411                       }412                   }}413              ], "invalid outline element test 1");414    var invalidOutlineTest2 = "<outline  width 2 color #0f00ff click 'clickme'>hello</outline>";415    deepEqual(parser.parse(invalidOutlineTest2),416              [417                  {text: "hello",418                   style: {419                       outline: {420                           color: "#ffffff",421                           width: 1422                       }423                   }}424              ], "invalid outline element test 2");425    var invalidOutlineTest3 = "<outilne  width 2 color #0f00ff click 'clickme'>hello</outline>";426    deepEqual(parser.parse(invalidOutlineTest3),427              [428                  {text: "hello",429                   style: {}}430              ], "invalid outline element test 3");...

Full Screen

Full Screen

test.js

Source:test.js Github

copy

Full Screen

1/* globals suite test */2var assert = require('assert')3var flat = require('../index')4var flatten = flat.flatten5var unflatten = flat.unflatten6var primitives = {7  String: 'good morning',8  Number: 1234.99,9  Boolean: true,10  Date: new Date(),11  null: null,12  undefined: undefined13}14suite('Flatten Primitives', function () {15  Object.keys(primitives).forEach(function (key) {16    var value = primitives[key]17    test(key, function () {18      assert.deepEqual(flatten({19        hello: {20          world: value21        }22      }), {23        'hello.world': value24      })25    })26  })27})28suite('Unflatten Primitives', function () {29  Object.keys(primitives).forEach(function (key) {30    var value = primitives[key]31    test(key, function () {32      assert.deepEqual(unflatten({33        'hello.world': value34      }), {35        hello: {36          world: value37        }38      })39    })40  })41})42suite('Flatten', function () {43  test('Nested once', function () {44    assert.deepEqual(flatten({45      hello: {46        world: 'good morning'47      }48    }), {49      'hello.world': 'good morning'50    })51  })52  test('Nested twice', function () {53    assert.deepEqual(flatten({54      hello: {55        world: {56          again: 'good morning'57        }58      }59    }), {60      'hello.world.again': 'good morning'61    })62  })63  test('Multiple Keys', function () {64    assert.deepEqual(flatten({65      hello: {66        lorem: {67          ipsum: 'again',68          dolor: 'sit'69        }70      },71      world: {72        lorem: {73          ipsum: 'again',74          dolor: 'sit'75        }76      }77    }), {78      'hello.lorem.ipsum': 'again',79      'hello.lorem.dolor': 'sit',80      'world.lorem.ipsum': 'again',81      'world.lorem.dolor': 'sit'82    })83  })84  test('Custom Delimiter', function () {85    assert.deepEqual(flatten({86      hello: {87        world: {88          again: 'good morning'89        }90      }91    }, {92      delimiter: ':'93    }), {94      'hello:world:again': 'good morning'95    })96  })97  test('Empty Objects', function () {98    assert.deepEqual(flatten({99      hello: {100        empty: {101          nested: { }102        }103      }104    }), {105      'hello.empty.nested': { }106    })107  })108  if (typeof Buffer !== 'undefined') {109    test('Buffer', function () {110      assert.deepEqual(flatten({111        hello: {112          empty: {113            nested: Buffer.from('test')114          }115        }116      }), {117        'hello.empty.nested': Buffer.from('test')118      })119    })120  }121  if (typeof Uint8Array !== 'undefined') {122    test('typed arrays', function () {123      assert.deepEqual(flatten({124        hello: {125          empty: {126            nested: new Uint8Array([1, 2, 3, 4])127          }128        }129      }), {130        'hello.empty.nested': new Uint8Array([1, 2, 3, 4])131      })132    })133  }134  test('Custom Depth', function () {135    assert.deepEqual(flatten({136      hello: {137        world: {138          again: 'good morning'139        }140      },141      lorem: {142        ipsum: {143          dolor: 'good evening'144        }145      }146    }, {147      maxDepth: 2148    }), {149      'hello.world': {150        again: 'good morning'151      },152      'lorem.ipsum': {153        dolor: 'good evening'154      }155    })156  })157  test('Should keep number in the left when object', function () {158    assert.deepEqual(flatten({159      hello: {160        '0200': 'world',161        '0500': 'darkness my old friend'162      }163    }), {164      'hello.0200': 'world',165      'hello.0500': 'darkness my old friend'166    })167  })168})169suite('Unflatten', function () {170  test('Nested once', function () {171    assert.deepEqual({172      hello: {173        world: 'good morning'174      }175    }, unflatten({176      'hello.world': 'good morning'177    }))178  })179  test('Nested twice', function () {180    assert.deepEqual({181      hello: {182        world: {183          again: 'good morning'184        }185      }186    }, unflatten({187      'hello.world.again': 'good morning'188    }))189  })190  test('Multiple Keys', function () {191    assert.deepEqual({192      hello: {193        lorem: {194          ipsum: 'again',195          dolor: 'sit'196        }197      },198      world: {199        greet: 'hello',200        lorem: {201          ipsum: 'again',202          dolor: 'sit'203        }204      }205    }, unflatten({206      'hello.lorem.ipsum': 'again',207      'hello.lorem.dolor': 'sit',208      'world.lorem.ipsum': 'again',209      'world.lorem.dolor': 'sit',210      'world': {greet: 'hello'}211    }))212  })213  test('nested objects do not clobber each other when a.b inserted before a', function () {214    var x = {}215    x['foo.bar'] = {t: 123}216    x['foo'] = {p: 333}217    assert.deepEqual(unflatten(x), {218      foo: {219        bar: {220          t: 123221        },222        p: 333223      }224    })225  })226  test('Custom Delimiter', function () {227    assert.deepEqual({228      hello: {229        world: {230          again: 'good morning'231        }232      }233    }, unflatten({234      'hello world again': 'good morning'235    }, {236      delimiter: ' '237    }))238  })239  test('Overwrite', function () {240    assert.deepEqual({241      travis: {242        build: {243          dir: '/home/travis/build/kvz/environmental'244        }245      }246    }, unflatten({247      travis: 'true',248      travis_build_dir: '/home/travis/build/kvz/environmental'249    }, {250      delimiter: '_',251      overwrite: true252    }))253  })254  test('Messy', function () {255    assert.deepEqual({256      hello: { world: 'again' },257      lorem: { ipsum: 'another' },258      good: {259        morning: {260          hash: {261            key: { nested: {262              deep: { and: { even: {263                deeper: { still: 'hello' }264              } } }265            } }266          },267          again: { testing: { 'this': 'out' } }268        }269      }270    }, unflatten({271      'hello.world': 'again',272      'lorem.ipsum': 'another',273      'good.morning': {274        'hash.key': {275          'nested.deep': {276            'and.even.deeper.still': 'hello'277          }278        }279      },280      'good.morning.again': {281        'testing.this': 'out'282      }283    }))284  })285  suite('Overwrite + non-object values in key positions', function () {286    test('non-object keys + overwrite should be overwritten', function () {287      assert.deepEqual(flat.unflatten({ a: null, 'a.b': 'c' }, {overwrite: true}), { a: { b: 'c' } })288      assert.deepEqual(flat.unflatten({ a: 0, 'a.b': 'c' }, {overwrite: true}), { a: { b: 'c' } })289      assert.deepEqual(flat.unflatten({ a: 1, 'a.b': 'c' }, {overwrite: true}), { a: { b: 'c' } })290      assert.deepEqual(flat.unflatten({ a: '', 'a.b': 'c' }, {overwrite: true}), { a: { b: 'c' } })291    })292    test('overwrite value should not affect undefined keys', function () {293      assert.deepEqual(flat.unflatten({ a: undefined, 'a.b': 'c' }, {overwrite: true}), { a: { b: 'c' } })294      assert.deepEqual(flat.unflatten({ a: undefined, 'a.b': 'c' }, {overwrite: false}), { a: { b: 'c' } })295    })296    test('if no overwrite, should ignore nested values under non-object key', function () {297      assert.deepEqual(flat.unflatten({ a: null, 'a.b': 'c' }), { a: null })298      assert.deepEqual(flat.unflatten({ a: 0, 'a.b': 'c' }), { a: 0 })299      assert.deepEqual(flat.unflatten({ a: 1, 'a.b': 'c' }), { a: 1 })300      assert.deepEqual(flat.unflatten({ a: '', 'a.b': 'c' }), { a: '' })301    })302  })303  suite('.safe', function () {304    test('Should protect arrays when true', function () {305      assert.deepEqual(flatten({306        hello: [307            { world: { again: 'foo' } },308           { lorem: 'ipsum' }309        ],310        another: {311          nested: [{ array: { too: 'deep' } }]312        },313        lorem: {314          ipsum: 'whoop'315        }316      }, {317        safe: true318      }), {319        hello: [320            { world: { again: 'foo' } },321           { lorem: 'ipsum' }322        ],323        'lorem.ipsum': 'whoop',324        'another.nested': [{ array: { too: 'deep' } }]325      })326    })327    test('Should not protect arrays when false', function () {328      assert.deepEqual(flatten({329        hello: [330            { world: { again: 'foo' } },331           { lorem: 'ipsum' }332        ]333      }, {334        safe: false335      }), {336        'hello.0.world.again': 'foo',337        'hello.1.lorem': 'ipsum'338      })339    })340  })341  suite('.object', function () {342    test('Should create object instead of array when true', function () {343      var unflattened = unflatten({344        'hello.you.0': 'ipsum',345        'hello.you.1': 'lorem',346        'hello.other.world': 'foo'347      }, {348        object: true349      })350      assert.deepEqual({351        hello: {352          you: {353            0: 'ipsum',354            1: 'lorem'355          },356          other: { world: 'foo' }357        }358      }, unflattened)359      assert(!Array.isArray(unflattened.hello.you))360    })361    test('Should create object instead of array when nested', function () {362      var unflattened = unflatten({363        'hello': {364          'you.0': 'ipsum',365          'you.1': 'lorem',366          'other.world': 'foo'367        }368      }, {369        object: true370      })371      assert.deepEqual({372        hello: {373          you: {374            0: 'ipsum',375            1: 'lorem'376          },377          other: { world: 'foo' }378        }379      }, unflattened)380      assert(!Array.isArray(unflattened.hello.you))381    })382    test('Should keep the zero in the left when object is true', function () {383      var unflattened = unflatten({384        'hello.0200': 'world',385        'hello.0500': 'darkness my old friend'386      }, {387        object: true388      })389      assert.deepEqual({390        hello: {391          '0200': 'world',392          '0500': 'darkness my old friend'393        }394      }, unflattened)395    })396    test('Should not create object when false', function () {397      var unflattened = unflatten({398        'hello.you.0': 'ipsum',399        'hello.you.1': 'lorem',400        'hello.other.world': 'foo'401      }, {402        object: false403      })404      assert.deepEqual({405        hello: {406          you: ['ipsum', 'lorem'],407          other: { world: 'foo' }408        }409      }, unflattened)410      assert(Array.isArray(unflattened.hello.you))411    })412  })413  if (typeof Buffer !== 'undefined') {414    test('Buffer', function () {415      assert.deepEqual(unflatten({416        'hello.empty.nested': Buffer.from('test')417      }), {418        hello: {419          empty: {420            nested: Buffer.from('test')421          }422        }423      })424    })425  }426  if (typeof Uint8Array !== 'undefined') {427    test('typed arrays', function () {428      assert.deepEqual(unflatten({429        'hello.empty.nested': new Uint8Array([1, 2, 3, 4])430      }), {431        hello: {432          empty: {433            nested: new Uint8Array([1, 2, 3, 4])434          }435        }436      })437    })438  }439})440suite('Arrays', function () {441  test('Should be able to flatten arrays properly', function () {442    assert.deepEqual({443      'a.0': 'foo',444      'a.1': 'bar'445    }, flatten({446      a: ['foo', 'bar']447    }))448  })449  test('Should be able to revert and reverse array serialization via unflatten', function () {450    assert.deepEqual({451      a: ['foo', 'bar']452    }, unflatten({453      'a.0': 'foo',454      'a.1': 'bar'455    }))456  })457  test('Array typed objects should be restored by unflatten', function () {458    assert.equal(459        Object.prototype.toString.call(['foo', 'bar'])460      , Object.prototype.toString.call(unflatten({461        'a.0': 'foo',462        'a.1': 'bar'463      }).a)464    )465  })466  test('Do not include keys with numbers inside them', function () {467    assert.deepEqual(unflatten({468      '1key.2_key': 'ok'469    }), {470      '1key': {471        '2_key': 'ok'472      }473    })474  })...

Full Screen

Full Screen

helloworlddialog.js

Source:helloworlddialog.js Github

copy

Full Screen

1// Copyright 2008 The Closure Library Authors. All Rights Reserved.2//3// Licensed under the Apache License, Version 2.0 (the "License");4// you may not use this file except in compliance with the License.5// You may obtain a copy of the License at6//7//      http://www.apache.org/licenses/LICENSE-2.08//9// Unless required by applicable law or agreed to in writing, software10// distributed under the License is distributed on an "AS-IS" BASIS,11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.12// See the License for the specific language governing permissions and13// limitations under the License.14/**15 * @fileoverview An example of how to write a dialog to be opened by a plugin.16 *17 */18goog.provide('goog.demos.editor.HelloWorldDialog');19goog.provide('goog.demos.editor.HelloWorldDialog.OkEvent');20goog.require('goog.dom.TagName');21goog.require('goog.events.Event');22goog.require('goog.string');23goog.require('goog.ui.editor.AbstractDialog');24goog.require('goog.ui.editor.AbstractDialog.Builder');25goog.require('goog.ui.editor.AbstractDialog.EventType');26// *** Public interface ***************************************************** //27/**28 * Creates a dialog to let the user enter a customized hello world message.29 * @param {goog.dom.DomHelper} domHelper DomHelper to be used to create the30 * dialog's dom structure.31 * @constructor32 * @extends {goog.ui.editor.AbstractDialog}33 */34goog.demos.editor.HelloWorldDialog = function(domHelper) {35  goog.ui.editor.AbstractDialog.call(this, domHelper);36};37goog.inherits(goog.demos.editor.HelloWorldDialog,38              goog.ui.editor.AbstractDialog);39// *** Event **************************************************************** //40/**41 * OK event object for the hello world dialog.42 * @param {string} message Customized hello world message chosen by the user.43 * @constructor44 * @extends {goog.events.Event}45 */46goog.demos.editor.HelloWorldDialog.OkEvent = function(message) {47  this.message = message;48};49goog.inherits(goog.demos.editor.HelloWorldDialog.OkEvent, goog.events.Event);50/**51 * Event type.52 * @type {goog.ui.editor.AbstractDialog.EventType}53 * @override54 */55goog.demos.editor.HelloWorldDialog.OkEvent.prototype.type =56    goog.ui.editor.AbstractDialog.EventType.OK;57/**58 * Customized hello world message chosen by the user.59 * @type {string}60 */61goog.demos.editor.HelloWorldDialog.OkEvent.prototype.message;62// *** Protected interface ************************************************** //63/** @override */64goog.demos.editor.HelloWorldDialog.prototype.createDialogControl = function() {65  var builder = new goog.ui.editor.AbstractDialog.Builder(this);66  /** @desc Title of the hello world dialog. */67  var MSG_HELLO_WORLD_DIALOG_TITLE = goog.getMsg('Add a Hello World message');68  builder.setTitle(MSG_HELLO_WORLD_DIALOG_TITLE).69      setContent(this.createContent_());70  return builder.build();71};72/**73 * Creates and returns the event object to be used when dispatching the OK74 * event to listeners, or returns null to prevent the dialog from closing.75 * @param {goog.events.Event} e The event object dispatched by the wrapped76 *     dialog.77 * @return {goog.demos.editor.HelloWorldDialog.OkEvent} The event object to be78 *     used when dispatching the OK event to listeners.79 * @protected80 * @override81 */82goog.demos.editor.HelloWorldDialog.prototype.createOkEvent = function(e) {83  var message = this.getMessage_();84  if (message &&85      goog.demos.editor.HelloWorldDialog.isValidHelloWorld_(message)) {86    return new goog.demos.editor.HelloWorldDialog.OkEvent(message);87  } else {88    /** @desc Error message telling the user why their message was rejected. */89    var MSG_HELLO_WORLD_DIALOG_ERROR =90        goog.getMsg('Your message must contain the words "hello" and "world".');91    this.dom.getWindow().alert(MSG_HELLO_WORLD_DIALOG_ERROR);92    return null; // Prevents the dialog from closing.93  }94};95// *** Private implementation *********************************************** //96/**97 * Input element where the user will type their hello world message.98 * @type {Element}99 * @private100 */101goog.demos.editor.HelloWorldDialog.prototype.input_;102/**103 * Creates the DOM structure that makes up the dialog's content area.104 * @return {Element} The DOM structure that makes up the dialog's content area.105 * @private106 */107goog.demos.editor.HelloWorldDialog.prototype.createContent_ = function() {108  /** @desc Sample hello world message to prepopulate the dialog with. */109  var MSG_HELLO_WORLD_DIALOG_SAMPLE = goog.getMsg('Hello, world!');110  this.input_ = this.dom.createDom(goog.dom.TagName.INPUT,111      {size: 25, value: MSG_HELLO_WORLD_DIALOG_SAMPLE});112  /** @desc Prompt telling the user to enter a hello world message. */113  var MSG_HELLO_WORLD_DIALOG_PROMPT =114      goog.getMsg('Enter your Hello World message');115  return this.dom.createDom(goog.dom.TagName.DIV,116                            null,117                            [MSG_HELLO_WORLD_DIALOG_PROMPT, this.input_]);118};119/**120 * Returns the hello world message currently typed into the dialog's input.121 * @return {?string} The hello world message currently typed into the dialog's122 *     input, or null if called before the input is created.123 * @private124 */125goog.demos.editor.HelloWorldDialog.prototype.getMessage_ = function() {126  return this.input_ && this.input_.value;127};128/**129 * Returns whether or not the given message contains the strings "hello" and130 * "world". Case-insensitive and order doesn't matter.131 * @param {string} message The message to be checked.132 * @return {boolean} Whether or not the given message contains the strings133 *     "hello" and "world".134 * @private135 */136goog.demos.editor.HelloWorldDialog.isValidHelloWorld_ = function(message) {137  message = message.toLowerCase();138  return goog.string.contains(message, 'hello') &&139         goog.string.contains(message, 'world');...

Full Screen

Full Screen

index.js

Source:index.js Github

copy

Full Screen

1/**2    Copyright 2014-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved.3    Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with the License. A copy of the License is located at4        http://aws.amazon.com/apache2.0/5    or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.6*/7/**8 * This simple sample has no external dependencies or session management, and shows the most basic9 * example of how to create a Lambda function for handling Alexa Skill requests.10 *11 * Examples:12 * One-shot model:13 *  User: "Alexa, tell Hello World to say hello"14 *  Alexa: "Hello World!"15 */16/**17 * App ID for the skill18 */19var APP_ID = "amzn1.ask.skill.c126aa6d-8be7-4470-8fe5-ce16cc4832b9";20/**21 * The AlexaSkill prototype and helper functions22 */23var AlexaSkill = require('./AlexaSkill');24var auth = require('./auth');25var graph = require('./graph');26/**27 * HelloWorld is a child of AlexaSkill.28 * To read more about inheritance in JavaScript, see the link below.29 *30 * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Introduction_to_Object-Oriented_JavaScript#Inheritance31 */32var HelloWorld = function () {33    AlexaSkill.call(this, APP_ID);34};35// Extend AlexaSkill36HelloWorld.prototype = Object.create(AlexaSkill.prototype);37HelloWorld.prototype.constructor = HelloWorld;38HelloWorld.prototype.eventHandlers.onSessionStarted = function (sessionStartedRequest, session) {39    console.log("HelloWorld onSessionStarted requestId: " + sessionStartedRequest.requestId40        + ", sessionId: " + session.sessionId);41    // any initialization logic goes here42};43HelloWorld.prototype.eventHandlers.onLaunch = function (launchRequest, session, response) {44    console.log("HelloWorld onLaunch requestId: " + launchRequest.requestId + ", sessionId: " + session.sessionId);45    var speechOutput = "Welcome to the Alexa Skills Kit, you can say hello";46    var repromptText = "You can say hello";47    response.ask(speechOutput, repromptText);48};49HelloWorld.prototype.eventHandlers.onSessionEnded = function (sessionEndedRequest, session) {50    console.log("HelloWorld onSessionEnded requestId: " + sessionEndedRequest.requestId51        + ", sessionId: " + session.sessionId);52    // any cleanup logic goes here53};54function CreateCalendarEvent(intent, session, response) {55}56HelloWorld.prototype.intentHandlers = {57    // register custom intent handlers58    "HelloWorldIntent": function (intent, session, response) {59        response.tellWithCard("Hello World!", "Hello World", "Hello World!");60    },61    "AddCalendarItemIntent": function (intent, session, response) {62        // Get an access token for the app.63        auth.getAccessToken().then(function (token) {64            // Get all of the users in the tenant.65            graph.getUsers(token)66                .then(function (users) {67                    // Create an event on each user's calendar.68                    var result = graph.createEvent(token, users, response);69                }, function (error) {70                    var errorMsg = '>>> Error getting users: ' + error;71                    console.error(errorMsg);72                    response.tellWithCard("Error:" + errorMsg, "Hello World", "Hello World!");        73                });74        }, function (error) {75        var errorMsg = '>>> Error getting access token: ' + error;76        console.error(errorMsg);77        response.tellWithCard("Error:" + errorMsg, "Hello World", "Hello World!");        78        });79    },80    "AddListItemIntent": function (intent, session, response) {81        // Get an access token for the app.82        auth.getAccessToken().then(function (token) {83            var result = graph.createItem(84                token, 85                function(reqError) {86                    if(reqError) {87                        response.tellWithCard("Error:" + reqError, "Hello World", "Hello World!");88                    }89                    else {90                        response.tellWithCard("List Item Created", "Hello World", "Hello World!");91                    }92                });93        }, function (error) {94        var errorMsg = '>>> Error getting access token: ' + error;95        console.error(errorMsg);96        response.tellWithCard("Error:" + errorMsg, "Hello World", "Hello World!");        97        });98    },99    "AMAZON.HelpIntent": function (intent, session, response) {100        response.ask("You can say hello to me!", "You can say hello to me!");101    }102};103// Create the handler that responds to the Alexa Request.104exports.handler = function (event, context) {105    // Create an instance of the HelloWorld skill.106    var helloWorld = new HelloWorld();107    helloWorld.execute(event, context);...

Full Screen

Full Screen

capitalize.test.js

Source:capitalize.test.js Github

copy

Full Screen

1import assert from 'assert';2import '../../src';3describe('capitalize', () => {4    describe('No Params', () => {5        it('length 0', () => {6            assert.strictEqual("".capitalize(), "");7        });8        it('1 word', () => {9            assert.strictEqual("hello".capitalize(), "Hello");10        });11        it('already capitalized', () => {12            assert.strictEqual("Hello".capitalize(), "Hello");13        });14         it('2 word', () => {15            assert.strictEqual("hello world".capitalize(), "Hello world");16        });17        it('already capitalized', () => {18            assert.strictEqual("Hello world".capitalize(), "Hello world");19        });20    });21    describe('Splitter', () => {22        it('length 0', () => {23            assert.strictEqual("".capitalize(/ /g), "");24        });25        it('length 0 - string splitter', () => {26            assert.strictEqual("".capitalize(" "), "");27        });28        it('1 word', () => {29            assert.strictEqual("hello".capitalize(/ /g), "Hello");30        });31        it('1 word - string splitter', () => {32            assert.strictEqual("hello".capitalize(" "), "Hello");33        });34        it('already capitalized', () => {35            assert.strictEqual("Hello".capitalize(/ /g), "Hello");36        });37        it('already capitalized - string splitter', () => {38            assert.strictEqual("Hello".capitalize(" "), "Hello");39        });40        it('string splitter', () => {41            assert.strictEqual("Hello    world".capitalize("  "), "Hello    World");42        });43        it('regexp flags', () => {44            assert.strictEqual("Hello world".capitalize(/O/i), "Hello woRld");45        });46        it('2 word', () => {47            assert.strictEqual("hello world".capitalize(/ /g), "Hello World");48        });49        it('already capitalized', () => {50            assert.strictEqual("Hello World".capitalize(/ /g), "Hello World");51        });52        it('middle split', () => {53            assert.strictEqual("Hello world".capitalize(/o/g), "Hello woRld");54        });55        it('different characters split', () => {56            assert.strictEqual("Hello world".capitalize(/[eo]/g), "HeLlo woRld");57        });58        it('last character', () => {59            assert.strictEqual("Hello world".capitalize(/d/g), "Hello world");60        });61        it('empty segments', () => {62            assert.strictEqual("Hello world".capitalize(/l/g), "HellO worlD");63        });64        it('long splitter', () => {65            assert.strictEqual("Hello world".capitalize(/wor/g), "Hello worLd");66        });67    });68     describe('Splitter + Joiner', () => {69        it('length 0', () => {70            assert.strictEqual("".capitalize(/ /g, "-"), "");71        });72        it('1 word', () => {73            assert.strictEqual("hello".capitalize(/ /g, "-"), "Hello");74        });75        it('already capitalized', () => {76            assert.strictEqual("Hello".capitalize(/ /g, "-"), "Hello");77        });78        it('2 word', () => {79            assert.strictEqual("hello world".capitalize(/ /g, "-"), "Hello-World");80        });81        it('already capitalized', () => {82            assert.strictEqual("Hello World".capitalize(/ /g, "-"), "Hello-World");83        });84        it('middle split', () => {85            assert.strictEqual("Hello world".capitalize(/o/g, "-"), "Hell- w-Rld");86        });87         it('different characters split', () => {88            assert.strictEqual("Hello world".capitalize(/[eo]/g, "-"), "H-Ll- w-Rld");89        });90        it('last character', () => {91            assert.strictEqual("Hello world".capitalize(/d/g, "-"), "Hello worl-");92        });93        it('empty segments', () => {94            assert.strictEqual("Hello world".capitalize(/l/g, "-"), "He--O wor-D");95        });96        it('long splitter, short joiner', () => {97            assert.strictEqual("Hello world".capitalize(/wor/g, "-"), "Hello -Ld");98        });99        it('short splitter, long joiner', () => {100            assert.strictEqual("Hello world".capitalize(/ /g, "-ASDF-"), "Hello-ASDF-World");101        });102        it('new lines', () => {103            assert.strictEqual("Hello\nworld".capitalize(/\n/, " "), "Hello World");104        });105        it('join by empty string', () => {106            assert.strictEqual("Hello world".capitalize(" ", ""), "HelloWorld");107        });108        it('join by 0', () => {109            assert.strictEqual("hello world".capitalize(" ", 0), "Hello0World");110        });111        it('join by false', () => {112            assert.strictEqual("hello world".capitalize(" ", false), "HellofalseWorld");113        });114    });...

Full Screen

Full Screen

BASE.web.PathResolver.js

Source:BASE.web.PathResolver.js Github

copy

Full Screen

1var assert = require("assert");2require("../BASE.js");3BASE.require.loader.setRoot("./");4BASE.require([5    "BASE.web.PathResolver"6], function () {7    8    var PathResolver = BASE.web.PathResolver;9    10    exports["BASE.web.PathResolver: Linux path test."] = function () {11        12        var directory = "/home/users";13        14        var directoryResolve = new PathResolver(directory);15        var directoryResolve2 = new PathResolver(directory);16        var directoryResolve3 = new PathResolver(directory);17        var directoryResolve4 = new PathResolver(directory);18        var directoryResolve5 = new PathResolver("/home/users/file.jpeg");19        20        var newDirectory = directoryResolve.resolve("./hello there");21        assert.equal(newDirectory, "/home/users/hello there");22        23        var newDirectory2 = directoryResolve2.resolve("../hello there");24        assert.equal(newDirectory2, "/home/hello there");25        26        var newDirectory3 = directoryResolve3.resolve("../../hello there");27        assert.equal(newDirectory3, "/hello there");28        29        var newDirectory4 = directoryResolve4.resolve("/hello there");30        assert.equal(newDirectory4, "/hello there");31        var newDirectory5 = directoryResolve5.resolve("./hello there");32        assert.equal(newDirectory5, "/home/users/hello there");33    };34    35    exports["BASE.web.PathResolver: Url path test."] = function () {36        37        var directory = "https://google.com/home/users";38        39        var directoryResolve = new PathResolver(directory);40        var directoryResolve2 = new PathResolver(directory);41        var directoryResolve3 = new PathResolver(directory);42        var directoryResolve4 = new PathResolver(directory);43        var directoryResolve5 = new PathResolver(directory +"/file.jpeg");44        45        var newDirectory = directoryResolve.resolve("./hello there");46        assert.equal(newDirectory, "https://google.com/home/users/hello there");47        48        var newDirectory2 = directoryResolve2.resolve("./../hello there");49        assert.equal(newDirectory2, "https://google.com/home/hello there");50        51        var newDirectory3 = directoryResolve3.resolve("../../hello there");52        assert.equal(newDirectory3, "https://google.com/hello there");53        54        var newDirectory4 = directoryResolve4.resolve("/hello there");55        assert.equal(newDirectory4, "/hello there");56        57        var newDirectory5 = directoryResolve5.resolve("./hello there");58        assert.equal(newDirectory5, "https://google.com/home/users/hello there");59    };60    61    62    exports["BASE.web.PathResolver: Windows path test."] = function () {63        64        var directory = "C:\\Home\\Users";65        66        var windowsConfig = {67            folderDelimiter: "\\"68        };69        70        var directoryResolve = new PathResolver(directory, windowsConfig);71        var directoryResolve2 = new PathResolver(directory, windowsConfig);72        var directoryResolve3 = new PathResolver(directory, windowsConfig);73        var directoryResolve4 = new PathResolver(directory, windowsConfig);74        var directoryResolve5 = new PathResolver(directory, windowsConfig);75        var directoryResolve6 = new PathResolver(directory, windowsConfig);76        77        var newDirectory = directoryResolve.resolve(".\\hello there");78        assert.equal(newDirectory, "C:\\Home\\Users\\hello there");79        80        var newDirectory2 = directoryResolve2.resolve("..\\hello there");81        assert.equal(newDirectory2, "C:\\Home\\hello there");82        83        var newDirectory3 = directoryResolve3.resolve("..\\..\\hello there");84        assert.equal(newDirectory3, "C:\\hello there");85        86        var newDirectory4 = directoryResolve4.resolve("..\\..\\..\\hello there");87        assert.equal(newDirectory4, "\\hello there");88        89        var newDirectory5 = directoryResolve5.resolve("\\hello there");90        assert.equal(newDirectory5, "\\hello there");91        var newDirectory6 = directoryResolve6.resolve("D:\\hello there");92        assert.equal(newDirectory6, "D:\\hello there");93    };...

Full Screen

Full Screen

summernote-ext-hello.js

Source:summernote-ext-hello.js Github

copy

Full Screen

1(function (factory) {2  /* global define */3  if (typeof define === 'function' && define.amd) {4    // AMD. Register as an anonymous module.5    define(['jquery'], factory);6  } else {7    // Browser globals: jQuery8    factory(window.jQuery);9  }10}(function ($) {11  // template12  var tmpl = $.summernote.renderer.getTemplate();13  /**14   * @class plugin.hello 15   * 16   * Hello Plugin  17   */18  $.summernote.addPlugin({19    /** @property {String} name name of plugin */20    name: 'hello',21    /** 22     * @property {Object} buttons 23     * @property {Function} buttons.hello   function to make button24     * @property {Function} buttons.helloDropdown   function to make button25     * @property {Function} buttons.helloImage   function to make button26     */27    buttons: { // buttons28      hello: function (lang, options) {29        return tmpl.iconButton(options.iconPrefix + 'header', {30          event : 'hello',31          title: 'hello',32          hide: true33        });34      },35      helloDropdown: function (lang, options) {36        var list = '<li><a data-event="helloDropdown" href="#" data-value="summernote">summernote</a></li>';37        list += '<li><a data-event="helloDropdown" href="#" data-value="codemirror">Code Mirror</a></li>';38        var dropdown = '<ul class="dropdown-menu">' + list + '</ul>';39        return tmpl.iconButton(options.iconPrefix + 'header', {40          title: 'hello',41          hide: true,42          dropdown : dropdown43        });44      },45      helloImage : function (lang, options) {46        return tmpl.iconButton(options.iconPrefix + 'file-image-o', {47          event : 'helloImage',48          title: 'helloImage',49          hide: true50        });51      }52    },53    /**54     * @property {Object} events 55     * @property {Function} events.hello  run function when button that has a 'hello' event name  fires click56     * @property {Function} events.helloDropdown run function when button that has a 'helloDropdown' event name  fires click57     * @property {Function} events.helloImage run function when button that has a 'helloImage' event name  fires click58     */59    events: { // events60      hello: function (event, editor, layoutInfo) {61        // Get current editable node62        var $editable = layoutInfo.editable();63        // Call insertText with 'hello'64        editor.insertText($editable, 'hello ');65      },66      helloDropdown: function (event, editor, layoutInfo, value) {67        // Get current editable node68        var $editable = layoutInfo.editable();69        // Call insertText with 'hello'70        editor.insertText($editable, 'hello ' + value + '!!!!');71      },72      helloImage : function (event, editor, layoutInfo) {73        var $editable = layoutInfo.editable();74        var img = $('<img src="http://upload.wikimedia.org/wikipedia/commons/b/b0/NewTux.svg" />');75        editor.insertNode($editable, img[0]);76      }77    }78  });...

Full Screen

Full Screen

hello_world_test.spec.js

Source:hello_world_test.spec.js Github

copy

Full Screen

1var HelloWorld = require('./hello_world');2describe('Hello World', function() {3  var helloWorld = new HelloWorld();4  it('says hello world with no name', function() {5    expect(helloWorld.hello('')).toEqual('Hello, World!');6  });7  xit('says hello to bob', function() {8    expect(helloWorld.hello('Bob')).toEqual('Hello, Bob!');9  });10  xit('says hello to sally', function() {11    expect(helloWorld.hello('Sally')).toEqual('Hello, Sally!');12  });...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var CypressTest = require('cypresstest');2var test = new CypressTest();3test.Hello();4function CypressTest() {5    this.Hello = function () {6        console.log("Hello from CypressTest");7    }8}9module.exports = CypressTest;10var http = require('http');11http.createServer(function (req, res) {12  res.writeHead(200, {'Content-Type': 'text/html'});13  res.end('Hello World!');14}).listen(8080);15The following example shows how to create a new file using the writeFile() method:16var http = require('http');17var fs = require('fs');18http.createServer(function (req, res) {19  fs.writeFile('mynewfile3.txt', 'Hello content!', function (err) {20    if (err) throw err;21    console.log('Saved!');22  });23}).listen(8080);24var http = require('http');25var fs = require('fs');26http.createServer(function (req, res) {27  fs.open('mynewfile4.txt', 'w', function (err, file) {28    if (err) throw err;

Full Screen

Using AI Code Generation

copy

Full Screen

1cy.hello();2cy.bye();3Cypress.Commands.add('hello', () => {4    cy.log('Hello');5});6Cypress.Commands.add('bye', () => {7    cy.log('Bye');8});9Cypress.Commands.add('hello', () => {10    cy.log('Hello');11});12Cypress.Commands.add('bye', () => {13    cy.log('Bye');14});15Cypress.Commands.add('hello', () => {16    cy.log('Hello');17});18Cypress.Commands.add('bye', () => {19    cy.log('Bye');20});21Cypress.Commands.add('hello', () => {22    cy.log('Hello');23});24Cypress.Commands.add('bye', () => {25    cy.log('Bye');26});27Cypress.Commands.add('hello', () => {28    cy.log('Hello');29});30Cypress.Commands.add('bye', () => {31    cy.log('Bye');32});33Cypress.Commands.add('hello', () => {34    cy.log('Hello');35});36Cypress.Commands.add('bye', () => {37    cy.log('Bye');38});39Cypress.Commands.add('hello', () => {40    cy.log('Hello');41});42Cypress.Commands.add('bye', () => {43    cy.log('Bye');44});45Cypress.Commands.add('hello', () => {46    cy.log('Hello');47});

Full Screen

Using AI Code Generation

copy

Full Screen

1Cypress.Commands.add('Hello',() => {2    console.log('Hello Cypress');3});4Cypress.Commands.add('Hello',() => {5    console.log('Hello Cypress');6});7Cypress.Hello();8Cypress.Commands.add('Hello',() => {9    console.log('Hello Cypress');10});11Cypress.Hello();12Cypress.Commands.add('Hello',() => {13    console.log('Hello Cypress');14});15Cypress.Hello();16Cypress.Commands.add('Hello',() => {17    console.log('Hello Cypress');18});19Cypress.Hello();20Cypress.Commands.add('Hello',() => {21    console.log('Hello Cypress');22});23Cypress.Hello();24Cypress.Commands.add('Hello',() => {25    console.log('Hello Cypress');26});27Cypress.Hello();28Cypress.Commands.add('Hello',() => {29    console.log('Hello Cypress');30});31Cypress.Hello();

Full Screen

Using AI Code Generation

copy

Full Screen

1cy.Hello('Hello World');2Cypress.Commands.add('Hello', (str) => {3  cy.log(str);4});5Cypress.Commands.add() method6Cypress.Commands.overwrite() method7describe('Custom Command Test', () => {8  it('Custom Command Test', () => {9    cy.Hello('Hello World');10    cy.Hello('Hello World');11    cy.Hello('Hello World');12  });13});14Cypress.Commands.add('Hello', (str) => {15  cy.log(str);16});17Cypress.Commands.overwrite('Hello', (originalFn, str) => {18  cy.log(str);19  cy.log(str);20  cy.log(str);21});

Full Screen

Using AI Code Generation

copy

Full Screen

1cy.hello();2cy.bye();3import Cypress from 'cypress';4Cypress.Commands.add('hello', () => {5    console.log('Hello World!');6});7import './commands';8cy.hello();9import Cypress from 'cypress';10Cypress.Commands.add('hello', (name) => {11    console.log('Hello ' + name);12});13import './commands';14cy.hello('John');15import Cypress from 'cypress';16Cypress.Commands.add('hello', (name) => {

Full Screen

Using AI Code Generation

copy

Full Screen

1var hello = require('./hello');2exports.Hello = function(){3console.log('Hello from Cypress!');4}5var hello = require('./hello');6exports.Hello = function(){7if (window.Cypress) {8console.log('Hello from Cypress!');9} else {10console.log('Hello from Browser!');11}12}

Full Screen

Cypress Tutorial

Cypress is a renowned Javascript-based open-source, easy-to-use end-to-end testing framework primarily used for testing web applications. Cypress is a relatively new player in the automation testing space and has been gaining much traction lately, as evidenced by the number of Forks (2.7K) and Stars (42.1K) for the project. LambdaTest’s Cypress Tutorial covers step-by-step guides that will help you learn from the basics till you run automation tests on LambdaTest.

Chapters:

  1. What is Cypress? -
  2. Why Cypress? - Learn why Cypress might be a good choice for testing your web applications.
  3. Features of Cypress Testing - Learn about features that make Cypress a powerful and flexible tool for testing web applications.
  4. Cypress Drawbacks - Although Cypress has many strengths, it has a few limitations that you should be aware of.
  5. Cypress Architecture - Learn more about Cypress architecture and how it is designed to be run directly in the browser, i.e., it does not have any additional servers.
  6. Browsers Supported by Cypress - Cypress is built on top of the Electron browser, supporting all modern web browsers. Learn browsers that support Cypress.
  7. Selenium vs Cypress: A Detailed Comparison - Compare and explore some key differences in terms of their design and features.
  8. Cypress Learning: Best Practices - Take a deep dive into some of the best practices you should use to avoid anti-patterns in your automation tests.
  9. How To Run Cypress Tests on LambdaTest? - Set up a LambdaTest account, and now you are all set to learn how to run Cypress tests.

Certification

You can elevate your expertise with end-to-end testing using the Cypress automation framework and stay one step ahead in your career by earning a Cypress certification. Check out our Cypress 101 Certification.

YouTube

Watch this 3 hours of complete tutorial to learn the basics of Cypress and various Cypress commands with the Cypress testing at LambdaTest.

Run Cypress 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