How to use d.getStatus method in Appium Base Driver

Best JavaScript code snippet using appium-base-driver

mainReducer.js

Source:mainReducer.js Github

copy

Full Screen

1import {getConfig} from '../config';2export const reducer = (state, action) => {3 console.log('dispatch', action);4 const merge = (field, data) => {5 return {6 ...state,7 [field]: {...state[field], ...data}8 };9 };10 const getConfiguredInitState = () => {11 return {12 ...initialState,13 app: {...state.app}14 };15 };16 let data = {};17 switch (action.type) {18 case getStatus(ACTION_LOCAL_AUTH, STATUS_START):19 if (action.data && action.data.isQuiet) {20 return state;21 } else {22 return merge('user', {status: USER_STATUS_CHECKING});23 }24 case getStatus(ACTION_LOCAL_AUTH, STATUS_SUCCESS):25 return merge('user', {status: USER_STATUS_LOGGED, ...action.data});26 case getStatus(ACTION_LOCAL_AUTH, STATUS_FAIL):27 return merge('user', {status: USER_STATUS_NOT_LOGGED});28 case getStatus(ACTION_SIGNIN, STATUS_INIT):29 return getConfiguredInitState();30 case getStatus(ACTION_SIGNIN, STATUS_START):31 data = {log: [], status: '', inProcess: true, errorMessage: ''};32 return merge('signin', data);33 case getStatus(ACTION_SIGNIN, STATUS_FAIL):34 data = {inProcess: false, errorMessage: action.data.message};35 return merge('signin', data);36 case getStatus(ACTION_SIGNIN, STATUS_SUCCESS):37 return merge('user', {38 status: USER_STATUS_LOGGED,39 username: action.data.username,40 usernameHash: action.data.usernameHash41 });42 case getStatus(ACTION_SIGNIN, STATUS_COMPLETE):43 data = {inProcess: false};44 return merge('signin', data);45 case getStatus(ACTION_SIGNIN, STATUS_LOG):46 data = {log: [...state.signin.log, action.data], status: action.data, inProcess: true};47 return merge('signin', data);48 case getStatus(ACTION_SIGNUP, STATUS_INIT):49 data = {log: [], status: '', inProcess: false, errorMessage: '', isMining: false};50 return merge('signup', data);51 case getStatus(ACTION_SIGNUP, STATUS_START):52 data = {log: [], status: '', inProcess: true, errorMessage: ''};53 return merge('signup', data);54 case getStatus(ACTION_SIGNUP, STATUS_FAIL):55 data = {inProcess: false, errorMessage: action.data.message};56 return merge('signup', data);57 case getStatus(ACTION_SIGNUP, STATUS_SUCCESS):58 data = {inProcess: false, isMining: true, minedInfo: {}};59 return merge('signup', data);60 case getStatus(ACTION_SIGNUP, STATUS_MINED):61 data = {isMining: false, minedInfo: action.data};62 return merge('signup', data);63 case getStatus(ACTION_SIGNUP, STATUS_COMPLETE):64 data = {inProcess: false};65 return merge('signup', data);66 case getStatus(ACTION_SIGNUP, STATUS_LOG):67 data = {log: [...state.signup.log, action.data], status: action.data, inProcess: true};68 return merge('signup', data);69 case getStatus(ACTION_CHANGE_PASSWORD, STATUS_INIT):70 data = {log: [], status: '', inProcess: false, errorMessage: ''};71 return merge('password', data);72 case getStatus(ACTION_CHANGE_PASSWORD, STATUS_START):73 data = {log: [], status: '', inProcess: true, errorMessage: ''};74 return merge('password', data);75 case getStatus(ACTION_CHANGE_PASSWORD, STATUS_FAIL):76 data = {errorMessage: action.data.message};77 return merge('password', data);78 case getStatus(ACTION_CHANGE_PASSWORD, STATUS_COMPLETE):79 data = {inProcess: false};80 return merge('password', data);81 case getStatus(ACTION_CHANGE_PASSWORD, STATUS_LOG):82 data = {log: [...state.password.log, action.data], status: action.data, inProcess: true};83 return merge('password', data);84 case getStatus(ACTION_CREATE_INVITE, STATUS_START):85 data = {inProcessCreation: true, errorMessage: ''};86 return merge('invite', data);87 case getStatus(ACTION_CREATE_INVITE, STATUS_FAIL):88 data = {errorMessage: action.data.message};89 return merge('invite', data);90 case getStatus(ACTION_CREATE_INVITE, STATUS_SUCCESS):91 data = {createdInvites: [...state.invite.createdInvites, action.data]};92 return merge('invite', data);93 case getStatus(ACTION_CREATE_INVITE, STATUS_COMPLETE):94 data = {inProcessCreation: false};95 return merge('invite', data);96 case getStatus(ACTION_GET_INVITES, STATUS_INIT):97 data = {98 log: [],99 status: '',100 inProcessCreation: false,101 inProcessReceiving: false,102 errorMessage: '',103 invites: []104 };105 return merge('invite', data);106 case getStatus(ACTION_GET_INVITES, STATUS_START):107 data = {108 log: [],109 status: '',110 inProcessCreation: false,111 inProcessReceiving: true,112 errorMessage: '',113 invites: []114 };115 return merge('invite', data);116 case getStatus(ACTION_GET_INVITES, STATUS_FAIL):117 data = {errorMessage: action.data.message};118 return merge('invite', data);119 case getStatus(ACTION_GET_INVITES, STATUS_SUCCESS):120 data = {invites: action.data};121 return merge('invite', data);122 case getStatus(ACTION_GET_INVITES, STATUS_COMPLETE):123 data = {inProcessReceiving: false};124 return merge('invite', data);125 case getStatus(ACTION_GET_INVITES, STATUS_LOG):126 data = {log: [...state.invite.log, action.data], status: action.data, inProcessReceiving: true};127 return merge('invite', data);128 case getStatus(ACTION_GET_INVITE, STATUS_SUCCESS):129 data = {inviteInfo: {...state.invite.inviteInfo, [action.data.inviteAddress]: action.data}};130 //console.log(data);131 return merge('invite', data);132 case getStatus(ACTION_LOGOUT, STATUS_SUCCESS):133 return getConfiguredInitState();134 case getStatus(ACTION_GET_BALANCE, STATUS_SUCCESS):135 //console.log(action.data);136 return merge('user', {balance: action.data});137 case getStatus(ACTION_APP_INFO, STATUS_START):138 data = {139 id: action.data,140 allowedUrls: [],141 title: '',142 description: '',143 isAppLoading: true,144 errorMessage: ''145 };146 return merge('authorizeApp', data);147 case getStatus(ACTION_APP_INFO, STATUS_FAIL):148 data = {isAppLoading: false, errorMessage: action.data.message};149 return merge('authorizeApp', data);150 case getStatus(ACTION_APP_INFO, STATUS_SUCCESS):151 data = {152 id: action.data.id,153 usernameHash: action.data.usernameHash,154 title: action.data.title,155 description: action.data.description,156 allowedUrls: action.data.allowedUrls,157 isAppLoading: false158 };159 return merge('authorizeApp', data);160 case getStatus(ACTION_SESSION, STATUS_START):161 data = {log: [], status: '', isSessionCreating: true, errorMessage: ''};162 return merge('authorizeApp', data);163 /*case getStatus(ACTION_SESSION, STATUS_FAIL):164 data = {inProcess: false, errorMessage: action.data.message};165 return merge('authorizeApp', data);166 case getStatus(ACTION_SESSION, STATUS_SUCCESS):167 data = {168 id: action.data.id,169 title: action.data.title,170 description: action.data.description,171 inProcess: false172 };173 return merge('authorizeApp', data);*/174 case getStatus(ACTION_SESSION, STATUS_COMPLETE):175 data = {log: [], status: '', isSessionCreating: false};176 return merge('authorizeApp', data);177 case getStatus(ACTION_SESSION, STATUS_LOG):178 data = {log: [...state.authorizeApp.log, action.data], status: action.data, isSessionCreating: true};179 return merge('authorizeApp', data);180 case getStatus(ACTION_GET_MY_APPS, STATUS_START):181 data = {inProcessReceiving: true, errorMessage: ''};182 return merge('myApps', data);183 case getStatus(ACTION_GET_MY_APPS, STATUS_FAIL):184 data = {errorMessage: action.data.message};185 return merge('myApps', data);186 case getStatus(ACTION_GET_MY_APPS, STATUS_SUCCESS):187 data = {apps: action.data};188 return merge('myApps', data);189 case getStatus(ACTION_GET_MY_APPS, STATUS_COMPLETE):190 data = {inProcessReceiving: false,};191 return merge('myApps', data);192 case getStatus(ACTION_CREATE_MY_APP, STATUS_START):193 data = {inProcessCreation: true, errorMessage: ''};194 return merge('myApps', data);195 case getStatus(ACTION_CREATE_MY_APP, STATUS_FAIL):196 data = {errorMessage: action.data.message};197 return merge('myApps', data);198 /*case getStatus(ACTION_CREATE_MY_APP, STATUS_SUCCESS):199 data = {apps: action.data};200 return merge('myApps', data);*/201 case getStatus(ACTION_CREATE_MY_APP, STATUS_COMPLETE):202 data = {inProcessCreation: false,};203 return merge('myApps', data);204 case getStatus(ACTION_GET_MY_APPS_INFO, STATUS_START):205 data = {inProcessReceiving: true, errorMessage: ''};206 return merge('appsInfo', data);207 case getStatus(ACTION_GET_MY_APPS_INFO, STATUS_FAIL):208 data = {errorMessage: action.data.message};209 return merge('appsInfo', data);210 case getStatus(ACTION_GET_MY_APPS_INFO, STATUS_SUCCESS):211 //data = {apps: action.data};212 return merge('appsInfo', action.data);213 case getStatus(ACTION_GET_MY_APPS_INFO, STATUS_COMPLETE):214 data = {inProcessReceiving: false,};215 return merge('appsInfo', data);216 case getStatus(ACTION_GET_MY_SESSIONS, STATUS_START):217 data = {inProcessReceiving: true, errorMessage: ''};218 return merge('mySessions', data);219 case getStatus(ACTION_GET_MY_SESSIONS, STATUS_FAIL):220 data = {errorMessage: action.data.message};221 return merge('mySessions', data);222 case getStatus(ACTION_GET_MY_SESSIONS, STATUS_SUCCESS):223 data = {sessions: action.data};224 return merge('mySessions', data);225 case getStatus(ACTION_GET_MY_SESSIONS, STATUS_COMPLETE):226 data = {inProcessReceiving: false,};227 return merge('mySessions', data);228 case getStatus(ACTION_GET_TREZOR_ADDRESSES, STATUS_START):229 data = {inProcessReceiving: true, errorMessage: ''};230 return merge('trezorAddresses', data);231 case getStatus(ACTION_GET_TREZOR_ADDRESSES, STATUS_FAIL):232 data = {errorMessage: action.data.message};233 return merge('trezorAddresses', data);234 case getStatus(ACTION_GET_TREZOR_ADDRESSES, STATUS_SUCCESS):235 data = {addresses: action.data.addresses, publicKey: action.data.publicKey};236 return merge('trezorAddresses', data);237 case getStatus(ACTION_GET_TREZOR_ADDRESSES, STATUS_COMPLETE):238 data = {inProcessReceiving: false,};239 return merge('trezorAddresses', data);240 case getStatus(ACTION_EDIT_MY_APP, STATUS_START):241 data = {inProcessEditing: true, errorMessage: ''};242 return merge('myApps', data);243 case getStatus(ACTION_EDIT_MY_APP, STATUS_FAIL):244 data = {errorMessage: action.data.message};245 return merge('myApps', data);246 case getStatus(ACTION_EDIT_MY_APP, STATUS_SUCCESS):247 //data = {apps: action.data};248 //return merge('myApps', action.data);249 return state;250 case getStatus(ACTION_EDIT_MY_APP, STATUS_COMPLETE):251 data = {inProcessEditing: false,};252 return merge('myApps', data);253 case getStatus(ACTION_RESET_PASSWORD, STATUS_START):254 data = {inProcess: true, errorMessage: ''};255 return merge('resetPasswordData', data);256 case getStatus(ACTION_RESET_PASSWORD, STATUS_FAIL):257 data = {errorMessage: action.data.message};258 return merge('resetPasswordData', data);259 /*case getStatus(ACTION_RESET_PASSWORD, STATUS_SUCCESS):260 return state;*/261 case getStatus(ACTION_RESET_PASSWORD, STATUS_COMPLETE):262 data = {inProcess: false,};263 return merge('resetPasswordData', data);264 case getStatus(ACTION_SET_INVITE_RESET, STATUS_START):265 data = {inProcess: true};266 return merge('settings', data);267 case getStatus(ACTION_SET_INVITE_RESET, STATUS_SUCCESS):268 data = {inviteReset: action.data.toString()};269 return merge('settings', data);270 case getStatus(ACTION_SET_INVITE_RESET, STATUS_COMPLETE):271 data = {inProcess: false};272 return merge('settings', data);273 case getStatus(ACTION_GET_INVITE_INFO, STATUS_START):274 data = {info: {inProcess: true, errorMessage: ''}};275 return merge('invite', data);276 case getStatus(ACTION_GET_INVITE_INFO, STATUS_SUCCESS):277 data = {info: action.data};278 return merge('invite', data);279 case getStatus(ACTION_GET_INVITE_INFO, STATUS_COMPLETE):280 data = {info: {...state.invite.info, inProcess: false}};281 return merge('invite', data);282 case getStatus(ACTION_GET_SETTINGS, STATUS_START):283 data = {inProcess: true};284 return merge('settings', data);285 case getStatus(ACTION_GET_SETTINGS, STATUS_SUCCESS):286 return merge('settings', action.data);287 case getStatus(ACTION_GET_SETTINGS, STATUS_COMPLETE):288 data = {inProcess: false};289 return merge('settings', data);290 case getStatus(ACTION_GET_SESSION_APP, STATUS_START):291 data = {inProcess: true, errorMessage: ''};292 return merge('sessionApp', data);293 case getStatus(ACTION_GET_SESSION_APP, STATUS_SUCCESS):294 return merge('sessionApp', action.data);295 case getStatus(ACTION_GET_SESSION_APP, STATUS_FAIL):296 data = {errorMessage: action.data.message};297 return merge('sessionApp', data);298 case getStatus(ACTION_GET_SESSION_APP, STATUS_COMPLETE):299 data = {inProcess: false};300 return merge('sessionApp', data);301 case getStatus(ACTION_CLOSE_SESSION, STATUS_START):302 data = {inProcessClose: true, closeId: action.data.logId};303 return merge('mySessions', data);304 case getStatus(ACTION_CLOSE_SESSION, STATUS_SUCCESS):305 // JSON.stringify/parse because object not correct clones306 let sessions = JSON.parse(JSON.stringify(state.mySessions.sessions));307 sessions = sessions.map(sourceItem => {308 const item = {...sourceItem};309 if (item.id === action.startData.logId) {310 item.returnValues.iv = '';311 }312 return item;313 });314 return merge('mySessions', {sessions});315 case getStatus(ACTION_CLOSE_SESSION, STATUS_COMPLETE):316 data = {inProcessClose: false, closeId: null};317 return merge('mySessions', data);318 case getStatus(ACTION_GET_LOGIC_CONTRACT, STATUS_SUCCESS):319 data = {smartContractLogicAddress: action.data,};320 return merge('app', data);321 case getStatus(ACTION_GET_INVITE_PRICE, STATUS_START):322 return merge('invite', {inProcessReceivePrice: true});323 case getStatus(ACTION_GET_INVITE_PRICE, STATUS_FAIL):324 return merge('invite', {errorMessage: action.data});325 case getStatus(ACTION_GET_INVITE_PRICE, STATUS_SUCCESS):326 return merge('invite', {...action.data});327 case getStatus(ACTION_GET_INVITE_PRICE, STATUS_COMPLETE):328 return merge('invite', {inProcessReceivePrice: false});329 case getStatus(ACTION_ALLOW_APP, STATUS_SUCCESS):330 data = {transactionHash: action.data.transactionHash};331 return merge('sessionApp', data);332 case getStatus(ACTION_ALLOW_APP, STATUS_FAIL):333 data = {errorMessage: action.data.message};334 return merge('authorizeApp', data);335 case getStatus(ACTION_SELF_APP_INFO, STATUS_INIT):336 return merge('app', action.data);337 default:338 return state;339 }340};341export const USER_STATUS_NOT_LOGGED = 'not_logged';342export const USER_STATUS_LOGGED = 'logged';343export const USER_STATUS_CHECKING = 'checking_auth';344export const initialState = {345 user: {346 isLoggedIn: function () {347 return this.status === USER_STATUS_LOGGED;348 },349 isCheckingAuth: function () {350 return this.status === USER_STATUS_CHECKING;351 },352 status: USER_STATUS_NOT_LOGGED,353 username: '',354 usernameHash: '',355 balance: {356 original: null,357 web: null,358 },359 wallet: {360 address: '',361 privateKey: '',362 }363 },364 sessionApp: {365 inProcess: false,366 errorMessage: ''367 },368 resetPasswordData: {369 inProcess: false,370 errorMessage: ''371 },372 settings: {373 inProcess: false,374 inviteReset: null375 },376 signup: {377 inProcess: false,378 isMining: false,379 minedInfo: {},380 status: '',381 log: [],382 errorMessage: ''383 },384 signin: {385 inProcess: false,386 status: '',387 log: [],388 errorMessage: ''389 },390 app: {391 network: '',392 provider: '',393 smartContractAddress: '',394 smartContractLogicAddress: '',395 currency: ''396 },397 authorizeApp: {398 id: null,399 title: '',400 description: '',401 usernameHash: '',402 allowedUrls: [],403 isAppLoading: false,404 isSessionCreating: false,405 status: '',406 log: [],407 errorMessage: ''408 },409 invite: {410 inProcessCreation: false,411 inProcessReceiving: false,412 inProcessReceivePrice: false,413 status: '',414 log: [],415 invites: [],416 inviteInfo: {},417 errorMessage: '',418 createdInvites: [],419 info: {},420 price: null421 },422 myApps: {423 inProcessCreation: false,424 inProcessEditing: false,425 inProcessReceiving: false,426 status: '',427 errorMessage: '',428 log: [],429 apps: []430 },431 appsInfo: {432 inProcessReceiving: false,433 errorMessage: ''434 },435 mySessions: {436 inProcessReceiving: false,437 inProcessClose: false,438 closeId: null,439 errorMessage: '',440 sessions: []441 },442 trezorAddresses: {443 inProcessReceiving: false,444 errorMessage: '',445 addresses: [],446 publicKey: null447 },448 password: {449 inProcess: false,450 status: '',451 errorMessage: '',452 log: [],453 },454 config: getConfig(process.env.REACT_APP_NETWORK)455};456export const STATUS_INIT = 'init';457export const STATUS_START = 'start';458export const STATUS_SUCCESS = 'success';459export const STATUS_FAIL = 'fail';460export const STATUS_COMPLETE = 'complete';461export const STATUS_LOG = 'log';462export const STATUS_MINED = 'mined';463export const getStatus = (action, status) => {464 return `${action}_${status}`;465};466export const ACTION_LOCAL_AUTH = 'local_auth';467export const ACTION_SIGNIN = 'signin';468export const ACTION_LOGOUT = 'logout';469//export const ACTION_LOGOUT_APP = 'logout_app';470export const ACTION_SIGNUP = 'signup';471export const ACTION_INVITE = 'invite';472export const ACTION_SESSION = 'session';473export const ACTION_SELF_APP_INFO = 'self_app_info';474export const ACTION_APP_INFO = 'app_info';475export const ACTION_ALLOW_APP = 'allow_app';476export const ACTION_GET_SESSION_APP = 'get_session_app';477export const ACTION_GET_INVITES = 'get_invites';478export const ACTION_GET_INVITE = 'get_invite';479export const ACTION_CREATE_INVITE = 'create_invite';480export const ACTION_CHANGE_PASSWORD = 'change_password';481export const ACTION_GET_BALANCE = 'get_balance';482export const ACTION_GET_MY_APPS = 'get_my_apps';483export const ACTION_GET_MY_APPS_INFO = 'get_my_apps_info';484export const ACTION_CREATE_MY_APP = 'create_my_app';485export const ACTION_EDIT_MY_APP = 'edit_my_app';486export const ACTION_DELETE_MY_APP = 'delete_my_app';487export const ACTION_RESTORE_MY_APP = 'restore_my_app';488export const ACTION_GET_MY_SESSIONS = 'get_my_sessions';489export const ACTION_GET_TREZOR_ADDRESSES = 'get_trezor_addresses';490export const ACTION_GET_LOGIC_CONTRACT = 'get_logic_contract';491export const ACTION_GET_SETTINGS = 'get_settings';492export const ACTION_SET_INVITE_RESET = 'set_invite_reset';493export const ACTION_GET_INVITE_INFO = 'get_invite_info';494export const ACTION_RESET_PASSWORD = 'reset_password';495export const ACTION_CLOSE_SESSION = 'close_session';...

Full Screen

Full Screen

index.js

Source:index.js Github

copy

Full Screen

1// Copier le fichier pac.service --> /lib/systemd/system PUIS sudo systemctl enable pac ET sudo service pac start2// service pac start3// service pac restart4// service pac stop5// service pac status6// journalctl -u pac7const express = require('express'), app = express(), 8 cors = require('cors'),9 piPac = require('./piPac.js'), pac = new piPac(), 10 handleTimeout = 10, PORT = 4200,11 allowedOrigins = ['http://192.168.0.22:3500', 'http://photowatt.tbsoft.fr'];12app.use(express.urlencoded({ extended: true })).13use(express.json()).14use(cors({15 origin: function(origin, callback){16 if(!origin) return callback(null, true);17 if(allowedOrigins.indexOf(origin) === -1) return callback(new Error('The CORS policy for this site does not allow access from the specified Origin.'), false);18 return callback(null, true);19 }20 })).21use(express.static(__dirname + '/static', {extensions:['html']})).22get("/PacOn" , (req, res) => { console.log("/PacOn"); pac.pacOn(); res.json(pac.getStatus()); }).23get("/PacOff" , (req, res) => { console.log("/PacOff"); pac.pacOff(); res.json(pac.getStatus()); }).24get("/AutoPacOn" , (req, res) => { console.log("/AutoPacOn"); pac.AutoPacOn(); res.json(pac.getStatus()); }).25get("/AutoPacOff" , (req, res) => { console.log("/AutoPacOff"); pac.AutoPacOff(); res.json(pac.getStatus()); }).26get("/CircuOn" , (req, res) => { console.log("/CircuOn"); pac.circulateursOn(); res.json(pac.getStatus()); }).27get("/CircuOff" , (req, res) => { console.log("/CircuOff"); pac.circulateursOff(); res.json(pac.getStatus()); }).28get("/CircuBOn" , (req, res) => { console.log("/CircuBOn"); pac.circulateurBoutOn(); res.json(pac.getStatus()); }).29get("/CircuBOff" , (req, res) => { console.log("/CircuBOff"); pac.circulateurBoutOff(); res.json(pac.getStatus()); }).30get("/CircuPOn" , (req, res) => { console.log("/CircuPOn"); pac.circulateurPacOn(); res.json(pac.getStatus()); }).31get("/CircuPOff" , (req, res) => { console.log("/CircuPOff"); pac.circulateurPacOff(); res.json(pac.getStatus()); }).32get("/CircuROn" , (req, res) => { console.log("/CircuROn"); pac.circulateurResOn(); res.json(pac.getStatus()); }).33get("/CircuROff" , (req, res) => { console.log("/CircuROff"); pac.circulateurResOff(); res.json(pac.getStatus()); }).34get("/Semaine" , (req, res) => { console.log("/Semaine"); pac.semaine(); res.json(pac.getStatus()); }).35get("/Weekend" , (req, res) => { console.log("/Weekend"); pac.weekend(); res.json(pac.getStatus()); }).36get("/Etage" , (req, res) => { console.log("/Etage"); pac.etage(); res.json(pac.getStatus()); }).37get("/samOn" , (req, res) => { console.log("/samOn"); pac.samOn(); res.json(pac.getStatus()); }).38get("/samOff" , (req, res) => { console.log("/samOff"); pac.samOff(); res.json(pac.getStatus()); }).39get("/cuisineOn" , (req, res) => { console.log("/cuisineOn"); pac.cuisineOn(); res.json(pac.getStatus()); }).40get("/cuisineOff" , (req, res) => { console.log("/cuisineOff"); pac.cuisineOff(); res.json(pac.getStatus()); }).41get("/salonOn" , (req, res) => { console.log("/salonOn"); pac.salonOn(); res.json(pac.getStatus()); }).42get("/salonOff" , (req, res) => { console.log("/salonOff"); pac.salonOff(); res.json(pac.getStatus()); }).43get("/sdbOn" , (req, res) => { console.log("/sdbOn"); pac.sdbOn(); res.json(pac.getStatus()); }).44get("/sdbOff" , (req, res) => { console.log("/sdbOff"); pac.sdbOff(); res.json(pac.getStatus()); }).45get("/cacOn" , (req, res) => { console.log("/cacOn"); pac.cacOn(); res.json(pac.getStatus()); }).46get("/cacOff" , (req, res) => { console.log("/cacOff"); pac.cacOff(); res.json(pac.getStatus()); }).47get("/caPierreOn" , (req, res) => { console.log("/caPierreOn"); pac.caPierreOn(); res.json(pac.getStatus()); }).48get("/caPierreOff" , (req, res) => { console.log("/caPierreOff"); pac.caPierreOff(); res.json(pac.getStatus()); }).49get("/caJulienOn" , (req, res) => { console.log("/caJulienOn"); pac.caJulienOn(); res.json(pac.getStatus()); }).50get("/caJulienOff" , (req, res) => { console.log("/caJulienOff"); pac.caJulienOff(); res.json(pac.getStatus()); }).51get("/sdjOn" , (req, res) => { console.log("/sdjOn"); pac.sdjOn(); res.json(pac.getStatus()); }).52get("/sdjOff" , (req, res) => { console.log("/sdjOff"); pac.sdjOff(); res.json(pac.getStatus()); }).53get("/sddOn" , (req, res) => { console.log("/sddOn"); pac.sddOn(); res.json(pac.getStatus()); }).54get("/sddOff" , (req, res) => { console.log("/sddOff"); pac.sddOff(); res.json(pac.getStatus()); }).55get("/couloirOn" , (req, res) => { console.log("/couloirOn"); pac.couloirOn(); res.json(pac.getStatus()); }).56get("/couloirOff" , (req, res) => { console.log("/couloirOff"); pac.couloirOff(); res.json(pac.getStatus()); }).57get("/bureauOn" , (req, res) => { console.log("/bureauOn"); pac.bureauOn(); res.json(pac.getStatus()); }).58get("/bureauOff" , (req, res) => { console.log("/bureauOff"); pac.bureauOff(); res.json(pac.getStatus()); }).59get("/dressingOn" , (req, res) => { console.log("/dressingOn"); pac.dressingOn(); res.json(pac.getStatus()); }).60get("/dressingOff" , (req, res) => { console.log("/dressingOff"); pac.dressingOff(); res.json(pac.getStatus()); }).61get("/setAlpha" , (req, res) => { console.log("/setAlpha"); res.json(pac.setAlpha(+req.query.value)); }).62get("/getStatus" , (req, res) => { console.log("/getStatus"); res.json(pac.getStatus()); }).63get("/Consignes" , (req, res) => { console.log("/get Consignes"); res.json(pac.getConsignes()); }).64post("/Consignes" , (req, res) => { console.log("/set Consignes"); res.end(pac.setConsignes(JSON.parse(req.body.consignes))); }).65listen(PORT, () => {66 console.log(`Server running on port ${PORT}`);67 process.once('SIGTERM', function (code) { console.log('SIGTERM received...'); pac.stop(); }); 68 setInterval(() => pac.handle(), handleTimeout * 1000); 69 setInterval(() => pac.hacheur(), 0); ...

Full Screen

Full Screen

controller.js

Source:controller.js Github

copy

Full Screen

1import moment from 'moment';2import {GetStatus} from '.';3import {notFound, success} from '../../services/response/';4export const create = ({bodymen: {body}}, res, next) =>5 GetStatus.create(body)6 .then((getStatus) => getStatus.view(true))7 .then(success(res, 201))8 .catch(next);9export const index = ({querymen: {query, select, cursor}}, res, next) =>10 GetStatus.count(query)11 .then(count => GetStatus.find(query, select, cursor)12 .then((getStatuses) => ({13 count,14 rows: getStatuses.map((getStatus) => getStatus.view())15 }))16 )17 .then(success(res))18 .catch(next);19export const show = ({params}, res, next) =>20 GetStatus.findOne({identifier: params.id})21 .then(notFound(res))22 .then((getStatus) => getStatus ? getStatus.view() : null)23 .then(success(res))24 .catch(next);25export const update = ({bodymen: {body}, params}, res, next) =>26 GetStatus.findOne({identifier: params.id})27 .then(notFound(res))28 .then((getStatus) => {29 if (getStatus) {30 if (body.hasOwnProperty('motor')) {31 getStatus.markModified('motor');32 }33 if (body.hasOwnProperty('automate')) {34 getStatus.markModified('automate');35 }36 if (body.hasOwnProperty('cutOff')) {37 getStatus.markModified('cutOff');38 }39 if (body.hasOwnProperty('cutOffAt')) {40 body.cutOffAt = moment();41 getStatus.markModified('cutOffAt');42 }43 if (body.hasOwnProperty('tankFilled')) {44 getStatus.markModified('tankFilled');45 }46 if (body.hasOwnProperty('websocket')) {47 getStatus.markModified('websocket');48 }49 if (body.hasOwnProperty('waterHeight')) {50 getStatus.markModified('waterHeight');51 }52 if (body.hasOwnProperty('skipCutoff')) {53 getStatus.markModified('skipCutoff');54 }55 if (body.hasOwnProperty('devLogs')) {56 getStatus.markModified('devLogs');57 }58 if (body.hasOwnProperty('flowRate')) {59 getStatus.markModified('flowRate');60 }61 if (body.hasOwnProperty('maxMotorOnTime')) {62 getStatus.markModified('maxMotorOnTime');63 }64 if (body.hasOwnProperty('minMotorOnPercentage')) {65 getStatus.markModified('minMotorOnPercentage');66 }67 if (body.hasOwnProperty('quantity')) {68 getStatus.markModified('quantity');69 }70 if (body.hasOwnProperty('updatedByDevice')) {71 getStatus.markModified('updatedByDevice');72 }73 return Object.assign(getStatus, body).save();74 }75 })76 .then((getStatus) => getStatus ? getStatus.view(true) : null)77 .then(success(res))78 .catch(next);79export const destroy = ({params}, res, next) =>80 GetStatus.findById(params.id)81 .then(notFound(res))82 .then((getStatus) => getStatus ? getStatus.remove() : null)83 .then(success(res, 204))84 .catch(next);85export const initializeStatus = () => {86 return new Promise(function(resolve, reject) {87 GetStatus.findOne({identifier: 'status'})88 .then((getStatus) => {89 return resolve(getStatus ? getStatus.view() : null);90 })91 .catch(err => reject(err))92 })93};94export const updateStatus = (payload) => {95 return new Promise(function(resolve, reject) {96 GetStatus.findOne({identifier: 'status'})97 .then((getStatus) => {98 if (getStatus) {99 if (payload.hasOwnProperty('motor')) {100 getStatus.markModified('motor');101 }102 if (payload.hasOwnProperty('automate')) {103 getStatus.markModified('automate');104 }105 if (payload.hasOwnProperty('cutOff')) {106 getStatus.markModified('cutOff');107 }108 if (payload.hasOwnProperty('cutOffAt')) {109 payload.cutOffAt = moment();110 getStatus.markModified('cutOffAt');111 }112 if (payload.hasOwnProperty('tankFilled')) {113 getStatus.markModified('tankFilled');114 }115 if (payload.hasOwnProperty('websocket')) {116 getStatus.markModified('websocket');117 }118 if (payload.hasOwnProperty('waterHeight')) {119 getStatus.markModified('waterHeight');120 }121 if (payload.hasOwnProperty('skipCutoff')) {122 getStatus.markModified('skipCutoff');123 }124 if (payload.hasOwnProperty('devLogs')) {125 getStatus.markModified('devLogs');126 }127 if (payload.hasOwnProperty('flowRate')) {128 getStatus.markModified('flowRate');129 }130 if (payload.hasOwnProperty('maxMotorOnTime')) {131 getStatus.markModified('maxMotorOnTime');132 }133 if (payload.hasOwnProperty('minMotorOnPercentage')) {134 getStatus.markModified('minMotorOnPercentage');135 }136 if (payload.hasOwnProperty('quantity')) {137 getStatus.markModified('quantity');138 }139 if (payload.hasOwnProperty('updatedByDevice')) {140 getStatus.markModified('updatedByDevice');141 }142 return Object.assign(getStatus, payload).save();143 }144 })145 .then((getStatus) => {146 return resolve(getStatus ? getStatus.view() : null);147 })148 .catch(err => reject(err))149 })...

Full Screen

Full Screen

get-status.spec.js

Source:get-status.spec.js Github

copy

Full Screen

1const grpc = require('grpc')2const path = require('path')3const { expect, rewire, sinon } = require('test/test-helper')4const LndEngine = rewire(path.resolve(__dirname, '..', 'index'))5const getStatus = rewire(path.resolve(__dirname, 'get-status'))6const VERSION = '0.7.1-beta commit=v0.7.1-beta-rc1'7describe('get-status', () => {8 describe('getStatus', () => {9 let reverts = []10 let engine11 let getInfoStub12 let genSeedStub13 let getInfoResponse14 let statuses15 beforeEach(() => {16 getInfoResponse = {17 chains: [{ chain: 'bitcoin', network: 'testnet' }],18 version: VERSION,19 syncedToChain: true20 }21 getInfoStub = sinon.stub().resolves(getInfoResponse)22 genSeedStub = sinon.stub().resolves(true)23 statuses = LndEngine.__get__('ENGINE_STATUSES')24 engine = {25 minVersion: '0.7.0-beta',26 client: sinon.stub(),27 walletUnlocker: sinon.stub(),28 logger: {29 error: sinon.stub()30 },31 chainName: 'bitcoin'32 }33 reverts.push(getStatus.__set__('getInfo', getInfoStub))34 reverts.push(getStatus.__set__('genSeed', genSeedStub))35 })36 afterEach(() => {37 reverts.forEach(r => r())38 })39 context('engine is valid', () => {40 it('returns VALIDATED if the lnd engine is valid', async () => {41 expect(await getStatus.call(engine)).to.be.eql(statuses.VALIDATED)42 })43 })44 context('engines wallet needs to be created', () => {45 it('if getInfo rejects with UNIMPLEMENTED AND genSeed is a successful call', async () => {46 const error = new Error('Something Happened')47 error.code = grpc.status.UNIMPLEMENTED48 getInfoStub.rejects(error)49 expect(await getStatus.call(engine)).to.be.eql(statuses.NEEDS_WALLET)50 })51 })52 context('engine is unlocked', () => {53 it('returns UNLOCKED if getInfo returns a blank response', async () => {54 getInfoStub.resolves({})55 expect(await getStatus.call(engine)).to.be.eql(statuses.UNLOCKED)56 })57 })58 context('engine is locked', () => {59 it('if getInfo rejects with UNIMPLEMENTED AND genSeed rejects with `wallet exists`', async () => {60 const error = new Error('Something Happened')61 error.code = grpc.status.UNIMPLEMENTED62 getInfoStub.rejects(error)63 const WALLET_EXISTS_ERROR_MESSAGE = getStatus.__get__('WALLET_EXISTS_ERROR_MESSAGE')64 const walletExistsError = new Error(WALLET_EXISTS_ERROR_MESSAGE)65 genSeedStub.rejects(walletExistsError)66 expect(await getStatus.call(engine)).to.be.eql(statuses.LOCKED)67 })68 })69 context('engine is unavailable', () => {70 it('if getInfo returns a real error (non-unimplemented)', async () => {71 const error = new Error('Something Happened')72 error.code = 273 getInfoStub.rejects(error)74 expect(await getStatus.call(engine)).to.be.eql(statuses.UNAVAILABLE)75 })76 it('if getInfo rejects with UNIMPLEMENTED AND genSeed reject with real errors', async () => {77 const error = new Error('Something Happened')78 error.code = grpc.status.UNIMPLEMENTED79 getInfoStub.rejects(error)80 const walletExistsError = new Error('Something else happened')81 genSeedStub.rejects(walletExistsError)82 expect(await getStatus.call(engine)).to.be.eql(statuses.UNAVAILABLE)83 })84 })85 context('engine is unlocked', () => {86 it('returns UNLOCKED if getInfo returns a blank response', async () => {87 getInfoStub.resolves({})88 expect(await getStatus.call(engine)).to.be.eql(statuses.UNLOCKED)89 })90 it('returns UNLOCKED if getInfo returns more than one chain', async () => {91 getInfoStub.resolves({92 chains: [93 { chain: 'bitcoin', network: 'testnet' },94 { chain: 'litecoin', network: 'mainnet' }95 ],96 version: VERSION,97 syncedToChain: true98 })99 expect(await getStatus.call(engine)).to.be.eql(statuses.UNLOCKED)100 })101 it('returns UNLOCKED if chain names do not match', async () => {102 getInfoStub.resolves({103 chains: [{ chain: 'badnet', network: 'testnet' }]104 })105 expect(await getStatus.call(engine)).to.be.eql(statuses.UNLOCKED)106 })107 })108 context('engine is not synced', () => {109 it('returns NOT_SYNCED if getInfo returns syncedToChain as false', async () => {110 getInfoStub.resolves({111 chains: [{ chain: 'bitcoin', network: 'testnet' }],112 version: VERSION,113 syncedToChain: false114 })115 expect(await getStatus.call(engine)).to.be.eql(statuses.NOT_SYNCED)116 })117 })118 context('engine is an old version', () => {119 it('returns OLD_VERSION if getInfo returns an old version', async () => {120 getInfoStub.resolves({121 chains: [{ chain: 'bitcoin', network: 'testnet' }],122 version: '0.6.0-beta',123 syncedToChain: true124 })125 expect(await getStatus.call(engine)).to.be.eql(statuses.OLD_VERSION)126 })127 })128 })...

Full Screen

Full Screen

day11_1.js

Source:day11_1.js Github

copy

Full Screen

1var demo = 2`L.LL.LL.LL3LLLLLLL.LL4L.L.L..L..5LLLL.LL.LL6L.LL.LL.LL7L.LLLLL.LL8..L.L.....9LLLLLLLLLL10L.LLLLLL.L11L.LLLLL.LL`12var fs = require('fs');13var filename = "day11input.txt";14fs.readFile(filename, 'utf8', function (err, data) {15 if (err) throw err;16 model(data);17 //getFixes(data);18})19var countOccupiedAdjacent = function(x, y, data) {20 //console.log(getStatus(x,y,data));21 var output = {22 "occupied": 0,23 "empty": 0,24 "floor": 025 }26 if (getStatus(x,y-1,data) == "#") {27 output.occupied++;28 } else if (getStatus(x,y-1,data) == "L") {29 output.empty++;30 } else if (getStatus(x,y-1,data) == ".") {31 output.floor++;32 }33 if (getStatus(x+1,y,data) == "#") {34 output.occupied++;35 } else if (getStatus(x+1,y,data) == "L") {36 output.empty++;37 } else if (getStatus(x+1,y,data) == ".") {38 output.floor++;39 }40 if (getStatus(x+1,y-1,data) == "#") {41 output.occupied++;42 } else if (getStatus(x+1,y-1,data) == "L") {43 output.empty++;44 } else if (getStatus(x+1,y-1,data) == ".") {45 output.floor++;46 }47 if (getStatus(x+1,y+1,data) == "#") {48 output.occupied++;49 } else if (getStatus(x+1,y+1,data) == "L") {50 output.empty++;51 } else if (getStatus(x+1,y+1,data) == ".") {52 output.floor++;53 }54 if (getStatus(x,y+1,data) == "#") {55 output.occupied++;56 } else if (getStatus(x,y+1,data) == "L") {57 output.empty++;58 } else if (getStatus(x,y+1,data) == ".") {59 output.floor++;60 }61 if (getStatus(x-1,y+1,data) == "#") {62 output.occupied++;63 } else if (getStatus(x-1,y+1,data) == "L") {64 output.empty++;65 } else if (getStatus(x-1,y+1,data) == ".") {66 output.floor++;67 }68 if (getStatus(x-1,y,data) == "#") {69 output.occupied++;70 } else if (getStatus(x-1,y,data) == "L") {71 output.empty++;72 } else if (getStatus(x-1,y,data) == ".") {73 output.floor++;74 }75 if (getStatus(x-1,y-1,data) == "#") {76 output.occupied++;77 } else if (getStatus(x-1,y-1,data) == "L") {78 output.empty++;79 } else if (getStatus(x-1,y-1,data) == ".") {80 output.floor++;81 }82 83 return output;84}85var getStatus = function(x, y, data) {86 //console.log("X: " + x);87 //console.log("Y: " + y);88 //console.log("D.L: " + data.length);89 //console.log("D[x].L: " + data[x].length);90 91 /* if (y >= data.length || x < 0) {92 return "OOB";93 }94 if (x >= data[y].length || y < 0) {95 return "OOB";96 } */97 if (x < 0 || y < 0) {98 return "OOB";99 }100 if (y >= data.length) {101 return "OOB";102 }103 if (x >= data[y].length) {104 return "OOB";105 }106 var position = data[y][x];107 /* try {108 109 } catch(err) {110 console.log("X: " + x);111 console.log("Y: " + y);112 console.log("D.L: " + data.length);113 console.log("D[x].L: " + data[x].length);114 throw err;115 } */116 117 if (position == "L") {118 return "L";119 } else if (position == ".") {120 return ".";121 } else if (position == "#") {122 return "#"123 } else {124 return false;125 }126}127var mutateCell = function(x, y, data) {128 var check = countOccupiedAdjacent(x, y, data);129 var status = getStatus(x, y, data);130 if (status == "L" && check.occupied == 0) {131 return "#";132 } 133 if (status == "#" && check.occupied >= 4) {134 return "L";135 }136 return status;137}138var model = function(data, steps) {139 var input = data.split("\n");140 //console.log(input);141 var maxx = input[0].length;142 var maxy = input.length;143 var boards = [];144 145 console.log("playing board is " + maxx + " x " + maxy);146 for (var i = 0; i == i; i++) {147 console.log("doing step " + i);148 boards.push([]);149 var playingBoard;150 if (i == 0) {151 playingBoard = [...input];152 } else {153 playingBoard = [...boards[i-1]];154 }155 //console.log(playingBoard);156 playingBoard.forEach(function(row, y) {157 boards[i].push([]);158 var newRow = "";159 row.split("").forEach(function(col, x){160 newRow = newRow + mutateCell(x,y,playingBoard);161 if (x == row.split("").length-1) {162 boards[i][y] = newRow;163 }164 })165 })166 if (boards.length > 1) {167 if (boards[i].toString() == boards[i-1].toString()) {168 console.log("STABILIZED AFTER : " + i + " STEPS");169 console.log("Total seats occupied: ");170 console.log(boards[i].toString().replace(/[^#]/g, "").length)171 break;172 }173 }174 175 }176 /*177 input.forEach(function(row, y) {178 //console.log(row);179 row.split("").forEach(function(col, x){180 //countOccupied(x,y,input);181 })182 })183 */184 //console.log(countOccupiedAdjacent(0,0,input));185 //console.log(boards);186}187//model(demo, 3);...

Full Screen

Full Screen

basic.js

Source:basic.js Github

copy

Full Screen

1var pwdv = ["imabp"] // To print pwd 2let basic = (context,counter) => {3 4 return {5 help: () => {6 context.echo("Hello")7 context.echo('\nList of commands available:');8 context.echo('===========================\n');9 context.echo('> [[b;#44D544;]about]');10 context.echo('> [[b;#44D544;]contribute]');11 context.echo('> echo ----------- ' + counter.getStatus(0));12 context.echo('> pwd ------------ ' + counter.getStatus(1));13 context.echo('> cd ------------- ' + counter.getStatus(2));14 context.echo('> cd .. ---------- ' + counter.getStatus(3));15 context.echo('> ls ------------- ' + counter.getStatus(4));16 context.echo('> cd ~ ----------- ' + counter.getStatus(5));17 context.echo('> cat ------------ ' + counter.getStatus(6));18 context.echo('> touch ---------- ' + counter.getStatus(7));19 context.echo('> cp ------------- ' + counter.getStatus(8));20 context.echo('> rm ------------- ' + counter.getStatus(9));21 context.echo('> mkdir ---------- ' + counter.getStatus(10));22 context.echo('> clear ---------- ' + counter.getStatus(11));23 context.echo('> uname ---------- ' + counter.getStatus(12));24 context.echo('> date ---------- ' + counter.getStatus(13));25 context.echo('> ifconfig ------- ' + counter.getStatus(14));26 context.echo('> tty ------------ ' + counter.getStatus(15));27 context.echo('> history -------- ' + counter.getStatus(16));28 context.echo('\n');29 },30 echo: (text)=>{31 counter.setStatusTrue(0)32 context.echo(text + '\n');33 context.echo('> The [[b;#ff3300;]echo] command prints back your arguments.');34 context.echo('> Type [[b;#ff3300;]help] and check your first task is completed.');35 context.echo('> Now type [[b;#ff3300;]pwd] to continue.');36 },37 pwd: function() {38 counter.setStatusTrue(1)39 var pwdvNew = pwdv.join(',').replace(',', '/').split();40 context.echo("/home/" + pwdvNew + '\n');41 context.echo('> Everything in Linux is a file. Every file is organized in a hierarchical directory tree.\n' +42 '> The first directory in the filesystem is aptly named the root directory.\n' +43 '> To see where you are, you can use the [[b;#ff3300;]pwd] command, this command means “print working directory”\n' +44 'and it just shows you which directory you are in.');45 context.echo('> Now type [[b;#ff3300;]ls] to see the directories and files present in the current directory');46 },47 uname: () => {48 counter.setStatusTrue(12)49 let uname;50 if (navigator.appVersion.indexOf("Win") !== -1) uname = "Windows"; 51 if (navigator.appVersion.indexOf("Mac") !== -1) uname = "Mac"; 52 if (navigator.appVersion.indexOf("X11") !== -1) uname = "UNIX"; 53 if (navigator.appVersion.indexOf("Linux") !== -1) uname = "Linux"; 54 context.echo(`${uname}\n`);55 context.echo('> The [[b;#ff3300;]uname] command prints the operating system of the current machine.\n');56 context.echo('> Now type [[b;#ff3300;]date] to get current date and time.');57 },58 date: () => {59 counter.setStatusTrue(13)60 context.echo(`${new Date()}\n`);61 context.echo('> The [[b;#ff3300;]date] command will display the date in the timezone on which the operating system was configured. You must be the super user to change date and time.');62 context.echo('> Now type [[b;#ff3300;]ifconfig] to get interface configuration of the system.');63 }64 }65}...

Full Screen

Full Screen

player.test.js

Source:player.test.js Github

copy

Full Screen

...16 let isPresent = false;17 for (let i = 0; i < 10; i += 1) {18 for (let j = 0; j < 10; j += 1) {19 // eslint-disable-next-line no-continue20 if (!(p.board.getStatus(i, j).hasShip)) continue;21 if (p.board.getStatus(i, j).vehicle.length === 5 && p.board.getStatus(i, j).vehicle.name === 'carrier') isPresent = true;22 }23 }24 expect(isPresent).toBe(true);25});26test('there must be a battleship', () => {27 let isPresent = false;28 for (let i = 0; i < 10; i += 1) {29 for (let j = 0; j < 10; j += 1) {30 // eslint-disable-next-line no-continue31 if (!(p.board.getStatus(i, j).hasShip)) continue;32 if (p.board.getStatus(i, j).vehicle.length === 4 && p.board.getStatus(i, j).vehicle.name === 'battleship') isPresent = true;33 }34 }35 expect(isPresent).toBe(true);36});37test('there must be a cruiser', () => {38 let isPresent = false;39 for (let i = 0; i < 10; i += 1) {40 for (let j = 0; j < 10; j += 1) {41 // eslint-disable-next-line no-continue42 if (!(p.board.getStatus(i, j).hasShip)) continue;43 if (p.board.getStatus(i, j).vehicle.length === 3 && p.board.getStatus(i, j).vehicle.name === 'cruiser') isPresent = true;44 }45 }46 expect(isPresent).toBe(true);47});48test('there must be a submarine', () => {49 let isPresent = false;50 for (let i = 0; i < 10; i += 1) {51 for (let j = 0; j < 10; j += 1) {52 // eslint-disable-next-line no-continue53 if (!(p.board.getStatus(i, j).hasShip)) continue;54 if (p.board.getStatus(i, j).vehicle.length === 3 && p.board.getStatus(i, j).vehicle.name === 'submarine') isPresent = true;55 }56 }57 expect(isPresent).toBe(true);58});59test('there must be a destroyer', () => {60 let isPresent = false;61 for (let i = 0; i < 10; i += 1) {62 for (let j = 0; j < 10; j += 1) {63 // eslint-disable-next-line no-continue64 if (!(p.board.getStatus(i, j).hasShip)) continue;65 if (p.board.getStatus(i, j).vehicle.length === 2 && p.board.getStatus(i, j).vehicle.name === 'destroyer') isPresent = true;66 }67 }68 expect(isPresent).toBe(true);69});70test('player is not lost at the beginning', () => {71 expect(p.hasLost()).toBe(false);72});73test('player loses if all ships sink', () => {74 for (let i = 0; i < 10; i += 1) {75 for (let j = 0; j < 10; j += 1) {76 if (!p.board.getStatus(i, j).hasShip) continue;77 p.recieveAttack(i, j);78 }79 }80 expect(p.hasLost()).toBe(true);...

Full Screen

Full Screen

commonHelpers.js

Source:commonHelpers.js Github

copy

Full Screen

1import { getStatus, getLength } from "../commonHelpers"2describe("getStatus", () => {3 it("loading", () => {4 expect(getStatus("LCP", -1)).toEqual("loading")5 expect(getStatus("FID", -1)).toEqual("loading")6 expect(getStatus("CLS", -1)).toEqual("loading")7 })8 it("error", () => {9 expect(getStatus("LCP", 4001)).toEqual("error")10 expect(getStatus("FID", 500)).toEqual("error")11 expect(getStatus("CLS", 1)).toEqual("error")12 })13 it("notice", () => {14 expect(getStatus("LCP", 2501)).toEqual("notice")15 expect(getStatus("FID", 101)).toEqual("notice")16 expect(getStatus("CLS", 0.2)).toEqual("notice")17 })18 it("success", () => {19 expect(getStatus("LCP", 2500)).toEqual("success")20 expect(getStatus("FID", 100)).toEqual("success")21 expect(getStatus("CLS", 0.1)).toEqual("success")22 })23 it("default success", () => {24 expect(getStatus("test", 2500)).toEqual("success")25 })26})27describe("getLength", () => {28 it("default", () => {29 expect(getLength("none")).toEqual([0.3, 0.5, 0.2])30 })...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var webdriverio = require('webdriverio');2var options = {3 desiredCapabilities: {4 }5};6var client = webdriverio.remote(options);7 .init()8 .getStatus()9 .then(function(status) {10 console.log(status);11 })12 .end();13var webdriverio = require('webdriverio');14var options = {15 desiredCapabilities: {16 }17};18var client = webdriverio.remote(options);19 .init()20 .getDeviceTime()21 .then(function(time) {22 console.log(time);23 })24 .end();25var webdriverio = require('webdriverio');26var options = {27 desiredCapabilities: {28 }29};30var client = webdriverio.remote(options);31 .init()32 .getDeviceTime()33 .then(function(time) {34 console.log(time);35 })36 .end();37var webdriverio = require('webdriverio');38var options = {39 desiredCapabilities: {

Full Screen

Using AI Code Generation

copy

Full Screen

1const BaseDriver = require('appium-base-driver');2const d = new BaseDriver();3console.log(d.getStatus());4const AndroidDriver = require('appium-android-driver');5const d = new AndroidDriver();6console.log(d.getStatus());7build: {8 }9build: {10 capabilities: {11 }12 }13build: {14 capabilities: {15 }16 }

Full Screen

Using AI Code Generation

copy

Full Screen

1var webdriverio = require('webdriverio');2var options = {3desiredCapabilities: {4}5};6var client = webdriverio.remote(options);7.init()8.elementById('com.android.calculator2:id/digit_1')9.click()10.elementById('com.android.calculator2:id/digit_2')11.click()12.elementById('com.android.calculator2:id/digit_3')13.click()14.elementById('com.android.calculator2:id/digit_4')15.click()16.elementById('com.android.calculator2:id/digit_5')17.click()18.elementById('com.android.calculator2:id/digit_6')19.click()20.elementById('com.android.calculator2:id/digit_7')21.click()22.elementById('com.android.calculator2:id/digit_8')23.click()24.elementById('com.android.calculator2:id/digit_9')25.click()26.elementById('com.android.calculator2:id/digit_0')27.click()28.elementById('com.android.calculator2:id/op_add')29.click()30.elementById('com.android.calculator2:id/digit_1')31.click()32.elementById('com.android.calculator2:id/digit_2')33.click()34.elementById('com.android.calculator2:id/digit_3')35.click()36.elementById('com.android.calculator2:id/digit_4')37.click()38.elementById('com.android.calculator2:id/digit_5')39.click()40.elementById('com.android.calculator2:id/digit_6')41.click()42.elementById('com.android.calculator2:id/digit_7')43.click()44.elementById('com.android.calculator2:id/digit_8')45.click()46.elementById('com.android.calculator2:id/digit_9')47.click()48.elementById('com.android.calculator2:id/digit_0')49.click()50.elementById('com.android.calculator2:id/eq')51.click()52.elementById('com.android.calculator2:id/result')53.getText().then(function(text){54console.log(text);55})56.end();

Full Screen

Using AI Code Generation

copy

Full Screen

1var d = new AppiumDriver();2var status = d.getStatus();3console.log(status);4var d = new AppiumDriver();5var status = d.getStatus();6console.log(status);7var d = new AppiumDriver();8var status = d.getStatus();9console.log(status);10var d = new AppiumDriver();11var status = d.getStatus();12console.log(status);13var d = new AppiumDriver();14var status = d.getStatus();15console.log(status);16var d = new AppiumDriver();17var status = d.getStatus();18console.log(status);19var d = new AppiumDriver();20var status = d.getStatus();21console.log(status);22var d = new AppiumDriver();23var status = d.getStatus();24console.log(status);25var d = new AppiumDriver();26var status = d.getStatus();27console.log(status);28var d = new AppiumDriver();29var status = d.getStatus();30console.log(status);31var d = new AppiumDriver();32var status = d.getStatus();33console.log(status);34var d = new AppiumDriver();35var status = d.getStatus();36console.log(status);37var d = new AppiumDriver();38var status = d.getStatus();39console.log(status);40var d = new AppiumDriver();41var status = d.getStatus();42console.log(status);43var d = new AppiumDriver();44var status = d.getStatus();45console.log(status);46var d = new AppiumDriver();47var status = d.getStatus();48console.log(status);49var d = new AppiumDriver();50var status = d.getStatus();51console.log(status);

Full Screen

Using AI Code Generation

copy

Full Screen

1var wd = require('wd');2var desired = require('./desired');3var assert = require('assert');4desired.app = require('./app');5describe("ios simple", function () {6 this.timeout(300000);7 var driver;8 before(function () {9 driver = wd.promiseChainRemote("localhost", 4723);10 require("./logging").configure(driver);11 return driver.init(desired);12 });13 after(function () {14 .quit()15 .finally(function () { return driver.sauceJobStatus(true); });16 });17 it("should get status", function () {18 return driver.getStatus()19 .then(function (status) {20 assert.ok(status.build.revision);21 });22 });23});24exports.platformVersion = "8.1";25exports.deviceName = "iPhone Simulator";26exports.app = undefined;27exports.browserName = "";28exports.platformName = "iOS";29exports.newCommandTimeout = 60;30exports.fullReset = true;31{32 "scripts": {33 },34 "dependencies": {35 }36}

Full Screen

Using AI Code Generation

copy

Full Screen

1var wd = require('wd');2var assert = require('assert');3var desired = {4};5var driver = wd.promiseChainRemote('localhost', 4723);6 .init(desired)7 .then(function () {8 return driver.getStatus();9 })10 .then(function (status) {11 console.log(status);12 })13 .fin(function () { return driver.quit(); })14 .done();15info: Welcome to Appium v1.3.4 (REV 3e3a9a9d9f9b2f2f2c1d1e8d0d0e0d0b6f5b9e9b)

Full Screen

Using AI Code Generation

copy

Full Screen

1var d = new Driver();2d.getStatus(function(err, status) {3 console.log(status);4});51. createSession()62. deleteSession()73. getStatus()84. getSessions()95. getCapabilities()106. getSessions()117. performTouch()128. performMultiAction()139. performGesture()1410. performActions()1511. getSettings()1612. updateSettings()1713. getLogTypes()1814. getLog()

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 Appium Base Driver 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