Best JavaScript code snippet using pact-foundation-pact
test-html-text-parser.js
Source:test-html-text-parser.js
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<world</size>";145 deepEqual(parser.parse(testLessThan),146 [ {text: "hello<world",147 style: {148 size: 20149 }150 }],151 "The < symbol should be correctly escaped.");152 var testGreatThan = "<on click='event1'> hello>world</on>";153 deepEqual(parser.parse(testGreatThan),154 [{text: " hello>world",155 style: {156 event: {157 click: 'event1'158 }159 }}],160 "The > symbol should be correctly escaped.");161 var testAmp = "<color=#0xff00>hello&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"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'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");...
test.js
Source:test.js
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 })...
helloworlddialog.js
Source:helloworlddialog.js
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');...
index.js
Source:index.js
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);...
capitalize.test.js
Source:capitalize.test.js
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 });...
BASE.web.PathResolver.js
Source:BASE.web.PathResolver.js
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 };...
summernote-ext-hello.js
Source:summernote-ext-hello.js
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 });...
hello_world_test.spec.js
Source:hello_world_test.spec.js
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 });...
Using AI Code Generation
1const { Hello } = require('pact-foundation-pact');2console.log(Hello());3const { Hello } = require('pact-foundation-pact');4console.log(Hello());5const { Hello } = require('pact-foundation-pact');6console.log(Hello());7const { Hello } = require('pact-foundation-pact');8console.log(Hello());9const { Hello } = require('pact-foundation-pact');10console.log(Hello());11const { Hello } = require('pact-foundation-pact');12console.log(Hello());13const { Hello } = require('pact-foundation-pact');14console.log(Hello());15const { Hello } = require('pact-foundation-pact');16console.log(Hello());17const { Hello } = require('pact-foundation-pact');18console.log(Hello());19const { Hello } = require('pact-foundation-pact');20console.log(Hello());21const { Hello } = require('pact-foundation-pact');22console.log(Hello());23const { Hello } = require('pact-foundation-pact');24console.log(Hello());25const { Hello } = require('pact-foundation-pact');26console.log(Hello());
Using AI Code Generation
1var pact = require('pact-foundation-pact');2var hello = require('./hello');3var expect = require('chai').expect;4describe("Hello", function() {5 it("says hello", function() {6 expect(hello.sayHello()).to.eql("Hello");7 });8});9var pact = require('pact-foundation-pact');10var hello = require('./hello');11var expect = require('chai').expect;12describe("Hello", function() {13 it("says hello", function() {14 expect(hello.sayHello()).to.eql("Hello");15 });16});17var pact = require('pact-foundation-pact');18var hello = require('./hello');19var expect = require('chai').expect;20describe("Hello", function() {21 it("says hello", function() {22 expect(hello.sayHello()).to.eql("Hello");23 });24});25var pact = require('pact-foundation-pact');26var hello = require('./hello');27var expect = require('chai').expect;28describe("Hello", function() {29 it("says hello", function() {30 expect(hello.sayHello()).to.eql("Hello");31 });32});33var pact = require('pact-foundation-pact');34var hello = require('./hello');35var expect = require('chai').expect;36describe("Hello", function() {37 it("says hello", function() {38 expect(hello.sayHello()).to.eql("Hello");39 });40});41var pact = require('pact-foundation
Using AI Code Generation
1var pact = require('pact-foundation/pact');2var hello = pact.Hello();3console.log(hello);4var pact = require('pact-foundation/pact');5var hello = pact.Hello();6console.log(hello);7var pact = require('pact-foundation/pact');8var hello = pact.Hello();9console.log(hello);10var pact = require('pact-foundation/pact');11var hello = pact.Hello();12console.log(hello);13var pact = require('pact-foundation/pact');14var hello = pact.Hello();15console.log(hello);16var pact = require('pact-foundation/pact');17var hello = pact.Hello();18console.log(hello);19var pact = require('pact-foundation/pact');20var hello = pact.Hello();21console.log(hello);22var pact = require('pact-foundation/pact');23var hello = pact.Hello();24console.log(hello);25var pact = require('pact-foundation/pact');26var hello = pact.Hello();27console.log(hello);28var pact = require('pact-foundation/pact');29var hello = pact.Hello();30console.log(hello);31var pact = require('pact-foundation/pact');32var hello = pact.Hello();33console.log(hello);34var pact = require('pact-foundation/pact');
Using AI Code Generation
1var pact = require('pact-foundation-pact');2var Hello = require('Hello');3describe('Hello', function () {4 it('says hello', function () {5 expect(Hello()).toEqual('Hello');6 });7});8var pact = require('pact-foundation-pact');9var Hello = require('Hello');10describe('Hello', function () {11 it('says hello', function () {12 expect(Hello()).toEqual('Hello');13 });14});15"jest": {16 "testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.js$",17 "moduleNameMapper": {18 }19 }
Using AI Code Generation
1var Pact = require("pact-foundation-pact");2var pact = Pact({consumer:"consumer", provider:"provider", port:1234, logLevel:"debug"});3pact.setup().then(function(){4 pact.addInteraction({5 withRequest: {6 headers: {7 }8 },9 willRespondWith: {10 headers: {11 },12 body: [{13 id: Pact.Matchers.somethingLike(1),14 name: Pact.Matchers.somethingLike("Pact")15 }]16 }17 }).then(function(){18 pact.verify().then(function(){19 pact.finalize();20 });21 });22});23 at process._tickCallback (internal/process/next_tick.js:103:7)
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!!