How to use valueForKey method in unexpected

Best JavaScript code snippet using unexpected

socket.js

Source:socket.js Github

copy

Full Screen

1import io from '@/js_sdk/hyoga-uni-socket_io/uni-socket.io.js';2// import live from './liveSocket.js'3// var config = {4// dev: "http://chat-room-dev.leihuozb.com",5// ol: "https://chat-room.leihuozb.com",6// local: 'http://154.204.42.66:19977',7// shut: "禁言",8// kick: "踢出",9// black: "拉黑",10// method: "get",11// }1213var socket;14var room = {15 /**16 * 初始化环境17 */18 initEnv: function (data) { 19 socket = io(data, {20 query: {},21 transports: [ 'websocket' ],22 timeout: 5000,23 });24 },25 26 /**27 * 连接28 */29 connect: function (data) {30 socket.on('connect', () => {31 32 let connData = {33 nickname: data.nickname,34 uid: data.uid,35 token: data.token,36 roomnum: data.roomnum,37 equipment: data.equipment,38 stream: data.stream39 };40 41 socket.emit('conn', connData);42 });43 },44 45 /**46 * 监听47 */48 listeners: function () {49 50 socket.on('disconnect', (msg) => {51 console.log('disconnect', msg);52 });53 socket.on('broadcast', (msg) => {54 console.log('broadcast', msg);55 });56 socket.on('heartbeat', (msg) => {57 console.log('heartbeat', msg);58 socket.emit("heartbeat", "heartbeat");59 });60 socket.on('error', (msg) => {61 console.log('error', msg);62 });63 socket.on('conn', (msg) => {64 console.log('conn', msg);65 room.action.zombie();66 });67 68 socket.on('broadcastingListen', (data) => {69 console.log('broadcastingListen', data);70 let arrayData = JSON.stringify(data);71 72 let subArrayData = arrayData[0];73 if (subArrayData[0] == "stopplay") {74 // [weakself.socketDelegate roomCloseByAdmin];75 return;76 }77 78 for (let path in subArrayData) {79 let jsonDict = path;80 let tmpArray = jsonDict.msg;81 let msg = tmpArray[0];82 let retcode = jsonDict.retcode;83 84 if (retcode == 409002) {85 uni.showToast({86 title:"你已被禁言",87 icon:'none',88 duration:200089 })90 return;91 }92 93 let method = msg._method_;94 room.getMessage(method, msg);95 }96 });97 },98 getMessage: function (method, msg) {99 100 //僵尸粉101 if (method == "requestFans") {102 let ct = msg.ct;103 let data = ct.data;104 if (data.code == 0) {105 let info = data.info;106 let tmpArray = info.list;107 let list = tmpArray[0];108 // [self.socketDelegate addZombieByArray:list];109 }110 }111 //会话消息112 if (method == "SendMsg") {113 let msgtype = msg.msgtype;114 if (msgtype == "2") {115 let ct = '';116 //点亮117 if (msg.heart != nil) {118 let lightColor = msg.heart;119 let light = "light";120 let titleColor = light+lightColor;121 ct = msg.ct;122 let uname = msg.uname;123 let levell = msg.level;124 let uid = msg.uid;125 let vip_type = msg.vip_type;126 let liangname = msg.liangname;127 let usertype = msg.usertype;128 let guardType = msg.guard_type;129 130 let chat = {131 userName: uname,132 contentChat: ct,133 levelI: level,134 id: uid,135 titleColor: titleColor,136 vip_type: vip_type,137 liangname: liangname,138 usertype: usertype,139 guard_type: guardType140 }141 // [self.socketDelegate light:chat];142 }143 else{144 let titleColor = "0";145 ct = msg.ct;146 let uname = msg.uname;147 let level = msg.level;148 let uid = msg.uid;149 let vip_type = msg.vip_type;150 let liangname = msg.liangname;151 let usertype = msg.usertype;152 let isAnchor = msg.isAnchor;153 let guardType = msg.guard_type;154 155 let chat = {156 userName: uname,157 contentChat: ct,158 levelI: level,159 id: uid,160 titleColor: titleColor,161 vip_type: vip_type,162 liangname: liangname,163 usertype: usertype,164 isAnchor: isAnchor,165 guard_type: guardType166 }167 // [self.socketDelegate messageListen:chat];168 }169 }170 //用户离开进入171 else if (msgtype == "0") {172 let action = msg.action;173 //用户离开174 if (action == "1") {175 //NSLog(@"用户离开,%@",msg);176 // [self.socketDelegate UserLeave:msg];177 }178 //用户进入179 if (action == "0") {180 // [self.socketDelegate UserAccess:msg];181 }182 }183 //直播关闭184 if (msgtype == "1") {185 let action = msg.action;186 if (action == "18") {187 // NSLog(@"直播关闭");188 // [self.socketDelegate LiveOff];189 }190 }191 if (msgtype == "26") {192 193 }194 //发红包195 // if ([msgtype isEqual:@"255"]) {196 // NSString *action = [msg valueForKey:@"action"];197 // //198 // if ([action isEqual:@"0"]) {199 // [self.socketDelegate showRedbag:msg];200 // }201 // }202 203 }204 //增加映票205 // else if ([method isEqual:@"updateVotes"]){206 // NSString *msgtype = [msg valueForKey:@"msgtype"];207 // if ([msgtype isEqual:@"26"]) {208 // //限制进房间的时候自己不增加209 // NSString *uid = minstr([msg valueForKey:@"uid"]);210 // if (![uid isEqual:[HConfig getOwnID]]) {211 // [self.socketDelegate addvotesdelegate:[msg valueForKey:@"votes"]];212 // }213 // }214 // }215 //房间类型切换216 else if (method == "changeLive") {217 // [self.socketDelegate changeLive:[NSString stringWithFormat:@"%@",[msg valueForKey:@"type_val"]]];218 }219 //点亮220 else if (method == "light") {221 let msgtype = msg.msgtype;222 if (msgtype == "0") {223 let action = msg.action ;224 //点亮225 if (action == "2") {226 // [self.socketDelegate sendLight];227 }228 }229 }230 //设置管理员231 else if (method == "SystemNot" || method == "ShutUpUser") {232 let msgtype = msg.msgtype;233 let action = msg.action;234 let touid = msg.touid;235 if(msgtype == "4" && action == "13") {236 //设置取消管理员237 // if ([touid isEqual:[HConfig getOwnID]]) {238 // [self alertShowMsg:minstr([msg valueForKey:@"ct"]) andTitle:YZMsg(@"提示")];239 // }240 }241 else if (msgtype == "4" && action == "1") {242 //禁言243 // if ([touid isEqual:[HConfig getOwnID]]) {244 // [self alertShowMsg:minstr([msg valueForKey:@"ct"]) andTitle:YZMsg(@"提示")];245 // }246 }247 // [self.socketDelegate setSystemNot:msg];248 } 249 else if (method == "setAdmin") {250 let ct = msg.ct;251 if (ct) {252 // [self.socketDelegate setAdmin:msg];253 }254 }255 // else if ([method isEqual:@"shopGoodsLiveFloat"]){256 // [self.socketDelegate showLiveGooodTips:msg];257 // }258 // else if ([method isEqual:@"Sendplatgift"]){259 // //全站礼物260 // [self.socketDelegate sendAllStationsGift:msg];261 // }262 //送礼物263 // else if ([method isEqual:@"SendGift"]) {264 // // NSString *titleColor = @"2";265 // if ([minstr([msg valueForKey:@"ifpk"]) isEqual:@"1"]) {266 // [self.socketDelegate changePkProgressViewValue:msg];267 // if (![minstr([msg valueForKey:@"roomnum"]) isEqual:minstr([_playDoc valueForKey:@"uid"])]) {268 // return;269 // }270 // }271 272 // NSString *haohualiwu = [NSString stringWithFormat:@"%@",[msg valueForKey:@"evensend"]];273 // NSDictionary *ct = [msg valueForKey:@"ct"];274 275 // NSDictionary *GiftInfo = @{@"uid":[msg valueForKey:@"uid"],276 // @"nicename":[msg valueForKey:@"uname"],277 // @"giftname":[ct valueForKey:@"giftname"],278 // @"gifticon":[ct valueForKey:@"gifticon"],279 // @"giftcount":[ct valueForKey:@"giftcount"],280 // @"giftid":[ct valueForKey:@"giftid"],281 // @"level":[msg valueForKey:@"level"],282 // @"avatar":[msg valueForKey:@"uhead"],283 // @"type":[ct valueForKey:@"type"],284 // @"swf":minstr([ct valueForKey:@"swf"]),285 // @"swftime":minstr([ct valueForKey:@"swftime"]),286 // @"swftype":minstr([ct valueForKey:@"swftype"]),287 // @"isluck":minstr([ct valueForKey:@"isluck"]),288 // @"lucktimes":minstr([ct valueForKey:@"lucktimes"]),289 // @"mark":minstr([ct valueForKey:@"mark"]),290 // @"livename":minstr([msg valueForKey:@"livename"]),291 // @"isplatgift":minstr([ct valueForKey:@"isplatgift"]),292 // @"paintedPath":[msg valueForKey:@"paintedPath"],293 // @"paintedHeight":minstr([msg valueForKey:@"paintedHeight"]),294 // @"paintedWidth":minstr([msg valueForKey:@"paintedWidth"])295 296 // };297 // [self.socketDelegate sendGift:nil andLiansong:haohualiwu andTotalCoin:minstr([ct valueForKey:@"votestotal"]) andGiftInfo:GiftInfo andCt:ct];298 // } 299 // else if ([method isEqual:@"luckWin"]) {//幸运礼物300 // [self.socketDelegate showAllLuckygift:msg];301 // NSLog(@"幸运礼物%@",msg);302 // }303 // else if ([method isEqual:@"jackpotWin"]) {//奖池中奖304 // [self.socketDelegate WinningPrize:msg];305 // NSLog(@"奖池中奖%@",msg);306 // }307 // else if ([method isEqual:@"jackpotUp"]) {//奖池升级308 // [self.socketDelegate JackpotLevelUp:msg];309 // NSLog(@"奖池升级%@",msg);310 // }311 else if (method == "SendBarrage") {//弹幕312 // [self.socketDelegate SendBarrage:msg];313 // NSLog(@"弹幕接受成功%@",msg);314 }315 else if (method == "StartEndLive") {//结束直播316 // [self.socketDelegate StartEndLive];317 }318 else if (method == "disconnect") {//断开链接319 // [self.socketDelegate UserDisconnect:msg];320 }321 // else if ([method isEqual:@"goodsLiveShow"]){//直播间商品窗口322 // [self.socketDelegate showLiveGoodsWithDic:msg];323 // }324 else if (method == "KickUser") {//踢人消息325 let unamessss = msg.touid;326 // if([unamessss isEqual:[HConfig getOwnID]] ){327 // [self.socketDelegate kickOK];328 // }329 let titleColor = "firstlogin";330 let ct = msg.ct;331 let uname = "直播间消息";332 let levell = " ";333 let ID = " ";334 let icon = " ";335 let vip_type = "0";336 let liangname = "0";337 338 let chat = {339 userName: uname,340 contentChat: ct,341 levelI: levell,342 id: ID,343 titleColor: titleColor,344 avatar: icon,345 vip_type: vip_type,346 liangname: liangname347 }348 // [self.socketDelegate KickUser:chat];349 }350 /*351 1 有人发送连麦请求352 2 主播接受连麦353 3 主播拒绝连麦354 4 用户推流,发送自己的播流地址355 5 用户断开连麦356 6 主播断开连麦357 7 主播正忙碌358 8 主播无响应359 */360 // else if ([method isEqual:@"ConnectVideo"]){361 // NSString *action = [NSString stringWithFormat:@"%@",[msg valueForKey:@"action"]];362 // if ([action isEqual:@"1"]) {363 // return;364 // }365 // if ([action isEqual:@"4"]) {366 // NSString *uid = [NSString stringWithFormat:@"%@",[msg valueForKey:@"uid"]];367 // if (![uid isEqual:[HConfig getOwnID]]) {368 // //不是连麦用户的其他用户播放连麦用户的流369 // [self.socketDelegate playLinkUserUrl:minstr([msg valueForKey:@"playurl"]) andUid:minstr([msg valueForKey:@"uid"])];370 // }371 // }372 // if ([action isEqual:@"5"]){373 // [self.socketDelegate hostout];374 // if (![minstr([msg valueForKey:@"uid"]) isEqual:[HConfig getOwnID]]) {375 // [MBProgressHUD showError:[NSString stringWithFormat:@"%@%@",minstr([msg valueForKey:@"uname"]),YZMsg(@"已下麦")]];376 // }377 // }378 // if ([action isEqual:@"6"]) {379 // [self.socketDelegate hostout];380 // if ([minstr([msg valueForKey:@"touid"]) isEqual:[HConfig getOwnID]]) {381 // [MBProgressHUD showError:YZMsg(@"主播已把你下麦")];382 // }else{383 // [MBProgressHUD showError:[NSString stringWithFormat:@"%@%@",minstr([msg valueForKey:@"uname"]),YZMsg(@"已下麦")]];384 // }385 // }386 // NSString *touid = [NSString stringWithFormat:@"%@",[msg valueForKey:@"touid"]];387 // if ([touid isEqual:[HConfig getOwnID]]) {388 // if ([action isEqual:@"2"]) {389 // //同意连麦390 // [self.socketDelegate startConnectvideo];391 // }392 // else if ([action isEqual:@"3"]){393 // //拒绝连麦394 // [MBProgressHUD hideHUD];395 // [MBProgressHUD showError:YZMsg(@"主播拒绝了您的连麦请求")];396 // [self.socketDelegate enabledlianmaibtn];397 // }398 399 // //主播正忙碌400 // if ([action isEqual:@"7"]) {401 // [MBProgressHUD hideHUD];402 // [MBProgressHUD showError:YZMsg(@"主播正忙碌")];403 // [self.socketDelegate enabledlianmaibtn];404 // }405 // //主播未响应406 // if ([action isEqual:@"8"]) {407 // [MBProgressHUD hideHUD];408 // [MBProgressHUD showError:YZMsg(@"当前主播暂时无法接通")];409 // [self.socketDelegate enabledlianmaibtn];410 // }411 // //主播未响应412 // if ([action isEqual:@"10"]) {413 // [MBProgressHUD hideHUD];414 // [MBProgressHUD showError:YZMsg(@"主播未开启连麦功能哦")];415 // [self.socketDelegate enabledlianmaibtn];416 // }417 418 // }419 420 // }421 // else if ([method isEqual:@"BuyGuard"]){//购买守护422 // [self.socketDelegate updateGuardMsg:msg];423 // NSDictionary *dic = @{@"ct":[NSString stringWithFormat:@"%@ %@",minstr([msg valueForKey:@"uname"]),YZMsg(@"守护了主播")]};424 // [self.socketDelegate setSystemNot:dic];425 // }426 // else if ([method isEqual:@"SendRed"]) {//发红包427 // NSString *action = [msg valueForKey:@"action"];428 // //429 // if ([action isEqual:@"0"]) {430 // [self.socketDelegate showRedbag:msg];431 // }432 // } 433 else if (method == "LiveConnect"){434 //1:发起连麦;2;接受连麦;3:拒绝连麦;4:连麦成功通知;5.手动断开连麦;7:对方正忙碌 8:对方无响应435 let action = msg.action;436 switch (action) {437 case 4:438 // [self.socketDelegate anchor_agreeLink:msg];439 break;440 case 5:441 // [self.socketDelegate anchor_stopLink:msg];442 break;443 default:444 break;445 }446 }447 // else if ([method isEqual:@"LivePK"]){448 // //1:发起PK;2;接受PK;3:拒绝PK;4:PK成功通知;5.;7:对方正忙碌 8:对方无响应 9:PK结果449 // int action = [minstr([msg valueForKey:@"action"]) intValue];450 // switch (action) {451 // case 4:452 // [self.socketDelegate showPKView:nil];453 // break;454 // case 9:455 // [self.socketDelegate showPKResult:msg];456 // break;457 458 // default:459 // break;460 // }461 // }462 //炸金花//收到主播广播准备开始游戏463 ////收到主播广播准备开始游戏464 // else if ([method isEqual:@"startGame"] || [method isEqual:@"startLodumaniGame"] || [method isEqual:@"startCattleGame"] ){465 // NSString *action = [NSString stringWithFormat:@"%@",[msg valueForKey:@"action"]];466 // NSString *msgtype = [NSString stringWithFormat:@"%@",[msg valueForKey:@"msgtype"]];467 // if ([action isEqual:@"1"]) {468 // //出现游戏界面469 // [self.socketDelegate prepGameandMethod:method andMsgtype:msgtype];470 // }471 // else if ([action isEqual:@"2"]){472 // if ([method isEqual:@"startCattleGame"]) {473 // NSDictionary *bankdic = [msg valueForKey:@"bankerlist"];474 // [self.socketDelegate changeBank:bankdic];475 // }476 // //开始发牌477 // [self.socketDelegate takePoker:[msg valueForKey:@"gameid"] Method:method andMsgtype:msgtype];478 479 // }480 // else if ([action isEqual:@"3"]){481 // //主播关闭游戏482 // [self.socketDelegate stopGame];483 // }484 // else if ([action isEqual:@"4"]){485 // //游戏开始 倒数计时486 // NSString *time = [NSString stringWithFormat:@"%@",[msg valueForKey:@"time"]];//游戏时间487 // [self.socketDelegate startGame:time andGameID:[msg valueForKey:@"gameid"]];488 // }489 // else if ([action isEqual:@"5"]){490 // //用户投注491 // NSString *money = [NSString stringWithFormat:@"%@",[msg valueForKey:@"money"]];492 // NSString *type = [NSString stringWithFormat:@"%@",[msg valueForKey:@"type"]];493 // [self.socketDelegate getCoin:type andMoney:money];494 // }else if ([action isEqual:@"6"]){495 // //开奖496 // NSArray *ct = [msg valueForKey:@"ct"];497 // [self.socketDelegate getResult:ct];498 // }499 // }500 // else if ([method isEqual:@"startRotationGame"]){501 // NSString *action = [NSString stringWithFormat:@"%@",[msg valueForKey:@"action"]];502 // if ([action isEqual:@"1"]) {503 // //出现游戏界面504 // [self.socketDelegate prepRotationGame];505 // }506 // else if ([action isEqual:@"2"]){507 508 509 // }510 // else if ([action isEqual:@"3"]){511 // //主播关闭游戏512 // [self.socketDelegate stopRotationGame];513 514 // }515 // else if ([action isEqual:@"4"]){516 // //游戏开始 倒数计时517 // NSString *time = [NSString stringWithFormat:@"%@",[msg valueForKey:@"time"]];//游戏时间518 // [self.socketDelegate startRotationGame:time andGameID:[msg valueForKey:@"gameid"]];519 // }520 // else if ([action isEqual:@"5"]){521 // //用户投注522 // NSString *money = [NSString stringWithFormat:@"%@",[msg valueForKey:@"money"]];523 // NSString *type = [NSString stringWithFormat:@"%@",[msg valueForKey:@"type"]];524 // [self.socketDelegate getRotationCoin:type andMoney:money];525 // }else if ([action isEqual:@"6"]){526 // //开奖527 // NSArray *ct = [msg valueForKey:@"ct"];528 // [self.socketDelegate getRotationResult:ct];529 // }530 // }531 //二八贝532 // else if ([method isEqual:@"startShellGame"]){533 // NSString *action = [NSString stringWithFormat:@"%@",[msg valueForKey:@"action"]];534 // NSString *msgtype = [NSString stringWithFormat:@"%@",[msg valueForKey:@"msgtype"]];535 // if ([action isEqual:@"1"]) {536 // //出现游戏界面537 // [self.socketDelegate shellprepGameandMethod:method andMsgtype:msgtype];538 // }539 // else if ([action isEqual:@"2"]){540 // //开始发牌541 // [self.socketDelegate shelltakePoker:[msg valueForKey:@"gameid"] Method:method andMsgtype:msgtype];542 // }543 // else if ([action isEqual:@"3"]){544 // //主播关闭游戏545 // [self.socketDelegate shellstopGame];546 // }547 // else if ([action isEqual:@"4"]){548 // //游戏开始 倒数计时549 // NSString *time = [NSString stringWithFormat:@"%@",[msg valueForKey:@"time"]];//游戏时间550 // [self.socketDelegate shellstartGame:time andGameID:[msg valueForKey:@"gameid"]];551 // }552 // else if ([action isEqual:@"5"]){553 // //用户投注554 // NSString *money = [NSString stringWithFormat:@"%@",[msg valueForKey:@"money"]];555 // NSString *type = [NSString stringWithFormat:@"%@",[msg valueForKey:@"type"]];556 // [self.socketDelegate shellgetCoin:type andMoney:money];557 // }else if ([action isEqual:@"6"]){558 // //开奖559 // NSArray *ct = [msg valueForKey:@"ct"];560 // [self.socketDelegate shellgetResult:ct];561 // }562 // }563 // else if ([method isEqual:@"shangzhuang"]){564 // NSString *action = [NSString stringWithFormat:@"%@",[msg valueForKey:@"action"]];565 // //有人上庄566 // if ([action isEqual:@"1"]) {567 // NSDictionary *subdic = @{568 // @"uid":[msg valueForKey:@"uid"],569 // @"uhead":[msg valueForKey:@"uhead"],570 // @"uname":[msg valueForKey:@"uname"],571 // @"coin":[msg valueForKey:@"coin"]572 // };573 // [self.socketDelegate getzhuangjianewmessagedelegatem:subdic];574 // }575 // }576 577 },578 579 /**580 * 关闭连接581 */582 close: function (data) {583 socket.close();584 },585586 /**587 * 监听588 */589 listeners: function () {590 591 socket.on('broadcastingListen', (msg) => {592 console.log('broadcastingListen', msg);593 });594 socket.on('disconnect', (msg) => {595 console.log('disconnect', msg);596 });597 socket.on('broadcast', (msg) => {598 console.log('broadcast', msg);599 });600 socket.on('heartbeat', (msg) => {601 console.log('heartbeat', msg);602 socket.emit("heartbeat", "heartbeat");603 });604 socket.on('error', (msg) => {605 console.log('error', msg);606 });607 socket.on('conn', (msg) => {608 console.log('conn', msg);609 room.action.zombie();610 });611 },612 613 action: {614 /**615 *僵尸粉616 */617 zombie: function () {618 let connData = {619 msg: [620 {621 _method_: "requestFans",622 timestamp:"",623 msgtype: "0",624 }625 ],626 retcode: "000000",627 retmsg: "OK"628 };629 console.log(connData);630 socket.emit('broadcast', connData);631 },632 633 /**634 *增加映票635 */636 addvotes: function (data) {637 let connData = {638 msg: [639 {640 _method_: "updateVotes",641 action: "1",642 votes: data.votes,643 msgtype: "26",644 uid: data.uid,645 isfirst: data.isfirst646 }647 ],648 retcode: "000000",649 retmsg: "OK"650 }651 console.log(connData);652 socket.emit('broadcast', connData);653 },654 655 /**656 *关注主播657 */658 attentionLive: function (data) {659 let connData = {660 msg: [661 {662 _method_: "SystemNot",663 action: "13",664 ct: data.ct,665 msgtype: "4",666 timestamp: "",667 tougood: "",668 touid: "0",669 city:"",670 touname: "",671 ugood: "",672 uid: data.uid,673 uname: data.uname,674 equipment: "app",675 roomnum: data.roomnum,676 usign:"",677 uhead:"",678 level:data.level,679 sex:""680 }681 ],682 retcode: "000000",683 retmsg: "OK"684 }685 console.log(connData);686 socket.emit('broadcast', connData);687 },688 689 /**690 *房间关闭691 */692 stopRoom: function (data) {693 let connData = {694 msg: [695 {696 _method_: "stopLive",697 action: "19",698 ct:"",699 msgtype: "1",700 timestamp: "",701 tougood: "",702 touid: "0",703 touname: "",704 ugood: data.ugood,705 uid: data.uid,706 uname: data.uname,707 equipment: "app",708 roomnum: data.roomnum,709 usign:"",710 uhead: data.uhead,711 level: data.level,712 city:"",713 sex:""714 }715 ],716 retcode: "000000",717 retmsg: "OK"718 }719 console.log(connData);720 socket.emit('broadcast', connData);721 },722 723 /**724 *发送消息725 */726 sendmessage: function (data) {727 let connData = {728 msg: [729 {730 _method_:"SendMsg",731 action:"0",732 ct: data.ct,733 msgtype:"2",734 timestamp:"",735 tougood:"",736 touid:"0",737 city:"",738 touname:"",739 ugood:"",740 uid: data.uid,741 uname:data.uname,742 equipment:"app",743 roomnum:data.roomnum,744 usign:"",745 uhead:"",746 level:data.level,747 sex:"",748 vip_type:data.vipType,749 liangname:data.liangname,750 isAnchor:"0",751 usertype:data.usertype,752 guard_type:data.guardtype753 }754 ],755 retcode:"000000",756 retmsg:"OK"757 }758 console.log(connData);759 socket.emit('broadcast', connData);760 },761 762 /**763 *送礼物764 */765 sendGift: function (data) {766 let connData = {767 msg: [768 {769 _method_: "SendGift",770 action: "0",771 ct:info ,772 msgtype: "1",773 uid: data.uid,774 uname: data.uname,775 equipment: "app",776 roomnum: data.roomnum,777 level:data.level,778 evensend:data.evensend,779 uhead:data.uhead,780 vip_type:data.viptype,781 liangname:data.liangame,782 livename:data.livename,783 paintedPath:data.paintedPath,784 paintedHeight:data.paintedHeight,785 paintedWidth:data.paintedWidth786 }787 ],788 retcode: "000000",789 retmsg: "OK"790 }791 console.log(connData);792 socket.emit('broadcast', connData);793 },794 795 /**796 *禁言797 */798 shutUp: function (data) {799 let connData = {800 msg: [801 {802 _method_:"ShutUpUser",803 action:"1",804 ct:data.ct,805 uid:data.uid,806 touid:data.touid,807 showid:data.showid,808 uname:"",809 msgtype:"4",810 timestamp:"",811 tougood:"",812 touname:"",813 ugood:""814 }815 ],816 retcode:"000000",817 retmsg:"OK"818 }819 console.log(connData);820 socket.emit('broadcast', connData);821 },822 823 /**824 *踢人825 */826 kickUser: function (data) {827 let connData = {828 msg: [829 {830 _method_:"KickUser",831 action:"2",832 ct:data.ct,833 uid:data.uid,834 touid:data.touid,835 showid:data.showid,836 uname:"",837 msgtype:"4",838 timestamp:"",839 tougood:"",840 touname:"",841 ugood:""842 },843 ],844 retcode:"000000",845 retmsg:"OK"846 }847 console.log(connData);848 socket.emit('broadcast', connData);849 },850 851 /**852 *弹幕853 */854 sendBarrage: function (data) {855 let connData = {856 msg: [857 {858 _method_: "SendBarrage",859 action: "7",860 ct:ct ,861 msgtype: "1",862 ugood: data.ugood,863 uid: data.uid,864 uname: data.uname,865 equipment: "app",866 roomnum: data.roomnum,867 level:data.level,868 uhead:data.uhead,869 vip_type:data.viptype,870 liangname:data.liangname871 }872 ],873 retcode: "000000",874 retmsg: "OK"875 }876 console.log(connData);877 socket.emit('broadcast', connData);878 },879 880 /**881 *点亮882 */883 starlight: function (data) {884 let connData = {885 msg: [886 {887 _method_: "SendMsg",888 action: "0",889 ct: "我点亮了",890 msgtype: "2",891 uid: data.uid,892 uname: data.nicename,893 equipment: "app",894 roomnum: data.roomnum,895 level:data.level,896 heart: data.heart,897 vip_type: data.viptype,898 liangname: data.liangname,899 usertype: data.usertype,900 guard_type: data.guardType901 }902 ],903 retcode: "000000",904 retmsg: "OK"905 }906 console.log(connData);907 socket.emit('broadcast', connData);908 },909 910 /**911 *连麦socket912 */913 sendLianMai: function (data) {914 let connData = {915 msg: [916 {917 _method_:"ConnectVideo",918 action: "5",919 msgtype: "10",920 uid:data.uid,921 uname:data.uname,922 }923 ],924 retcode: "000000",925 retmsg: "OK"926 }927 console.log(connData);928 socket.emit('broadcast', connData);929 },930 931 /**932 *连麦933 */934 sendSmall: function (data) {935 let connData = {936 msg: [937 {938 _method_: "updateVotes",939 action:"1",940 votes:data.votes,941 msgtype: "26",942 uid:data.uid,943 isfirst:data.isfirst944 }945 ],946 retcode: "000000",947 retmsg: "OK"948 }949 console.log(connData);950 socket.emit('broadcast', connData);951 },952 953 /**954 *close connect955 */956 closeConnect: function (data) {957 let connData = {958 msg: [959 {960 _method_: "ConnectVideo",961 action:"5",962 msgtype: "10",963 uid:data.uid,964 uname:data.uname965 }966 ],967 retcode: "000000",968 retmsg: "OK"969 }970 console.log(connData);971 socket.emit('broadcast', connData);972 },973 974 /**975 *videoToHost976 */977 videoToHost: function (data) {978 let connData = {979 msg: [980 {981 _method_: "ConnectVideo",982 action:"1",983 msgtype: "10",984 uid:data.uid,985 uname:data.uname,986 uhead:data.uhead,987 level:data.level,988 sex:data.sex989 }990 ],991 retcode: "000000",992 retmsg: "OK"993 }994 console.log(connData);995 socket.emit('broadcast', connData);996 },997 998 /**999 *buyGuard1000 */1001 buyGuard: function (data) {1002 let connData = {1003 msg: [1004 {1005 _method_: "BuyGuard",1006 action:"0",1007 msgtype: "0",1008 ct:"守护了主播",1009 uid:data.uid,1010 uname:data.uname,1011 uhead:data.uhead,1012 votestotal:data.votestotal,1013 guard_nums:data.guardnums1014 }1015 ],1016 retcode: "000000",1017 retmsg: "OK"1018 }1019 console.log(connData);1020 socket.emit('broadcast', connData);1021 },1022 1023 /**1024 *fahongbaola1025 */1026 fahongbaola: function (data) {1027 let connData = {1028 msg: [1029 {1030 _method_: "SendRed",1031 action: "0",1032 ct:"在直播间发红包啦!快去抢哦",1033 msgtype: "0",1034 timestamp: "",1035 touid: "0",1036 ugood: data.ugood,1037 uid: data.uid,1038 uname: data.uname,1039 equipment: "app",1040 uhead:data.uhead,1041 level:data.level,1042 vip_type:data.viptype,1043 liangname:data.liangname,1044 isAnchor:"0"1045 }1046 ],1047 retcode: "000000",1048 retmsg: "OK"1049 }1050 console.log(connData);1051 socket.emit('broadcast', connData);1052 },1053 1054 /**1055 *stakePoke1056 */1057 stakePoke: function (data) {1058 let connData = {1059 msg: [1060 {1061 _method_: data.method,1062 action: "5",1063 msgtype:data.msgtype,1064 type:data.type,1065 money:data.money,1066 uid:data.uid1067 }1068 ],1069 retcode: "000000",1070 retmsg: "OK"1071 }1072 console.log(connData);1073 socket.emit('broadcast', connData);1074 },1075 1076 /**1077 *stakeRotationPoke1078 */1079 stakeRotationPoke: function (data) {1080 let connData = {1081 msg: [1082 {1083 _method_: "startRotationGame",1084 action: "5",1085 msgtype:"16",1086 type:data.type,1087 money:data.money,1088 uid:data.uid1089 }1090 ],1091 retcode: "000000",1092 retmsg: "OK"1093 }1094 console.log(connData);1095 socket.emit('broadcast', connData);1096 },1097 1098 /**1099 *getzhuangjianewm1100 */1101 getzhuangjianewm: function (data) {1102 let connData = {1103 msg: [1104 {1105 _method_:"shangzhuang",1106 action:"1",1107 msgtype:"25",1108 uid:data.uid,1109 uhead:data.uhead,1110 uname:data.uname,1111 coin:data.coin1112 }1113 ],1114 retcode: "000000",1115 retmsg: "OK"1116 }1117 console.log(connData);1118 socket.emit('broadcast', connData);1119 },1120 1121 // /**1122 // *1123 // * 超管弹幕刷新1124 // *1125 // * @return mixed $data default string,1126 // * @example1127 // * 说明:1128 // *1129 // */1130 // barrage: {1131 // tpl: function () {1132 // return {1133 // retcode: "000000",1134 // retmsg: "ok",1135 // msg: [1136 // {1137 // _method_: 'barrage-refresh',1138 // action: "0",1139 // touid: 0,1140 // msgtype: "1",1141 // uname: 'sys-super',1142 // uid: '-10000',1143 // liangname: "0",1144 // vip_type: "0",1145 // ct: '',1146 // guard_type: "10",1147 // usertype: "60",1148 // },1149 // ],1150 // };1151 // },1152 // //刷新1153 // refresh: function () {1154 // console.log(room.action.barrage.tpl());1155 // socket.emit("broadcast", room.action.barrage.tpl());1156 // }1157 // },1158 // /**1159 // *1160 // * 超管踢出1161 // *1162 // * @return mixed $data default string,1163 // * @example1164 // * 说明:1165 // *1166 // */1167 // kick: {1168 // //模板1169 // tpl: function (paermission, uid, nick_name) {1170 // return {1171 // retcode: "000000",1172 // retmsg: "ok",1173 // msg: [1174 // {1175 // _method_: "KickUser",1176 // action: "2",1177 // touid: uid,1178 // touname: nick_name,1179 // msgtype: "4",1180 // uname: nick_name,1181 // uid: uid,1182 // liangname: "0",1183 // vip_type: "0",1184 // ct: nick_name + "被踢出房间",1185 // guard_type: "10",1186 // usertype: "30",1187 // },1188 // ],1189 // };1190 // },1191 // click: function (nick_name, paermission, uid, room_id) {1192 // room.alert(nick_name, paermission, uid, room_id, config.kick, room.action.kick.send);1193 // },1194 // emit: function (nick_name, paermission, uid, room_id) {1195 // room.ajax(config.method, '/admin/onlines-kick/' + uid + '/' + room_id, function (data) {1196 // if (data.code == 200) {1197 // //删除1198 // room.showHide(data.data.paermission, uid, room_id, 'kick');1199 // if (data.data.paermission == 'disabled') {1200 // //广播通知1201 // socket.emit("broadcast", room.action.kick.tpl(data.data.paermission, uid, nick_name));1202 // }1203 // //提示操作成功1204 // room.alertSuccess();1205 // } else {1206 // //提示操作失败1207 // room.alertError(data.message);1208 // }1209 // });1210 // },12111212 },12131214 // /**1215 // *1216 // * 超管禁言1217 // *1218 // * @return mixed $data default string,1219 // * @example1220 // * 说明:1221 // *1222 // */1223 // shut: {1224 // //模板1225 // tpl: function (paermission, uid, nick_name) {1226 // let method =1227 // paermission == "disabled" ? "ShutUpUser" : "ResumeUser";1228 // return {1229 // retcode: "000000",1230 // retmsg: "ok",1231 // msg: [1232 // {1233 // _method_: method,1234 // action: "0",1235 // touid: uid,1236 // msgtype: "1",1237 // uname: nick_name,1238 // uid: uid,1239 // liangname: "0",1240 // vip_type: "0",1241 // ct: nick_name + (method == "ShutUpUser" ? "被禁言了" : "禁言解除了"),1242 // guard_type: "10",1243 // usertype: "30",1244 // },1245 // ],1246 // };1247 // },1248 // click: function (nick_name, paermission, uid, room_id) {1249 // room.alert(nick_name, paermission, uid, room_id, config.shut, room.action.shut.send);1250 // },1251 // emit: function (nick_name, paermission, uid, room_id) {1252 // room.ajax(config.method, '/admin/onlines-shut/' + uid + '/' + room_id, function (data) {1253 // if (data.code == 200) {1254 // //隐藏或显示图标1255 // room.showHide(data.data.paermission, uid, room_id, 'shut');1256 // //广播通知1257 // socket.emit("broadcast", room.action.shut.tpl(data.data.paermission, uid, nick_name));1258 // //提示操作成功1259 // room.alertSuccess();1260 // } else {1261 // //提示操作失败1262 // room.alertError(data.message);1263 // }1264 // });1265 // },1266 // }12671268 // },1269 // alertSuccess: function () {1270 // swal({1271 // title: '操作成功',1272 // icon: 'success',1273 // });1274 // },1275 // alertError: function (message) {1276 // swal({1277 // title: message,1278 // icon: 'warning',1279 // });1280 // },1281 // alert: function (nick_name, paermission, uid, room_id, text, callback) {1282 // swal({1283 // title: paermission == "allow" ? "是否确认" + text : "是否确认解除" + text,1284 // text: "",1285 // type: "warning",1286 // showCancelButton: true,1287 // confirmButtonText: "确认",1288 // cancelButtonText: "取消",1289 // }).then(function (res) {1290 // if (res.value) {1291 // return callback(nick_name, paermission, uid, room_id);1292 // }1293 // });1294 // },1295 // showHide: function (paermission, uid, room_id, id) {1296 // if (paermission == 'allow') {1297 // $('#' + id + '_' + uid + '_' + room_id + '_allow').show();1298 // $('#' + id + '_' + uid + '_' + room_id + '_disabled').hide();1299 // } else {1300 // $('#' + id + '_' + uid + '_' + room_id + '_allow').hide();1301 // $('#' + id + '_' + uid + '_' + room_id + '_disabled').show();1302 // }1303 // },1304 // ajax: function (method, url, callback) {1305 // $.ajax({method: method, url: url, success: callback});1306 // }13071308}13091310export default {1311 // live,1312 room...

Full Screen

Full Screen

VehicleDataTypeTests.js

Source:VehicleDataTypeTests.js Github

copy

Full Screen

...3const Validator = require('./../../../Validator.js');4describe('VehicleDataTypeTests', function () {5 it('testValidEnums', function (done) {6 let example = 'VEHICLEDATA_GPS';7 const enumVehicledataGps = VehicleDataType.valueForKey(example);8 example = 'VEHICLEDATA_SPEED';9 const enumVehicledataSpeed = VehicleDataType.valueForKey(example);10 example = 'VEHICLEDATA_RPM';11 const enumVehicledataRpm = VehicleDataType.valueForKey(example);12 example = 'VEHICLEDATA_FUELLEVEL';13 const enumVehicledataFuellevel = VehicleDataType.valueForKey(example);14 example = 'VEHICLEDATA_FUELLEVEL_STATE';15 const enumVehicledataFuellevelState = VehicleDataType.valueForKey(example);16 example = 'VEHICLEDATA_FUELCONSUMPTION';17 const enumVehicledataFuelconsumption = VehicleDataType.valueForKey(example);18 example = 'VEHICLEDATA_CLIMATEDATA';19 const enumVehicledataClimatedata = VehicleDataType.valueForKey(example);20 example = 'VEHICLEDATA_EXTERNTEMP';21 const enumVehicledataExterntemp = VehicleDataType.valueForKey(example);22 example = 'VEHICLEDATA_VIN';23 const enumVehicledataVin = VehicleDataType.valueForKey(example);24 example = 'VEHICLEDATA_PRNDL';25 const enumVehicledataPrndl = VehicleDataType.valueForKey(example);26 example = 'VEHICLEDATA_TIREPRESSURE';27 const enumVehicledataTirepressure = VehicleDataType.valueForKey(example);28 example = 'VEHICLEDATA_ODOMETER';29 const enumVehicledataOdometer = VehicleDataType.valueForKey(example);30 example = 'VEHICLEDATA_BELTSTATUS';31 const enumVehicledataBeltstatus = VehicleDataType.valueForKey(example);32 example = 'VEHICLEDATA_BODYINFO';33 const enumVehicledataBodyinfo = VehicleDataType.valueForKey(example);34 example = 'VEHICLEDATA_DEVICESTATUS';35 const enumVehicledataDevicestatus = VehicleDataType.valueForKey(example);36 example = 'VEHICLEDATA_ECALLINFO';37 const enumVehicledataEcallinfo = VehicleDataType.valueForKey(example);38 example = 'VEHICLEDATA_AIRBAGSTATUS';39 const enumVehicledataAirbagstatus = VehicleDataType.valueForKey(example);40 example = 'VEHICLEDATA_EMERGENCYEVENT';41 const enumVehicledataEmergencyevent = VehicleDataType.valueForKey(example);42 example = 'VEHICLEDATA_CLUSTERMODESTATUS';43 const enumVehicledataClustermodestatus = VehicleDataType.valueForKey(example);44 example = 'VEHICLEDATA_MYKEY';45 const enumVehicledataMykey = VehicleDataType.valueForKey(example);46 example = 'VEHICLEDATA_BRAKING';47 const enumVehicledataBraking = VehicleDataType.valueForKey(example);48 example = 'VEHICLEDATA_WIPERSTATUS';49 const enumVehicledataWiperstatus = VehicleDataType.valueForKey(example);50 example = 'VEHICLEDATA_HEADLAMPSTATUS';51 const enumVehicledataHeadlampstatus = VehicleDataType.valueForKey(example);52 example = 'VEHICLEDATA_BATTVOLTAGE';53 const enumVehicledataBattvoltage = VehicleDataType.valueForKey(example);54 example = 'VEHICLEDATA_ENGINETORQUE';55 const enumVehicledataEnginetorque = VehicleDataType.valueForKey(example);56 example = 'VEHICLEDATA_ACCPEDAL';57 const enumVehicledataAccpedal = VehicleDataType.valueForKey(example);58 example = 'VEHICLEDATA_STEERINGWHEEL';59 const enumVehicledataSteeringwheel = VehicleDataType.valueForKey(example);60 example = 'VEHICLEDATA_TURNSIGNAL';61 const enumVehicledataTurnsignal = VehicleDataType.valueForKey(example);62 example = 'VEHICLEDATA_FUELRANGE';63 const enumVehicledataFuelrange = VehicleDataType.valueForKey(example);64 example = 'VEHICLEDATA_ENGINEOILLIFE';65 const enumVehicledataEngineoillife = VehicleDataType.valueForKey(example);66 example = 'VEHICLEDATA_ELECTRONICPARKBRAKESTATUS';67 const enumVehicledataElectronicparkbrakestatus = VehicleDataType.valueForKey(example);68 example = 'VEHICLEDATA_CLOUDAPPVEHICLEID';69 const enumVehicledataCloudappvehicleid = VehicleDataType.valueForKey(example);70 example = 'VEHICLEDATA_OEM_CUSTOM_DATA';71 const enumVehicledataOemCustomData = VehicleDataType.valueForKey(example);72 example = 'VEHICLEDATA_STABILITYCONTROLSSTATUS';73 const enumVehicledataStabilitycontrolsstatus = VehicleDataType.valueForKey(example);74 example = 'VEHICLEDATA_HANDSOFFSTEERING';75 const enumVehicledataHandsoffsteering = VehicleDataType.valueForKey(example);76 example = 'VEHICLEDATA_WINDOWSTATUS';77 const enumVehicledataWindowstatus = VehicleDataType.valueForKey(example);78 example = 'VEHICLEDATA_GEARSTATUS';79 const enumVehicledataGearstatus = VehicleDataType.valueForKey(example);80 example = 'VEHICLEDATA_SEATOCCUPANCY';81 const enumVehicledataSeatoccupancy = VehicleDataType.valueForKey(example);82 Validator.assertNotNullUndefined(enumVehicledataGps, 'VEHICLEDATA_GPS returned null.');83 Validator.assertNotNullUndefined(enumVehicledataSpeed, 'VEHICLEDATA_SPEED returned null.');84 Validator.assertNotNullUndefined(enumVehicledataRpm, 'VEHICLEDATA_RPM returned null.');85 Validator.assertNotNullUndefined(enumVehicledataFuellevel, 'VEHICLEDATA_FUELLEVEL returned null.');86 Validator.assertNotNullUndefined(enumVehicledataFuellevelState, 'VEHICLEDATA_FUELLEVEL_STATE returned null.');87 Validator.assertNotNullUndefined(enumVehicledataFuelconsumption, 'VEHICLEDATA_FUELCONSUMPTION returned null.');88 Validator.assertNotNullUndefined(enumVehicledataClimatedata, 'VEHICLEDATA_CLIMATEDATA returned null.');89 Validator.assertNotNullUndefined(enumVehicledataExterntemp, 'VEHICLEDATA_EXTERNTEMP returned null.');90 Validator.assertNotNullUndefined(enumVehicledataVin, 'VEHICLEDATA_VIN returned null.');91 Validator.assertNotNullUndefined(enumVehicledataPrndl, 'VEHICLEDATA_PRNDL returned null.');92 Validator.assertNotNullUndefined(enumVehicledataTirepressure, 'VEHICLEDATA_TIREPRESSURE returned null.');93 Validator.assertNotNullUndefined(enumVehicledataOdometer, 'VEHICLEDATA_ODOMETER returned null.');94 Validator.assertNotNullUndefined(enumVehicledataBeltstatus, 'VEHICLEDATA_BELTSTATUS returned null.');95 Validator.assertNotNullUndefined(enumVehicledataBodyinfo, 'VEHICLEDATA_BODYINFO returned null.');96 Validator.assertNotNullUndefined(enumVehicledataDevicestatus, 'VEHICLEDATA_DEVICESTATUS returned null.');97 Validator.assertNotNullUndefined(enumVehicledataEcallinfo, 'VEHICLEDATA_ECALLINFO returned null.');98 Validator.assertNotNullUndefined(enumVehicledataAirbagstatus, 'VEHICLEDATA_AIRBAGSTATUS returned null.');99 Validator.assertNotNullUndefined(enumVehicledataEmergencyevent, 'VEHICLEDATA_EMERGENCYEVENT returned null.');100 Validator.assertNotNullUndefined(enumVehicledataClustermodestatus, 'VEHICLEDATA_CLUSTERMODESTATUS returned null.');101 Validator.assertNotNullUndefined(enumVehicledataMykey, 'VEHICLEDATA_MYKEY returned null.');102 Validator.assertNotNullUndefined(enumVehicledataBraking, 'VEHICLEDATA_BRAKING returned null.');103 Validator.assertNotNullUndefined(enumVehicledataWiperstatus, 'VEHICLEDATA_WIPERSTATUS returned null.');104 Validator.assertNotNullUndefined(enumVehicledataHeadlampstatus, 'VEHICLEDATA_HEADLAMPSTATUS returned null.');105 Validator.assertNotNullUndefined(enumVehicledataBattvoltage, 'VEHICLEDATA_BATTVOLTAGE returned null.');106 Validator.assertNotNullUndefined(enumVehicledataEnginetorque, 'VEHICLEDATA_ENGINETORQUE returned null.');107 Validator.assertNotNullUndefined(enumVehicledataAccpedal, 'VEHICLEDATA_ACCPEDAL returned null.');108 Validator.assertNotNullUndefined(enumVehicledataSteeringwheel, 'VEHICLEDATA_STEERINGWHEEL returned null.');109 Validator.assertNotNullUndefined(enumVehicledataTurnsignal, 'VEHICLEDATA_TURNSIGNAL returned null.');110 Validator.assertNotNullUndefined(enumVehicledataFuelrange, 'VEHICLEDATA_FUELRANGE returned null.');111 Validator.assertNotNullUndefined(enumVehicledataEngineoillife, 'VEHICLEDATA_ENGINEOILLIFE returned null.');112 Validator.assertNotNullUndefined(enumVehicledataElectronicparkbrakestatus, 'VEHICLEDATA_ELECTRONICPARKBRAKESTATUS returned null.');113 Validator.assertNotNullUndefined(enumVehicledataCloudappvehicleid, 'VEHICLEDATA_CLOUDAPPVEHICLEID returned null.');114 Validator.assertNotNullUndefined(enumVehicledataOemCustomData, 'VEHICLEDATA_OEM_CUSTOM_DATA returned null.');115 Validator.assertNotNullUndefined(enumVehicledataStabilitycontrolsstatus, 'VEHICLEDATA_STABILITYCONTROLSSTATUS returned null.');116 Validator.assertNotNullUndefined(enumVehicledataHandsoffsteering, 'VEHICLEDATA_HANDSOFFSTEERING returned null.');117 Validator.assertNotNullUndefined(enumVehicledataWindowstatus, 'VEHICLEDATA_WINDOWSTATUS returned null.');118 Validator.assertNotNullUndefined(enumVehicledataGearstatus, 'VEHICLEDATA_GEARSTATUS returned null.');119 Validator.assertNotNullUndefined(enumVehicledataSeatoccupancy, 'VEHICLEDATA_SEATOCCUPANCY returned null.');120 done();121 });122 it('testInvalidEnum', function (done) {123 const example = 'nIGHT';124 const temp = VehicleDataType.valueForKey(example);125 Validator.assertNull(temp, 'Result of valueForKey should be null.');126 done();127 });128 it('testNullEnum', function (done) {129 const example = null;130 const temp = VehicleDataType.valueForKey(example);131 Validator.assertNull(temp, 'Result of valueForKey should be null.');132 done();133 });...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var obj = {2 "cars": {3 }4};5console.log(obj.cars.car1);6var obj = {7 "cars": {8 }9};10console.log(obj.cars.car1);11var obj = {12 "cars": {13 }14};15console.log(obj.cars.car1);16var obj = {17 "cars": {18 }19};20console.log(obj.cars.car1);21var obj = {22 "cars": {23 }24};25console.log(obj.cars.car1);26var obj = {27 "cars": {28 }29};30console.log(obj.cars.car1);31var obj = {32 "cars": {33 }34};35console.log(obj.cars.car1);36var obj = {

Full Screen

Using AI Code Generation

copy

Full Screen

1const unexpected = require('unexpected');2const unexpectedReact = require('unexpected-react');3const unexpectedSinon = require('unexpected-sinon');4const expect = unexpected.clone().use(unexpectedReact).use(unexpectedSinon);5const React = require('react');6const TestComponent = React.createClass({7 render() {8 return (9 );10 },11});12describe('TestComponent', () => {13 it('renders a h1 tag', () => {14 const component = <TestComponent />;15 expect(component, 'to have rendered', <h1>Hello World</h1>);16 });17});18{19 "scripts": {20 },21 "devDependencies": {22 },23 "dependencies": {24 }25}260 passing (9ms)

Full Screen

Using AI Code Generation

copy

Full Screen

1var unexpected = require('unexpected');2var expect = unexpected.clone();3var obj = {4 "cars": {5 }6};7expect(obj, 'to have key', 'name');8expect(obj, 'to have key', 'age');9expect(obj, 'to have key', 'cars');10expect(obj, 'to have key', 'car1');11expect(obj, 'to have key', 'car2');12expect(obj, 'to have key', 'car3');13expect(obj, 'to have key', 'name');14expect(obj, 'to have key', 'age');15expect(obj, 'to have key', 'cars');16expect(obj, 'to have key', 'car1');17expect(obj, 'to have key', 'car2');18expect(obj, 'to have key', 'car3');19var unexpected = require('unexpected');20var expect = unexpected.clone();21var obj = {22 "cars": {23 }24};25expect(obj, 'to have key path', 'cars.car1');26expect(obj, 'to have key path', 'cars.car2');27expect(obj, 'to have key path', 'cars.car3');28expect(obj, 'to have key path', 'cars.car1');29expect(obj, 'to have key path', 'cars.car2');30expect(obj, 'to have key path', 'cars.car3');31var unexpected = require('unexpected');32var expect = unexpected.clone();33var obj = {34 "cars": {35 }36};37expect(obj, 'to have key', 'name');38expect(obj, 'to have key', 'age');39expect(obj, 'to have key', 'cars');40expect(obj, 'to have key', 'car1');41expect(obj, 'to have key', 'car2');42expect(obj

Full Screen

Using AI Code Generation

copy

Full Screen

1var unexpected = require('unexpected');2var expect = unexpected.clone();3var a = 2;4var b = 3;5expect(a, 'to equal', b);6 at AssertionError (native)7 at Context.<anonymous> (/Users/username/test.js:7:13)8 at callFn (/Users/username/node_modules/mocha/lib/runnable.js:334:21)9 at Test.Runnable.run (/Users/username/node_modules/mocha/lib/runnable.js:327:7)10 at Runner.runTest (/Users/username/node_modules/mocha/lib/runner.js:429:10)11 at next (/Users/username/node_modules/mocha/lib/runner.js:341:14)12 at next (/Users/username/node_modules/mocha/lib/runner.js:285:14)13 at Immediate._onImmediate (/Users/username/node_modules/mocha/lib/runner.js:319:5)14 at processImmediate [as _immediateCallback] (timers.js:383:17)15at AssertionError (native)16at Context.<anonymous> (/Users/username/test.js:7:13)17at callFn (/Users/username/node_modules/mocha/lib/runnable.js:334:21)18at Test.Runnable.run (/Users/username/node_modules/mocha/lib/runnable.js:327:7)19at Runner.runTest (/Users/username/node_modules/mocha/lib/runner.js:429:10)20at next (/Users/username/node_modules/mocha/lib/runner.js:341:14)21at next (/Users/username/node_modules/mocha/lib/runner.js:285:14)22at Immediate._onImmediate (/Users/username/node_modules/mocha/lib/runner.js

Full Screen

Using AI Code Generation

copy

Full Screen

1var unexpected = require('unexpected');2var expect = unexpected.clone();3var obj = {a:1,b:2};4var value = expect(obj, 'to have key', 'a');5console.log(value);6var unexpected = require('unexpected');7var expect = unexpected.clone();8var obj = {a:1,b:2};9var value = expect(obj, 'to have key', 'a');10console.log(value);11var unexpected = require('unexpected');12var expect = unexpected.clone();13var obj = {a:1,b:2};14var value = expect(obj, 'to have key', 'b');15console.log(value);16var unexpected = require('unexpected');17var expect = unexpected.clone();18var obj = {a:1,b:2};19var value = expect(obj, 'to have key', 'c');20console.log(value);21var unexpected = require('unexpected');22var expect = unexpected.clone();23var obj = {a:1,b:2};24var value = expect(obj, 'to have key', 'c');25console.log(value);26var unexpected = require('unexpected');27var expect = unexpected.clone();28var obj = {a:1,b:2};29var value = expect(obj, 'to have key', 'a');30console.log(value);31var unexpected = require('unexpected');32var expect = unexpected.clone();33var obj = {a:1,b:2};34var value = expect(obj, 'to have key', 'b');35console.log(value);

Full Screen

Using AI Code Generation

copy

Full Screen

1var unexpectedObject = require('./unexpectedObject');2var result = unexpectedObject.valueForKey('name');3console.log(result);4var unexpectedObject = {5 valueForKey: function (key) {6 return this[key];7 }8};9module.exports = unexpectedObject;

Full Screen

Using AI Code Generation

copy

Full Screen

1console.log("Running test.js");2var test = require('./test2.js');3console.log(test);4var test2 = test.valueForKey("a");5console.log(test2);6console.log("Running test2.js");7var test = {8};9module.exports = test;10{ a: 'test' }11console.log("Running test2.js");12var test = function() {13 return {14 };15};16module.exports = test();17{ a: 'test' }18console.log("Running test2.js");19var test = function() {20 return {21 b: function() {22 return "test2";23 }24 };25};26module.exports = test();27console.log("Running test.js");28var test = require('./test2.js');29console.log(test);30var test2 = test.b();31console.log(test2);

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 unexpected 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