How to use fromJSON method in frisby

Best JavaScript code snippet using frisby

json.ts

Source:json.ts Github

copy

Full Screen

...26 t.equal(float32.toJSON(0), 0);27 t.equal(float32.toJSON(0.5), 0.5);28 t.end();29});30test('primitive.fromJSON()', (t) => {31 const bool = new MuBoolean();32 t.equal(bool.fromJSON(bool.toJSON(false)), false);33 t.equal(bool.fromJSON(bool.toJSON(true)), true);34 const utf8 = new MuUTF8();35 t.equal(utf8.fromJSON(utf8.toJSON('')), '');36 t.equal(utf8.fromJSON(utf8.toJSON('Iñtërnâtiônàlizætiøn☃💩')), 'Iñtërnâtiônàlizætiøn☃💩');37 const float32 = new MuFloat32();38 t.equal(float32.fromJSON(float32.toJSON(0)), 0);39 t.equal(float32.fromJSON(float32.toJSON(0.5)), 0.5);40 t.end();41});42test('primitive.fromJSON() with bad input', (t) => {43 const bool = new MuBoolean(true);44 t.equal(bool.fromJSON(<any>undefined), true);45 t.equal(bool.fromJSON(<any>null), true);46 t.equal(bool.fromJSON(<any>0), true);47 t.equal(bool.fromJSON(<any>''), true);48 t.equal(bool.fromJSON(<any>'false'), true);49 t.equal(bool.fromJSON(<any>[]), true);50 const float32 = new MuFloat32(0.5);51 t.equal(float32.fromJSON(<any>undefined), 0.5);52 t.equal(float32.fromJSON(<any>null), 0.5);53 t.equal(float32.fromJSON(<any>false), 0.5);54 t.equal(float32.fromJSON(<any>true), 0.5);55 t.equal(float32.fromJSON(<any>'1e3'), 0.5);56 t.equal(float32.fromJSON(<any>'1.1.1'), 0.5);57 t.equal(float32.fromJSON(<any>{}), 0.5);58 const utf8 = new MuUTF8('Iñtërnâtiônàlizætiøn☃💩');59 t.equal(utf8.fromJSON(<any>undefined), 'Iñtërnâtiônàlizætiøn☃💩');60 t.equal(utf8.fromJSON(<any>null), 'Iñtërnâtiônàlizætiøn☃💩');61 t.equal(utf8.fromJSON(<any>false), 'Iñtërnâtiônàlizætiøn☃💩');62 t.equal(utf8.fromJSON(<any>123), 'Iñtërnâtiônàlizætiøn☃💩');63 t.equal(utf8.fromJSON(<any>{}), 'Iñtërnâtiônàlizætiøn☃💩');64 t.end();65});66test('array.toJSON()', (t) => {67 const array = new MuArray(new MuFloat32(), Infinity);68 const a = array.alloc();69 t.notEqual(array.toJSON(a), a);70 t.deepEqual(array.toJSON(a), a);71 for (let i = 0; i < 1e3; ++i) {72 a.push(randFloat32());73 }74 t.notEqual(array.toJSON(a), a);75 t.deepEqual(array.toJSON(a), a);76 t.end();77});78test('array.fromJSON()', (t) => {79 const array = new MuArray(new MuFloat32(), Infinity);80 const a = array.alloc();81 const j1 = array.toJSON(a);82 t.notEqual(array.fromJSON(j1), j1);83 t.deepEqual(array.fromJSON(j1), a);84 for (let i = 0; i < 1e3; ++i) {85 a.push(randFloat32());86 }87 const j2 = array.toJSON(a);88 t.notEqual(array.fromJSON(j2), j2);89 t.deepEqual(array.fromJSON(j2), a);90 t.end();91});92test('array.toJSON()', (t) => {93 const vector = new MuVector(new MuFloat32(), 1e3);94 const array = new MuArray(vector, Infinity);95 const a1 = new Array(10);96 const a2 = new Array(a1.length);97 for (let i = 0; i < a1.length; ++i) {98 a1[i] = vector.alloc();99 a2[i] = new Array(vector.dimension);100 for (let j = 0; j < a1[i].length; ++j) {101 a2[i][j] = a1[i][j] = randFloat32();102 }103 }104 t.deepEqual(array.toJSON(a1), a2);105 t.end();106});107test('array.fromJSON()', (t) => {108 const vector = new MuVector(new MuFloat32(), 1e3);109 const array = new MuArray(vector, Infinity);110 const a1 = new Array(10);111 for (let i = 0; i < a1.length; ++i) {112 a1[i] = vector.alloc();113 for (let j = 0; j < a1[i].length; ++j) {114 a1[i][j] = randFloat32();115 }116 }117 const a2 = array.fromJSON(array.toJSON(a1));118 t.equal(a2.length, a1.length);119 t.true(a2[0] instanceof Float32Array);120 t.deepEqual(a2, a1);121 t.end();122});123test('sorted.toJSON()', (t) => {124 const sorted = new MuSortedArray(new MuFloat32(), Infinity);125 const s = sorted.alloc();126 t.notEqual(sorted.toJSON(s), s);127 t.deepEqual(sorted.toJSON(s), s);128 for (let i = 0; i < 1e3; ++i) {129 s.push(randFloat32());130 }131 t.notEqual(sorted.toJSON(s), s);132 t.deepEqual(sorted.toJSON(s), s);133 t.end();134});135test('sorted.fromJSON()', (t) => {136 const sorted = new MuSortedArray(new MuFloat32(), Infinity);137 const s = sorted.alloc();138 const j1 = sorted.toJSON(s);139 t.notEqual(sorted.fromJSON(j1), j1);140 t.deepEqual(sorted.fromJSON(j1), s);141 for (let i = 0; i < 1e3; ++i) {142 s.push(randFloat32());143 }144 const j2 = sorted.toJSON(s);145 t.notEqual(sorted.fromJSON(j2), j2);146 t.deepEqual(sorted.fromJSON(j2), s);147 t.end();148});149test('struct.toJSON()', (t) => {150 const float32 = new MuFloat32();151 const vector = new MuVector(float32, 1e3);152 const struct = new MuStruct({153 f: float32,154 v: vector,155 });156 const s = struct.alloc();157 t.true(Array.isArray(struct.toJSON(s).v));158 t.deepEqual(struct.toJSON(s), {159 f: float32.toJSON(float32.alloc()),160 v: vector.toJSON(vector.alloc()),161 });162 const o:any = {};163 o.f = s.f = randFloat32();164 o.v = new Array(s.v.length);165 for (let i = 0; i < s.v.length; ++i) {166 o.v[i] = s.v[i] = randFloat32();167 }168 t.deepEqual(struct.toJSON(s), o);169 t.end();170});171test('struct.fromJSON()', (t) => {172 const float32 = new MuFloat32();173 const vector = new MuVector(float32, 1e3);174 const struct = new MuStruct({175 f: float32,176 v: vector,177 });178 const s1 = struct.alloc();179 s1.f = randFloat32();180 for (let i = 0; i < s1.v.length; ++i) {181 s1.v[i] = randFloat32();182 }183 const s2 = struct.fromJSON(struct.toJSON(s1));184 t.true(s2.v instanceof Float32Array);185 t.deepEqual(s2, s1);186 t.end();187});188test('union.toJSON()', (t) => {189 const union = new MuUnion(190 {191 f: new MuFloat32(),192 v: new MuVector(new MuFloat32(), 1e3),193 },194 'f',195 );196 const u = union.alloc();197 u.data = randFloat32();198 t.notEqual(union.toJSON(u), u);199 t.deepEqual(union.toJSON(u), u);200 u.type = 'v';201 u.data = union.muData[u.type].alloc();202 const a = new Array(u.data.length);203 for (let i = 0; i < u.data.length; ++i) {204 a[i] = u.data[i] = randFloat32();205 }206 t.true(Array.isArray(union.toJSON(u).data));207 t.deepEqual(union.toJSON(u), {208 type: u.type,209 data: a,210 });211 t.end();212});213test('union.fromJSON()', (t) => {214 const union = new MuUnion(215 {216 f: new MuFloat32(),217 v: new MuVector(new MuFloat32(), 1e3),218 },219 'v',220 );221 const u1 = union.alloc();222 for (let i = 0; i < 1e3; ++i) {223 u1.data[i] = randFloat32();224 }225 const u2 = union.fromJSON(union.toJSON(u1));226 t.true(u2.data instanceof Float32Array);227 t.deepEqual(u2, u1);228 t.end();229});230test('bytes.toJSON()', (t) => {231 const bytes = new MuBytes();232 const a = new Array(100);233 for (let i = 0; i < a.length; ++i) {234 a[i] = randUint8();235 }236 const b = new Uint8Array(a);237 t.deepEqual(bytes.toJSON(b), a);238 t.end();239});240test('bytes.fromJSON()', (t) => {241 const bytes = new MuBytes();242 const b = new Uint8Array(100);243 for (let i = 0; i < b.length; ++i) {244 b[i] = randUint8();245 }246 t.deepEqual(bytes.fromJSON(bytes.toJSON(b)), b);247 t.end();248});249test('dictionary.toJSON()', (t) => {250 const dictionary = new MuDictionary(new MuFloat32(), Infinity);251 const d = dictionary.alloc();252 t.notEqual(dictionary.toJSON(d), d);253 t.deepEqual(dictionary.toJSON(d), d);254 let code = 97;255 for (let i = 0; i < 26; ++i) {256 d[String.fromCharCode(code++)] = randFloat32();257 }258 t.notEqual(dictionary.toJSON(d), d);259 t.deepEqual(dictionary.toJSON(d), d);260 t.end();261});262test('dictionary.fromJSON()', (t) => {263 const dictionary = new MuDictionary(new MuFloat32(), Infinity);264 const d = dictionary.alloc();265 const j1 = dictionary.toJSON(d);266 t.notEqual(dictionary.fromJSON(j1), j1);267 t.deepEqual(dictionary.fromJSON(j1), d);268 let code = 97;269 for (let i = 0; i < 26; ++i) {270 d[String.fromCharCode(code++)] = randFloat32();271 }272 const j2 = dictionary.toJSON(d);273 t.notEqual(dictionary.fromJSON(j2), j2);274 t.deepEqual(dictionary.fromJSON(j2), d);275 t.end();276});277test('vector.toJSON()', (t) => {278 const vector = new MuVector(new MuFloat32(), 1e3);279 const v = vector.alloc();280 const a = new Array(v.length);281 for (let i = 0; i < a.length; ++i) {282 a[i] = v[i] = randFloat32();283 }284 t.deepEqual(vector.toJSON(v), a);285 t.end();286});287test('vector.fromJSON()', (t) => {288 const vector = new MuVector(new MuFloat32(), 1e3);289 const v1 = vector.alloc();290 for (let i = 0; i < v1.length; ++i) {291 v1[i] = randFloat32();292 }293 const v2 = vector.fromJSON(vector.toJSON(v1));294 t.true(v2 instanceof Float32Array);295 t.deepEqual(v2, v1);296 t.end();297});298test('date.toJSON()', (t) => {299 const date = new MuDate();300 const d = date.alloc();301 t.equal(date.toJSON(d), d.toISOString());302 t.end();303});304test('date.fromJSON()', (t) => {305 const date = new MuDate();306 const d = date.alloc();307 t.deepEqual(date.fromJSON(date.toJSON(d)), d);308 t.notEqual(date.fromJSON(date.toJSON(d)), d);309 t.end();310});311test('json.toJSON()', (t) => {312 const json = new MuJSON();313 const o = {};314 t.equal(json.toJSON(o), o);315 t.end();316});317test('json.fromJSON()', (t) => {318 const json = new MuJSON();319 const o = {};320 t.equal(json.fromJSON(json.toJSON(o)), o);321 const o2 = {a: 1234};322 t.equal(json.fromJSON(json.toJSON(o2)), o2);323 t.end();324});325test('option.toJSON()', (t) => {326 const op = new MuOption(new MuFloat32()); // optional primitive327 const of = new MuOption(new MuStruct({op: op})); // optional functor328 t.equal(op.toJSON(undefined), undefined);329 t.equal(op.toJSON(4), 4);330 t.equal(of.toJSON(undefined), undefined);331 t.deepEqual(of.toJSON({op: undefined}), {op: undefined});332 t.deepEqual(of.toJSON({op: 4}), {op: 4});333 t.end();334});335test('option.fromJSON()', (t) => {336 const op = new MuOption(new MuFloat32()); // optional primitive337 const of = new MuOption(new MuStruct({op: op})); // optional functor338 t.equal(op.fromJSON(op.toJSON(undefined)), undefined);339 t.equal(op.fromJSON(op.toJSON(4)), 4);340 t.equal(of.fromJSON(of.toJSON(undefined)), undefined);341 t.deepEqual(of.fromJSON(of.toJSON({op: undefined})), {op: undefined});342 t.deepEqual(of.fromJSON(of.toJSON({op: 4})), {op: 4});343 t.end();344});345test('nonPrimitive.fromJSON() with bad input', (t) => {346 const array = new MuArray(new MuFloat32(1), Infinity, [1, 2, 3]);347 const bytes = new MuBytes(new Uint8Array([1, 2, 3]));348 const date = new MuDate();349 const dictionary = new MuDictionary(new MuFloat32(1), Infinity, { e: Math.E });350 const json = new MuJSON({ foo: 'bar' });351 const sorted = new MuSortedArray(new MuFloat32(1), Infinity, undefined, [0.5, 1, 1.5]);352 const struct = new MuStruct({353 foo: new MuFloat32(1),354 bar: new MuUTF8('bar'),355 });356 const union = new MuUnion({357 f: new MuFloat32(1),358 u: new MuUTF8('foo'),359 }, 'u');360 const vector = new MuVector(new MuFloat32(1), 2);361 t.notEqual(array.fromJSON(<any>undefined), array.identity);362 t.deepEqual(array.fromJSON(<any>undefined), array.identity);363 t.deepEqual(array.fromJSON(<any>null), array.identity);364 t.deepEqual(array.fromJSON(<any>false), array.identity);365 t.deepEqual(array.fromJSON(<any>0), array.identity);366 t.deepEqual(array.fromJSON(<any>'foo'), array.identity);367 t.deepEqual(array.fromJSON(<any>{}), array.identity);368 t.deepEqual(array.fromJSON([ '', {} ]), [1, 1]);369 t.notEqual(bytes.fromJSON(<any>undefined), bytes.identity);370 t.deepEqual(bytes.fromJSON(<any>undefined), bytes.identity);371 t.deepEqual(bytes.fromJSON(<any>null), bytes.identity);372 t.deepEqual(bytes.fromJSON(<any>false), bytes.identity);373 t.deepEqual(bytes.fromJSON(<any>0), bytes.identity);374 t.deepEqual(bytes.fromJSON(<any>'bar'), bytes.identity);375 t.deepEqual(bytes.fromJSON(<any>{}), bytes.identity);376 t.deepEqual(bytes.fromJSON(<any>[ '', {} ]), new Uint8Array([ 0, 0 ]));377 t.notEqual(date.fromJSON(<any>undefined), date.identity);378 t.deepEqual(date.fromJSON(<any>undefined), date.identity);379 t.deepEqual(date.fromJSON(<any>null), date.identity);380 t.deepEqual(date.fromJSON(<any>false), date.identity);381 t.deepEqual(date.fromJSON(<any>'baz'), date.identity);382 t.deepEqual(date.fromJSON(<any>[]), date.identity);383 t.deepEqual(date.fromJSON(<any>{}), date.identity);384 t.notEqual(dictionary.fromJSON(<any>undefined), dictionary.identity);385 t.deepEqual(dictionary.fromJSON(<any>undefined), dictionary.identity);386 t.deepEqual(dictionary.fromJSON(<any>null), dictionary.identity);387 t.deepEqual(dictionary.fromJSON(<any>false), dictionary.identity);388 t.deepEqual(dictionary.fromJSON(<any>0), dictionary.identity);389 t.deepEqual(dictionary.fromJSON(<any>'qux'), dictionary.identity);390 t.deepEqual(dictionary.fromJSON(<any>[]), dictionary.identity);391 t.deepEqual(dictionary.fromJSON(<any>{ a: '', b: {} }), { a: 1, b: 1 });392 t.notEqual(json.fromJSON(<any>undefined), json.identity);393 t.deepEqual(json.fromJSON(<any>undefined), json.identity);394 t.deepEqual(json.fromJSON(<any>null), json.identity);395 t.deepEqual(json.fromJSON(<any>false), json.identity);396 t.deepEqual(json.fromJSON(<any>0), json.identity);397 t.deepEqual(json.fromJSON(<any>'quux'), json.identity);398 t.notEqual(sorted.fromJSON(<any>undefined), sorted.identity);399 t.deepEqual(sorted.fromJSON(<any>undefined), sorted.identity);400 t.deepEqual(sorted.fromJSON(<any>null), sorted.identity);401 t.deepEqual(sorted.fromJSON(<any>false), sorted.identity);402 t.deepEqual(sorted.fromJSON(<any>0), sorted.identity);403 t.deepEqual(sorted.fromJSON(<any>'foo'), sorted.identity);404 t.deepEqual(sorted.fromJSON(<any>{}), sorted.identity);405 t.deepEqual(sorted.fromJSON(<any>[ '', {} ]), [ 1, 1 ]);406 t.notEqual(struct.fromJSON(<any>undefined), struct.identity);407 t.deepEqual(struct.fromJSON(<any>undefined), struct.identity);408 t.deepEqual(struct.fromJSON(<any>null), struct.identity);409 t.deepEqual(struct.fromJSON(<any>false), struct.identity);410 t.deepEqual(struct.fromJSON(<any>0), struct.identity);411 t.deepEqual(struct.fromJSON(<any>'bar'), struct.identity);412 t.deepEqual(struct.fromJSON(<any>[]), struct.identity);413 t.deepEqual(struct.fromJSON({ qux: 'foo', quux: {} }), { foo: 1, bar: 'bar' });414 t.notEqual(union.fromJSON(<any>undefined), union.identity);415 t.deepEqual(union.fromJSON(<any>undefined), union.identity);416 t.deepEqual(union.fromJSON(<any>null), union.identity);417 t.deepEqual(union.fromJSON(<any>false), union.identity);418 t.deepEqual(union.fromJSON(<any>0), union.identity);419 t.deepEqual(union.fromJSON(<any>'baz'), union.identity);420 t.deepEqual(union.fromJSON(<any>{}), union.identity);421 t.deepEqual(union.fromJSON(<any>[]), union.identity);422 t.deepEqual(union.fromJSON(<any>{ type: 'x' }), union.identity);423 t.deepEqual(union.fromJSON(<any>{ type: 'u', data: {} }), { type: 'u', data: 'foo' });424 t.notEqual(vector.fromJSON(<any>undefined), vector.identity);425 t.deepEqual(vector.fromJSON(<any>undefined), vector.identity);426 t.deepEqual(vector.fromJSON(<any>null), vector.identity);427 t.deepEqual(vector.fromJSON(<any>false), vector.identity);428 t.deepEqual(vector.fromJSON(<any>0), vector.identity);429 t.deepEqual(vector.fromJSON(<any>'qux'), vector.identity);430 t.deepEqual(vector.fromJSON(<any>{}), vector.identity);431 t.deepEqual(vector.fromJSON(<any>[ '', {} ]), new Float32Array([ 1, 1 ]));432 t.end();...

Full Screen

Full Screen

_load.js

Source:_load.js Github

copy

Full Screen

1/* eslint-disable */2// Auto-generated by generate-protos script on Mon Feb 28 2022 16:49:13 GMT-0500 (Eastern Standard Time)3const Schema = module.exports;4const {Root} = require('protobufjs');5mergeObjects(Schema, Root.fromJSON(require('./clientmetrics.json')));6mergeObjects(Schema, Root.fromJSON(require('./common.json')));7mergeObjects(Schema, Root.fromJSON(require('./content_manifest.json')));8mergeObjects(Schema, Root.fromJSON(require('./encrypted_app_ticket.json')));9mergeObjects(Schema, Root.fromJSON(require('./enums.json')));10mergeObjects(Schema, Root.fromJSON(require('./enums_clientserver.json')));11mergeObjects(Schema, Root.fromJSON(require('./friends_mobile.json')));12mergeObjects(Schema, Root.fromJSON(require('./htmlmessages.json')));13mergeObjects(Schema, Root.fromJSON(require('./service_accountlinking.json')));14mergeObjects(Schema, Root.fromJSON(require('./service_accountprivacy.json')));15mergeObjects(Schema, Root.fromJSON(require('./service_auction.json')));16mergeObjects(Schema, Root.fromJSON(require('./service_broadcast.json')));17mergeObjects(Schema, Root.fromJSON(require('./service_chat.json')));18mergeObjects(Schema, Root.fromJSON(require('./service_chatroom.json')));19mergeObjects(Schema, Root.fromJSON(require('./service_chatusability.json')));20mergeObjects(Schema, Root.fromJSON(require('./service_clan.json')));21mergeObjects(Schema, Root.fromJSON(require('./service_clanchatrooms.json')));22mergeObjects(Schema, Root.fromJSON(require('./service_clanfaqs.json')));23mergeObjects(Schema, Root.fromJSON(require('./service_clientmetrics.json')));24mergeObjects(Schema, Root.fromJSON(require('./service_cloudconfigstore.json')));25mergeObjects(Schema, Root.fromJSON(require('./service_community.json')));26mergeObjects(Schema, Root.fromJSON(require('./service_econ.json')));27mergeObjects(Schema, Root.fromJSON(require('./service_embedded.json')));28mergeObjects(Schema, Root.fromJSON(require('./service_experimentservice.json')));29mergeObjects(Schema, Root.fromJSON(require('./service_fovasvideo.json')));30mergeObjects(Schema, Root.fromJSON(require('./service_friendmessages.json')));31mergeObjects(Schema, Root.fromJSON(require('./service_friendslist.json')));32mergeObjects(Schema, Root.fromJSON(require('./service_loyaltyrewards.json')));33mergeObjects(Schema, Root.fromJSON(require('./service_news.json')));34mergeObjects(Schema, Root.fromJSON(require('./service_parental.json')));35mergeObjects(Schema, Root.fromJSON(require('./service_player.json')));36mergeObjects(Schema, Root.fromJSON(require('./service_publishedfile.json')));37mergeObjects(Schema, Root.fromJSON(require('./service_quest.json')));38mergeObjects(Schema, Root.fromJSON(require('./service_saleitemrewards.json')));39mergeObjects(Schema, Root.fromJSON(require('./service_steamtv.json')));40mergeObjects(Schema, Root.fromJSON(require('./service_store.json')));41mergeObjects(Schema, Root.fromJSON(require('./service_storebrowse.json')));42mergeObjects(Schema, Root.fromJSON(require('./service_storequery.json')));43mergeObjects(Schema, Root.fromJSON(require('./service_summersale2020.json')));44mergeObjects(Schema, Root.fromJSON(require('./service_useraccount.json')));45mergeObjects(Schema, Root.fromJSON(require('./service_usergameactivity.json')));46mergeObjects(Schema, Root.fromJSON(require('./service_usernews.json')));47mergeObjects(Schema, Root.fromJSON(require('./service_userreviews.json')));48mergeObjects(Schema, Root.fromJSON(require('./service_video.json')));49mergeObjects(Schema, Root.fromJSON(require('./service_voicechat.json')));50mergeObjects(Schema, Root.fromJSON(require('./service_webrtc.json')));51mergeObjects(Schema, Root.fromJSON(require('./steamdatagram_messages_auth.json')));52mergeObjects(Schema, Root.fromJSON(require('./steamdatagram_messages_sdr.json')));53mergeObjects(Schema, Root.fromJSON(require('./steammessages_accounthardware.steamclient.json')));54mergeObjects(Schema, Root.fromJSON(require('./steammessages_appoverview.json')));55mergeObjects(Schema, Root.fromJSON(require('./steammessages_auth.steamclient.json')));56mergeObjects(Schema, Root.fromJSON(require('./steammessages_base.json')));57mergeObjects(Schema, Root.fromJSON(require('./steammessages_broadcast.steamclient.json')));58mergeObjects(Schema, Root.fromJSON(require('./steammessages_chat.steamclient.json')));59mergeObjects(Schema, Root.fromJSON(require('./steammessages_clientlanp2p.json')));60mergeObjects(Schema, Root.fromJSON(require('./steammessages_clientmetrics.steamclient.json')));61mergeObjects(Schema, Root.fromJSON(require('./steammessages_clientnotificationtypes.json')));62mergeObjects(Schema, Root.fromJSON(require('./steammessages_clientserver.json')));63mergeObjects(Schema, Root.fromJSON(require('./steammessages_clientserver_2.json')));64mergeObjects(Schema, Root.fromJSON(require('./steammessages_clientserver_appinfo.json')));65mergeObjects(Schema, Root.fromJSON(require('./steammessages_clientserver_friends.json')));66mergeObjects(Schema, Root.fromJSON(require('./steammessages_clientserver_gameservers.json')));67mergeObjects(Schema, Root.fromJSON(require('./steammessages_clientserver_lbs.json')));68mergeObjects(Schema, Root.fromJSON(require('./steammessages_clientserver_login.json')));69mergeObjects(Schema, Root.fromJSON(require('./steammessages_clientserver_mms.json')));70mergeObjects(Schema, Root.fromJSON(require('./steammessages_clientserver_ucm.json')));71mergeObjects(Schema, Root.fromJSON(require('./steammessages_clientserver_uds.json')));72mergeObjects(Schema, Root.fromJSON(require('./steammessages_clientserver_ufs.json')));73mergeObjects(Schema, Root.fromJSON(require('./steammessages_clientserver_userstats.json')));74mergeObjects(Schema, Root.fromJSON(require('./steammessages_client_objects.json')));75mergeObjects(Schema, Root.fromJSON(require('./steammessages_cloud.steamclient.json')));76mergeObjects(Schema, Root.fromJSON(require('./steammessages_contentsystem.steamclient.json')));77mergeObjects(Schema, Root.fromJSON(require('./steammessages_credentials.steamclient.json')));78mergeObjects(Schema, Root.fromJSON(require('./steammessages_datapublisher.steamclient.json')));79mergeObjects(Schema, Root.fromJSON(require('./steammessages_depotbuilder.steamclient.json')));80mergeObjects(Schema, Root.fromJSON(require('./steammessages_deviceauth.steamclient.json')));81mergeObjects(Schema, Root.fromJSON(require('./steammessages_econ.steamclient.json')));82mergeObjects(Schema, Root.fromJSON(require('./steammessages_friendmessages.steamclient.json')));83mergeObjects(Schema, Root.fromJSON(require('./steammessages_gamenetworking.steamclient.json')));84mergeObjects(Schema, Root.fromJSON(require('./steammessages_gamenetworkingui.json')));85mergeObjects(Schema, Root.fromJSON(require('./steammessages_gamenotifications.steamclient.json')));86mergeObjects(Schema, Root.fromJSON(require('./steammessages_gameservers.steamclient.json')));87mergeObjects(Schema, Root.fromJSON(require('./steammessages_hiddevices.json')));88mergeObjects(Schema, Root.fromJSON(require('./steammessages_inventory.steamclient.json')));89mergeObjects(Schema, Root.fromJSON(require('./steammessages_linkfilter.steamclient.json')));90mergeObjects(Schema, Root.fromJSON(require('./steammessages_lobbymatchmaking.steamclient.json')));91mergeObjects(Schema, Root.fromJSON(require('./steammessages_market.steamclient.json')));92mergeObjects(Schema, Root.fromJSON(require('./steammessages_offline.steamclient.json')));93mergeObjects(Schema, Root.fromJSON(require('./steammessages_parental.steamclient.json')));94mergeObjects(Schema, Root.fromJSON(require('./steammessages_parties.steamclient.json')));95mergeObjects(Schema, Root.fromJSON(require('./steammessages_partnerapps.steamclient.json')));96mergeObjects(Schema, Root.fromJSON(require('./steammessages_player.steamclient.json')));97mergeObjects(Schema, Root.fromJSON(require('./steammessages_publishedfile.steamclient.json')));98mergeObjects(Schema, Root.fromJSON(require('./steammessages_qms.steamclient.json')));99mergeObjects(Schema, Root.fromJSON(require('./steammessages_remoteclient.json')));100mergeObjects(Schema, Root.fromJSON(require('./steammessages_remoteclient_discovery.json')));101mergeObjects(Schema, Root.fromJSON(require('./steammessages_remoteclient_service.steamclient.json')));102mergeObjects(Schema, Root.fromJSON(require('./steammessages_remoteclient_service_messages.json')));103mergeObjects(Schema, Root.fromJSON(require('./steammessages_remoteplay.json')));104mergeObjects(Schema, Root.fromJSON(require('./steammessages_secrets.steamclient.json')));105mergeObjects(Schema, Root.fromJSON(require('./steammessages_shader.steamclient.json')));106mergeObjects(Schema, Root.fromJSON(require('./steammessages_sitelicenseclient.json')));107mergeObjects(Schema, Root.fromJSON(require('./steammessages_siteserverui.json')));108mergeObjects(Schema, Root.fromJSON(require('./steammessages_site_license.steamclient.json')));109mergeObjects(Schema, Root.fromJSON(require('./steammessages_star.steamclient.json')));110mergeObjects(Schema, Root.fromJSON(require('./steammessages_store.steamclient.json')));111mergeObjects(Schema, Root.fromJSON(require('./steammessages_timedtrial.steamclient.json')));112mergeObjects(Schema, Root.fromJSON(require('./steammessages_twofactor.steamclient.json')));113mergeObjects(Schema, Root.fromJSON(require('./steammessages_unified_base.steamclient.json')));114mergeObjects(Schema, Root.fromJSON(require('./steammessages_unified_test.steamclient.json')));115mergeObjects(Schema, Root.fromJSON(require('./steammessages_useraccount.steamclient.json')));116mergeObjects(Schema, Root.fromJSON(require('./steammessages_vac.steamclient.json')));117mergeObjects(Schema, Root.fromJSON(require('./steammessages_video.steamclient.json')));118mergeObjects(Schema, Root.fromJSON(require('./steammessages_virtualcontroller.json')));119mergeObjects(Schema, Root.fromJSON(require('./steammessages_workshop.steamclient.json')));120mergeObjects(Schema, Root.fromJSON(require('./steamnetworkingsockets_messages.json')));121mergeObjects(Schema, Root.fromJSON(require('./steamnetworkingsockets_messages_certs.json')));122mergeObjects(Schema, Root.fromJSON(require('./steamnetworkingsockets_messages_udp.json')));123function mergeObjects(destinationObject, sourceObject) {124 for (let i in sourceObject) {125 if (sourceObject.hasOwnProperty(i)) {126 destinationObject[i] = sourceObject[i];127 }128 }...

Full Screen

Full Screen

BotiumMockRichMessageTypes.js

Source:BotiumMockRichMessageTypes.js Github

copy

Full Screen

1const _ = require('lodash')2class BotiumMockMedia {3 constructor (fromJson = {}) {4 this.mediaUri = fromJson.mediaUri5 this.mimeType = fromJson.mimeType6 this.altText = fromJson.altText7 this.downloadUri = fromJson.downloadUri8 this.buffer = fromJson.buffer9 }10 prettify (indent = 0) {11 const sections = []12 if (this.mediaUri) sections.push(_.truncate(this.mediaUri, { length: 200 }))13 if (this.mimeType) sections.push(this.mimeType)14 if (this.altText) sections.push(this.altText)15 return `${' '.repeat(indent)}MEDIA(${sections.join(' | ')})`16 }17}18class BotiumMockButton {19 constructor (fromJson = {}) {20 this.text = fromJson.text21 this.payload = fromJson.payload22 this.imageUri = fromJson.imageUri23 }24 prettify (indent = 0) {25 const sections = []26 if (this.text) sections.push(this.text)27 if (this.payload) sections.push(_.isObject(this.payload) ? JSON.stringify(this.payload) : this.payload)28 if (this.imageUri) sections.push(_.truncate(this.imageUri, { length: 200 }))29 return `${' '.repeat(indent)}BUTTON(${sections.join(' | ')})`30 }31}32class BotiumMockCard {33 constructor (fromJson = {}) {34 this.text = fromJson.text35 this.subtext = fromJson.subtext36 this.content = fromJson.content37 this.sourceData = fromJson.sourceData38 this.image = (fromJson.image ? new BotiumMockMedia(fromJson.image) : null)39 this.buttons = (fromJson.buttons ? fromJson.buttons.map((a) => new BotiumMockButton(a)) : null)40 this.media = (fromJson.media ? fromJson.media.map((a) => new BotiumMockMedia(a)) : null)41 this.forms = (fromJson.forms ? fromJson.forms.map((a) => new BotiumMockForm(a)) : null)42 this.cards = (fromJson.cards ? fromJson.cards.map((a) => new BotiumMockCard(a)) : null)43 this.sourceData = fromJson.sourceData44 }45 prettify (indent = 0) {46 return this._prettifyLines(this, indent).join('\n')47 }48 _prettifyLines (card, indent) {49 const prettifySafe = (entry, indent) => entry.prettify ? entry.prettify(2) : `${' '.repeat(indent)}<No botium object!>${JSON.stringify(entry)}`50 const sections = []51 if (card.text) sections.push(card.text)52 if (card.subtext) sections.push(card.subtext)53 const lines = []54 if (card.image) lines.push(card.image.prettify(indent + 2))55 if (card.media) lines.push(...card.media.map(m => prettifySafe(m, indent + 2)))56 if (card.buttons) lines.push(...card.buttons.map(b => prettifySafe(b, indent + 2)))57 if (card.forms) lines.push(...card.forms.map(f => prettifySafe(f, indent + 2)))58 if (card.cards) lines.push(...card.cards.map(c => this._prettifyLines(c, indent + 2)))59 return [60 `${' '.repeat(indent)}CARD(${sections.join(' | ')})`,61 ...lines62 ]63 }64}65class BotiumMockForm {66 constructor (fromJson = {}) {67 this.name = fromJson.name68 this.value = fromJson.value69 this.label = fromJson.label70 this.type = fromJson.type71 this.options = (fromJson.options ? fromJson.options.map((c) => new BotiumMockChoice(c)) : null)72 }73 prettify (indent = 0) {74 const sections = []75 if (this.name) sections.push(this.name)76 if (this.label) sections.push(this.label)77 if (this.value) sections.push(this.value)78 return `${' '.repeat(indent)}FORM(${sections.join(' | ')})`79 }80}81class BotiumMockChoice {82 constructor (fromJson = {}) {83 this.title = fromJson.title84 this.value = fromJson.value85 }86}87module.exports = {88 BotiumMockMedia,89 BotiumMockButton,90 BotiumMockCard,91 BotiumMockForm...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var frisby = require('frisby');2var data = {3 { "name": "Ford", "models": ["Fiesta", "Focus", "Mustang"] },4 { "name": "BMW", "models": ["320", "X3", "X5"] },5 { "name": "Fiat", "models": ["500", "Panda"] }6};7frisby.create('Test POST')8 {9 },10 { json: true }11 .expectStatus(201)12 .expectJSON(data)13 .toss();14var frisby = require('frisby');15frisby.create('Test POST')16 {17 },18 { json: true }19 .expectStatus(201)20 .expectJSONTypes({21 })22 .toss();

Full Screen

Using AI Code Generation

copy

Full Screen

1var frisby = require('frisby');2var fs = require('fs');3var data = JSON.parse(fs.readFileSync('data.json', 'utf8'));4frisby.create('Test POST request')5 .expectStatus(200)6 .expectJSON(data)7 .toss();8{

Full Screen

Using AI Code Generation

copy

Full Screen

1var frisby = require('frisby');2frisby.create('test')3.expectStatus(200)4.expectHeaderContains('content-type', 'application/json')5.expectJSONTypes({6})7.toss();8var frisby = require('frisby');9frisby.create('test')10.expectStatus(200)11.expectHeaderContains('content-type', 'application/json')12.expectJSONTypes('?', {13})14.toss();15var frisby = require('frisby');16frisby.create('test')17.expectStatus(200)18.expectHeaderContains('content-type', 'application/json')19.expectJSONTypes({

Full Screen

Using AI Code Generation

copy

Full Screen

1var frisby = require('frisby');2var fs = require('fs');3var data = JSON.parse(fs.readFileSync('data.json', 'utf8'));4data.forEach(function (item) {5 frisby.create(item.name)6 .expectStatus(200)7 .expectHeaderContains('content-type', 'application/json')8 .expectJSONTypes({9 })10 .expectJSON(item)11 .toss();12});13frisby.create('Get all employees')14 .expectStatus(200)15 .expectHeaderContains('content-type', 'application/json')16 .expectJSONTypes('*', {17 })18 .expectJSON(data)19 .toss();20 {

Full Screen

Using AI Code Generation

copy

Full Screen

1var frisby = require('frisby');2var fs = require('fs');3var data = frisby.fromJSON(fs.readFileSync('data.json', 'utf8'));4var data1 = frisby.fromJSON(fs.readFileSync('data1.json', 'utf8'));5var frisby = require('frisby');6var fs = require('fs');7var data = require('./data.json');8var data1 = require('./data1.json');9var frisby = require('frisby');10var data = require('./data.json');11var data1 = require('./data1.json');12var frisby = require('frisby');13var data = require('./data.json');14var data1 = require('./data1.json');15var frisby = require('frisby');16var data = require('./data.json');17var data1 = require('./data1.json');18var frisby = require('frisby');19var data = require('./data.json');20var data1 = require('./data1.json');21var frisby = require('frisby');22var data = require('./data.json');23var data1 = require('./data1.json');24var frisby = require('frisby');25var data = require('./data.json');26var data1 = require('./data1.json');27var frisby = require('frisby');28var data = require('./data.json');29var data1 = require('./data1.json');30var frisby = require('frisby');31var data = require('./data.json');32var data1 = require('./data1.json');33var frisby = require('frisby');34var data = require('./data.json');35var data1 = require('./data1.json');36var frisby = require('frisby');37var data = require('./data.json');38var data1 = require('./data1.json');39var frisby = require('

Full Screen

Using AI Code Generation

copy

Full Screen

1var frisby = require('frisby');2var fs = require('fs');3var obj = JSON.parse(fs.readFileSync('test.json', 'utf8'));4frisby.create('Test POST to /api/v1/contacts')5 .expectStatus(200)6 .expectHeaderContains('content-type', 'application/json')7 .expectJSONTypes({8 })9 .expectJSON({

Full Screen

Using AI Code Generation

copy

Full Screen

1var frisby = require('frisby');2var fs = require('fs');3var data = fs.readFileSync('test.json');4var json = JSON.parse(data);5var value = json['key1'];6console.log(value);7var value = json.key1;8console.log(value);9var value = json.key2['nestedkey1'];10console.log(value);11var value = json.key2.nestedkey1;12console.log(value);13var value = json['key2']['nestedkey1'];14console.log(value);15var value = json['key2'].nestedkey1;16console.log(value);17var value = json.key2['nestedkey1'];18console.log(value);19var value = json['key2'].nestedkey1;20console.log(value);21var value = json['key2']['nestedkey1'];22console.log(value);23var value = json.key2.nestedkey1;24console.log(value);25var value = json['key2'].nestedkey1;26console.log(value);27var value = json['key2']['nestedkey1'];28console.log(value);29var value = json.key2.nestedkey1;30console.log(value);31var value = json['key2'].nestedkey1;32console.log(value);33var value = json['key2']['nestedkey1'];34console.log(value);35var value = json.key2.nestedkey1;36console.log(value);

Full Screen

Using AI Code Generation

copy

Full Screen

1var frisby = require('./frisby');2frisby.create('Check if property exists in the response')3 .expectStatus(200)4 .expectHeaderContains('content-type', 'application/json')5 .afterJSON(function(json) {6 var property = json[0];7 expect(property).not.toBeUndefined();8 expect(property).not.toBeNull();9 expect(property).not.toBeNaN();10 expect(property).not.toBe(false);11 expect(property).not.toBe('');12 expect(property).not.toBe(0);13 expect(property).not.toBe('0');14 expect(property).toEqual(jasmine.any(Object));15 expect(property).toEqual(jasmine.anything());16 expect(property).toEqual(jasmine.any(Number));17 expect(property).toEqual(jasmine.any(String));18 expect(property).toEqual(jasmine.any(Boolean));19 expect(property).toEqual(jasmine.any(Array));20 expect(property).toEqual(jasmine.any(Function));21 expect(property).toEqual(jasmine.any(Error));22 expect(property).toEqual(jasmine.any(Date));23 expect(property).toEqual(jasmine.any(RegExp));24 expect(property).toEqual(jasmine.any(Symbol));25 expect(property).toEqual(jasmine.any(Map));26 expect(property).toEqual(jasmine.any(Set));27 expect(property).toEqual(jasmine.any(WeakMap));28 expect(property).toEqual(jasmine.any(WeakSet));29 expect(property).toEqual(jasmine.any(Int8Array));30 expect(property).toEqual(jasmine.any(Uint8Array));31 expect(property).toEqual(jasmine.any(Uint8ClampedArray));32 expect(property).toEqual(jasmine.any(Int16Array));33 expect(property).toEqual(jasmine.any(Uint16Array));34 expect(property).toEqual(jasmine.any(Int32Array));35 expect(property).toEqual(jasmine.any(Uint32Array));36 expect(property).toEqual(jasmine.any(Float32Array));37 expect(property).toEqual(jasmine.any(Float64Array));38 expect(property).toEqual(jasmine.any(Proxy));39 expect(property).toEqual(jasmine.any(Promise));40 expect(property).toEqual(jasmine.any(Generator));41 expect(property).toEqual(jasmine.any(GeneratorFunction));42 expect(property).toEqual(jasmine.any(AsyncFunction));43 expect(property).toEqual(jasmine.any(Reflect));44 expect(property).toEqual(jasmine.any(JSON));45 expect(property).toEqual(jasmine.any(Math));

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

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