How to use getStatus method in Appium Xcuitest Driver

Best JavaScript code snippet using appium-xcuitest-driver

1_testInvoiceManager.js

Source:1_testInvoiceManager.js Github

copy

Full Screen

...7 const manager = await InvoiceManager.deployed();8 const storage = await InvoiceStorage.deployed();9 assert.equal((await storage.getNumOfInvoices()), numOfInvoices);10 await manager.approveInvoice(1, [web3.utils.soliditySha3('hello'), web3.utils.soliditySha3('world')], 222);11 assert.equal(await storage.getStatus(0), 1);12 assert.deepEqual(await storage.getDataHash(0), [web3.utils.soliditySha3('hello'), web3.utils.soliditySha3('world')]);13 numOfInvoices++;14 assert.equal((await storage.getNumOfInvoices()), numOfInvoices);15 });16 it('approve same invoice and same bank bad status, no duplicates fail', async () => {17 const storage = await InvoiceStorage.deployed();18 const manager = await InvoiceManager.deployed();19 assert.equal(await storage.getStatus(0), 1);20 for (var i = 1; i <= 10; i++) {21 if (i !== 3) {22 await storage.setStatus(0, i);23 await manager.approveInvoice(1, [web3.utils.soliditySha3('hello'), web3.utils.soliditySha3('world')], 222);24 assert.notEqual(await storage.getStatus(0), 3);25 }26 }27 await storage.setStatus(0, 1);28 assert.equal((await storage.getNumOfInvoices()), numOfInvoices);29 });30 it('reverse non-existent invoice fail', async () => {31 const storage = await InvoiceStorage.deployed();32 const manager = await InvoiceManager.deployed();33 await manager.reverseInvoice(2, [web3.utils.soliditySha3('hello'), web3.utils.soliditySha3('world')], 222);34 assert.equal((await storage.getNumOfInvoices()), numOfInvoices);35 });36 it('reverse existing non-approved invoice, no duplicates fail', async () => {37 const storage = await InvoiceStorage.deployed();38 const manager = await InvoiceManager.deployed();39 assert.equal(await storage.getStatus(0), 1);40 for (var i = 1; i <= 10; i++) {41 if (i !== 1) {42 await storage.setStatus(0, i);43 await manager.reverseInvoice(1, [web3.utils.soliditySha3('hello'), web3.utils.soliditySha3('world')], 222);44 assert.equal(await storage.getStatus(0), i);45 }46 }47 await storage.setStatus(0, 1);48 assert.equal((await storage.getNumOfInvoices()), numOfInvoices);49 });50 it('reverse existing approved invoice, no duplicates success', async () => {51 const storage = await InvoiceStorage.deployed();52 const manager = await InvoiceManager.deployed();53 assert.equal(await storage.getStatus(0), 1);54 await manager.reverseInvoice(1, [web3.utils.soliditySha3('hello'), web3.utils.soliditySha3('world')], 222);55 assert.equal(await storage.getStatus(0), 3);56 assert.deepEqual(await storage.getDataHash(0), [web3.utils.soliditySha3('hello'), web3.utils.soliditySha3('world')]);57 });58 it('approve existing not reversed invoice, no duplicates fail', async () => {59 const storage = await InvoiceStorage.deployed();60 const manager = await InvoiceManager.deployed();61 assert.deepEqual(await storage.getDataHash(0), [web3.utils.soliditySha3('hello'), web3.utils.soliditySha3('world')]);62 for (var i = 2; i <= 10; i++) {63 if (i !== 3) {64 await storage.setStatus(0, i);65 await manager.approveInvoice(1, [web3.utils.soliditySha3('hello'), web3.utils.soliditySha3('world')], 222);66 assert.equal(await storage.getStatus(0), i);67 }68 }69 await storage.setStatus(0, 3);70 assert.equal((await storage.getNumOfInvoices()), numOfInvoices);71 });72 it('approve existing reversed invoice, no duplicates success', async () => {73 const storage = await InvoiceStorage.deployed();74 const manager = await InvoiceManager.deployed();75 assert.equal(await storage.getStatus(0), 3);76 await manager.approveInvoice(1, [web3.utils.soliditySha3('hello'), web3.utils.soliditySha3('world')], 222);77 assert.equal(await storage.getStatus(0), 1);78 assert.deepEqual(await storage.getDataHash(0), [web3.utils.soliditySha3('hello'), web3.utils.soliditySha3('world')]);79 assert.equal((await storage.getNumOfInvoices()), numOfInvoices);80 });81 it('finance non-existent invoice fail', async () => {82 const storage = await InvoiceStorage.deployed();83 const manager = await InvoiceManager.deployed();84 await manager.financeInvoice(2, [web3.utils.soliditySha3('hello'), web3.utils.soliditySha3('world')], 222);85 assert.equal((await storage.getNumOfInvoices()), numOfInvoices);86 });87 it('finance existing non-approved invoice, no duplicates fail', async () => {88 const storage = await InvoiceStorage.deployed();89 const manager = await InvoiceManager.deployed();90 assert.equal(await storage.getStatus(0), 1);91 for (var i = 2; i <= 10; i++) {92 if (i !== 1) {93 await storage.setStatus(0, i);94 await manager.financeInvoice(1, [web3.utils.soliditySha3('hello'), web3.utils.soliditySha3('world')], 222);95 assert.equal(await storage.getStatus(0), i);96 }97 }98 await storage.setStatus(0, 1);99 assert.equal((await storage.getNumOfInvoices()), numOfInvoices);100 });101 it('finance existing approved invoice, no duplicates success', async () => {102 const storage = await InvoiceStorage.deployed();103 const manager = await InvoiceManager.deployed();104 await manager.financeInvoice(1, [web3.utils.soliditySha3('hello'), web3.utils.soliditySha3('world')], 222);105 assert.equal(await storage.getStatus(0), 2);106 assert.deepEqual(await storage.getDataHash(0), [web3.utils.soliditySha3('hello'), web3.utils.soliditySha3('world')]);107 assert.equal((await storage.getNumOfInvoices()), numOfInvoices);108 });109 it('approve same invoice and different bank, one wrong status duplicate fail', async () => {110 const storage = await InvoiceStorage.deployed();111 const manager = await InvoiceManager.deployed();112 await manager.approveInvoice(1, [web3.utils.soliditySha3('second'), web3.utils.soliditySha3('wind')], 222);113 assert.equal(await storage.getStatus(1), 1);114 assert.deepEqual(await storage.getDataHash(1), [web3.utils.soliditySha3('second'), web3.utils.soliditySha3('wind')]);115 numOfInvoices++;116 for (var i = 4; i <= 10; i++) {117 await storage.setStatus(1, i);118 await manager.approveInvoice(2, [web3.utils.soliditySha3('second'), web3.utils.soliditySha3('wind')], 222);119 }120 await storage.setStatus(1, 1);121 assert.equal((await storage.getNumOfInvoices()), numOfInvoices);122 });123 it('approve same invoice and different bank, one financed duplicate success', async () => {124 const storage = await InvoiceStorage.deployed();125 const manager = await InvoiceManager.deployed();126 await manager.approveInvoice(2, [web3.utils.soliditySha3('hello'), web3.utils.soliditySha3('world')], 222);127 assert.equal(await storage.getStatus(0), 6);128 assert.equal(await storage.getStatus(2), 5);129 assert.deepEqual(await storage.getDataHash(0), [web3.utils.soliditySha3('hello'), web3.utils.soliditySha3('world')]);130 assert.deepEqual(await storage.getDataHash(2), [web3.utils.soliditySha3('hello'), web3.utils.soliditySha3('world')]);131 numOfInvoices++;132 assert.equal((await storage.getNumOfInvoices()), numOfInvoices);133 });134 it('approve same invoice and different bank, one approved duplicate success', async () => {135 const storage = await InvoiceStorage.deployed();136 const manager = await InvoiceManager.deployed();137 await manager.approveInvoice(1, [web3.utils.soliditySha3('third'), web3.utils.soliditySha3('bird')], 222);138 assert.equal(await storage.getStatus(3), 1);139 await manager.approveInvoice(2, [web3.utils.soliditySha3('third'), web3.utils.soliditySha3('bird')], 222);140 assert.equal(await storage.getStatus(3), 4);141 assert.equal(await storage.getStatus(4), 4);142 numOfInvoices += 2;143 assert.equal((await storage.getNumOfInvoices()), numOfInvoices);144 });145 it('approve same invoice and different bank, one reversed duplicate success', async () => {146 const storage = await InvoiceStorage.deployed();147 const manager = await InvoiceManager.deployed();148 await manager.approveInvoice(1, [web3.utils.soliditySha3('fourth'), web3.utils.soliditySha3('amendment')], 222);149 assert.equal(await storage.getStatus(5), 1);150 await manager.reverseInvoice(1, [web3.utils.soliditySha3('fourth'), web3.utils.soliditySha3('amendment')], 222);151 assert.equal(await storage.getStatus(5), 3);152 await manager.approveInvoice(2, [web3.utils.soliditySha3('fourth'), web3.utils.soliditySha3('amendment')], 222);153 assert.equal(await storage.getStatus(5), 8);154 assert.equal(await storage.getStatus(6), 1);155 numOfInvoices += 2;156 assert.equal((await storage.getNumOfInvoices()), numOfInvoices);157 });158 it('approve existing status 8 invoice, one approved duplicate success', async () => {159 const storage = await InvoiceStorage.deployed();160 const manager = await InvoiceManager.deployed();161 assert.equal(await storage.getStatus(5), 8);162 assert.equal(await storage.getStatus(6), 1);163 await manager.approveInvoice(1, [web3.utils.soliditySha3('fourth'), web3.utils.soliditySha3('amendment')], 222);164 assert.equal(await storage.getStatus(5), 4);165 assert.equal(await storage.getStatus(6), 4);166 assert.equal((await storage.getNumOfInvoices()), numOfInvoices);167 });168 it('reverse approved invoice, one wrong status duplicate fail', async () => {169 const storage = await InvoiceStorage.deployed();170 const manager = await InvoiceManager.deployed();171 assert.deepEqual(await storage.getDataHash(5), [web3.utils.soliditySha3('fourth'), web3.utils.soliditySha3('amendment')]);172 assert.deepEqual(await storage.getDataHash(6), [web3.utils.soliditySha3('fourth'), web3.utils.soliditySha3('amendment')]);173 assert.equal(await storage.getStatus(5), 4);174 assert.equal(await storage.getStatus(6), 4);175 for (var i = 1; i <= 10; i++) {176 if(i !== 4 && i !== 6 && i !== 8) {177 await storage.setStatus(6, i);178 await manager.reverseInvoice(1, [web3.utils.soliditySha3('fourth'), web3.utils.soliditySha3('amendment')], 222);179 assert.equal(await storage.getStatus(5), 4);180 assert.equal(await storage.getStatus(6), i);181 }182 }183 await storage.setStatus(6, 4);184 assert.equal((await storage.getNumOfInvoices()), numOfInvoices);185 });186 it('finance approved invoice, one wrong status duplicate fail', async () => {187 const storage = await InvoiceStorage.deployed();188 const manager = await InvoiceManager.deployed();189 assert.deepEqual(await storage.getDataHash(5), [web3.utils.soliditySha3('fourth'), web3.utils.soliditySha3('amendment')]);190 assert.deepEqual(await storage.getDataHash(6), [web3.utils.soliditySha3('fourth'), web3.utils.soliditySha3('amendment')]);191 assert.equal(await storage.getStatus(5), 4);192 assert.equal(await storage.getStatus(6), 4);193 for (var i = 1; i <= 10; i++) {194 if(i !== 4 && i !== 6 && i !== 8) {195 await storage.setStatus(6, i);196 await manager.financeInvoice(1, [web3.utils.soliditySha3('fourth'), web3.utils.soliditySha3('amendment')], 222);197 assert.equal(await storage.getStatus(5), 4);198 assert.equal(await storage.getStatus(6), i);199 }200 }201 await storage.setStatus(6, 4);202 assert.equal((await storage.getNumOfInvoices()), numOfInvoices);203 });204 it('reverse approved invoice, one status 4 duplicate success', async () => {205 const storage = await InvoiceStorage.deployed();206 const manager = await InvoiceManager.deployed();207 assert.deepEqual(await storage.getDataHash(5), [web3.utils.soliditySha3('fourth'), web3.utils.soliditySha3('amendment')]);208 assert.deepEqual(await storage.getDataHash(6), [web3.utils.soliditySha3('fourth'), web3.utils.soliditySha3('amendment')]);209 assert.equal(await storage.getStatus(5), 4);210 assert.equal(await storage.getStatus(6), 4);211 await manager.reverseInvoice(1, [web3.utils.soliditySha3('fourth'), web3.utils.soliditySha3('amendment')], 222);212 assert.equal(await storage.getStatus(5), 8);213 assert.equal(await storage.getStatus(6), 1);214 assert.equal((await storage.getNumOfInvoices()), numOfInvoices);215 });216 it('reverse approved invoice, one status 8 duplicate success', async () => {217 const storage = await InvoiceStorage.deployed();218 const manager = await InvoiceManager.deployed();219 assert.deepEqual(await storage.getDataHash(5), [web3.utils.soliditySha3('fourth'), web3.utils.soliditySha3('amendment')]);220 assert.deepEqual(await storage.getDataHash(6), [web3.utils.soliditySha3('fourth'), web3.utils.soliditySha3('amendment')]);221 assert.equal(await storage.getStatus(5), 8);222 assert.equal(await storage.getStatus(6), 1);223 await manager.reverseInvoice(2, [web3.utils.soliditySha3('fourth'), web3.utils.soliditySha3('amendment')], 222);224 assert.equal(await storage.getStatus(5), 3);225 assert.equal(await storage.getStatus(6), 3);226 assert.equal((await storage.getNumOfInvoices()), numOfInvoices);227 });228 it('finance approved invoice, one status 8 duplicate success', async () => {229 const storage = await InvoiceStorage.deployed();230 const manager = await InvoiceManager.deployed();231 await manager.approveInvoice(2, [web3.utils.soliditySha3('fourth'), web3.utils.soliditySha3('amendment')], 222);232 assert.equal(await storage.getStatus(5), 8);233 assert.equal(await storage.getStatus(6), 1);234 assert.deepEqual(await storage.getDataHash(5), [web3.utils.soliditySha3('fourth'), web3.utils.soliditySha3('amendment')]);235 assert.deepEqual(await storage.getDataHash(6), [web3.utils.soliditySha3('fourth'), web3.utils.soliditySha3('amendment')]);236 await manager.financeInvoice(2, [web3.utils.soliditySha3('fourth'), web3.utils.soliditySha3('amendment')], 222);237 assert.equal(await storage.getStatus(5), 9);238 assert.equal(await storage.getStatus(6), 2);239 assert.equal((await storage.getNumOfInvoices()), numOfInvoices);240 });241 it('finance approved invoice, one status 4 duplicate success', async () => {242 const storage = await InvoiceStorage.deployed();243 const manager = await InvoiceManager.deployed();244 await manager.approveInvoice(1, [web3.utils.soliditySha3('fifth'), web3.utils.soliditySha3('force')], 222);245 await manager.approveInvoice(2, [web3.utils.soliditySha3('fifth'), web3.utils.soliditySha3('force')], 222);246 await manager.financeInvoice(1, [web3.utils.soliditySha3('fifth'), web3.utils.soliditySha3('force')], 222);247 assert.equal(await storage.getStatus(7), 6);248 assert.equal(await storage.getStatus(8), 5);249 assert.deepEqual(await storage.getDataHash(7), [web3.utils.soliditySha3('fifth'), web3.utils.soliditySha3('force')]);250 assert.deepEqual(await storage.getDataHash(8), [web3.utils.soliditySha3('fifth'), web3.utils.soliditySha3('force')]);251 numOfInvoices += 2;252 assert.equal((await storage.getNumOfInvoices()), numOfInvoices);253 });254 it('reverse approved invoice, one status 6 duplicate success', async () => {255 const storage = await InvoiceStorage.deployed();256 const manager = await InvoiceManager.deployed();257 assert.deepEqual(await storage.getDataHash(7), [web3.utils.soliditySha3('fifth'), web3.utils.soliditySha3('force')]);258 assert.deepEqual(await storage.getDataHash(8), [web3.utils.soliditySha3('fifth'), web3.utils.soliditySha3('force')]);259 assert.equal(await storage.getStatus(7), 6);260 assert.equal(await storage.getStatus(8), 5);261 await manager.reverseInvoice(2, [web3.utils.soliditySha3('fifth'), web3.utils.soliditySha3('force')], 222);262 assert.equal(await storage.getStatus(7), 2);263 assert.equal(await storage.getStatus(8), 9);264 assert.equal((await storage.getNumOfInvoices()), numOfInvoices);265 });266 it('finance approved invoice, one status 6 duplicate success', async () => {267 const storage = await InvoiceStorage.deployed();268 const manager = await InvoiceManager.deployed();269 await manager.approveInvoice(2, [web3.utils.soliditySha3('fifth'), web3.utils.soliditySha3('force')], 222);270 assert.equal(await storage.getStatus(7), 6);271 assert.equal(await storage.getStatus(8), 5);272 assert.deepEqual(await storage.getDataHash(7), [web3.utils.soliditySha3('fifth'), web3.utils.soliditySha3('force')]);273 assert.deepEqual(await storage.getDataHash(8), [web3.utils.soliditySha3('fifth'), web3.utils.soliditySha3('force')]);274 await manager.financeInvoice(2, [web3.utils.soliditySha3('fifth'), web3.utils.soliditySha3('force')], 222);275 assert.equal(await storage.getStatus(7), 7);276 assert.equal(await storage.getStatus(8), 7);277 assert.equal((await storage.getNumOfInvoices()), numOfInvoices);278 });279 it('approve same invoice and different bank, multiple duplicates status 6 success', async () => {280 const storage = await InvoiceStorage.deployed();281 const manager = await InvoiceManager.deployed();282 await manager.approveInvoice(1, [web3.utils.soliditySha3('sixth'), web3.utils.soliditySha3('sense')], 222);283 await manager.approveInvoice(2, [web3.utils.soliditySha3('sixth'), web3.utils.soliditySha3('sense')], 222);284 await manager.financeInvoice(1, [web3.utils.soliditySha3('sixth'), web3.utils.soliditySha3('sense')], 222);285 assert.equal(await storage.getStatus(9), 6);286 assert.equal(await storage.getStatus(10), 5);287 await manager.approveInvoice(3, [web3.utils.soliditySha3('sixth'), web3.utils.soliditySha3('sense')], 222);288 assert.equal(await storage.getStatus(9), 6);289 assert.equal(await storage.getStatus(10), 5);290 assert.equal(await storage.getStatus(11), 5);291 assert.deepEqual(await storage.getDataHash(9), [web3.utils.soliditySha3('sixth'), web3.utils.soliditySha3('sense')]);292 assert.deepEqual(await storage.getDataHash(10), [web3.utils.soliditySha3('sixth'), web3.utils.soliditySha3('sense')]);293 assert.deepEqual(await storage.getDataHash(11), [web3.utils.soliditySha3('sixth'), web3.utils.soliditySha3('sense')]);294 numOfInvoices += 3;295 assert.equal((await storage.getNumOfInvoices()), numOfInvoices);296 });297 it('approve same invoice and different bank, multiple duplicates status 2 success', async () => {298 const storage = await InvoiceStorage.deployed();299 const manager = await InvoiceManager.deployed();300 assert.deepEqual(await storage.getDataHash(5), [web3.utils.soliditySha3('fourth'), web3.utils.soliditySha3('amendment')]);301 assert.deepEqual(await storage.getDataHash(6), [web3.utils.soliditySha3('fourth'), web3.utils.soliditySha3('amendment')]);302 assert.equal(await storage.getStatus(5), 9);303 assert.equal(await storage.getStatus(6), 2);304 await manager.approveInvoice(3, [web3.utils.soliditySha3('fourth'), web3.utils.soliditySha3('amendment')], 222);305 assert.equal(await storage.getStatus(5), 9);306 assert.equal(await storage.getStatus(6), 6);307 assert.equal(await storage.getStatus(12), 5);308 assert.deepEqual(await storage.getDataHash(5), [web3.utils.soliditySha3('fourth'), web3.utils.soliditySha3('amendment')]);309 assert.deepEqual(await storage.getDataHash(6), [web3.utils.soliditySha3('fourth'), web3.utils.soliditySha3('amendment')]);310 assert.deepEqual(await storage.getDataHash(12), [web3.utils.soliditySha3('fourth'), web3.utils.soliditySha3('amendment')]);311 numOfInvoices++;312 assert.equal((await storage.getNumOfInvoices()), numOfInvoices);313 });314 it('reverse same invoice and same bank, multiple duplicates status 6 success', async () => {315 const storage = await InvoiceStorage.deployed();316 const manager = await InvoiceManager.deployed();317 assert.deepEqual(await storage.getDataHash(5), [web3.utils.soliditySha3('fourth'), web3.utils.soliditySha3('amendment')]);318 assert.deepEqual(await storage.getDataHash(6), [web3.utils.soliditySha3('fourth'), web3.utils.soliditySha3('amendment')]);319 assert.deepEqual(await storage.getDataHash(12), [web3.utils.soliditySha3('fourth'), web3.utils.soliditySha3('amendment')]);320 await manager.approveInvoice(1, [web3.utils.soliditySha3('fourth'), web3.utils.soliditySha3('amendment')], 222);321 assert.equal(await storage.getStatus(5), 5);322 assert.equal(await storage.getStatus(6), 6);323 assert.equal(await storage.getStatus(12), 5);324 await manager.reverseInvoice(1, [web3.utils.soliditySha3('fourth'), web3.utils.soliditySha3('amendment')], 222);325 assert.equal(await storage.getStatus(5), 9);326 assert.equal(await storage.getStatus(6), 6);327 assert.equal(await storage.getStatus(12), 5);328 await manager.reverseInvoice(3, [web3.utils.soliditySha3('fourth'), web3.utils.soliditySha3('amendment')], 222);329 assert.equal(await storage.getStatus(5), 9);330 assert.equal(await storage.getStatus(6), 2);331 assert.equal(await storage.getStatus(12), 9);332 assert.equal((await storage.getNumOfInvoices()), numOfInvoices);333 });334 it('approve same invoice and different bank, multiple duplicates status 1 success', async () => {335 const storage = await InvoiceStorage.deployed();336 const manager = await InvoiceManager.deployed();337 await manager.approveInvoice(1, [web3.utils.soliditySha3('seventh'), web3.utils.soliditySha3('heaven')], 222);338 await manager.approveInvoice(2, [web3.utils.soliditySha3('seventh'), web3.utils.soliditySha3('heaven')], 222);339 await manager.reverseInvoice(2, [web3.utils.soliditySha3('seventh'), web3.utils.soliditySha3('heaven')], 222);340 assert.equal(await storage.getStatus(13), 1);341 assert.equal(await storage.getStatus(14), 8);342 await manager.approveInvoice(3, [web3.utils.soliditySha3('seventh'), web3.utils.soliditySha3('heaven')], 222);343 assert.equal(await storage.getStatus(13), 4);344 assert.equal(await storage.getStatus(14), 8);345 assert.equal(await storage.getStatus(15), 4);346 assert.deepEqual(await storage.getDataHash(13), [web3.utils.soliditySha3('seventh'), web3.utils.soliditySha3('heaven')]);347 assert.deepEqual(await storage.getDataHash(14), [web3.utils.soliditySha3('seventh'), web3.utils.soliditySha3('heaven')]);348 assert.deepEqual(await storage.getDataHash(15), [web3.utils.soliditySha3('seventh'), web3.utils.soliditySha3('heaven')]);349 numOfInvoices += 3;350 assert.equal((await storage.getNumOfInvoices()), numOfInvoices);351 });352 it('approve same invoice and same bank, multiple duplicates status 4 success', async () => {353 const storage = await InvoiceStorage.deployed();354 const manager = await InvoiceManager.deployed();355 assert.deepEqual(await storage.getDataHash(13), [web3.utils.soliditySha3('seventh'), web3.utils.soliditySha3('heaven')]);356 assert.deepEqual(await storage.getDataHash(14), [web3.utils.soliditySha3('seventh'), web3.utils.soliditySha3('heaven')]);357 assert.deepEqual(await storage.getDataHash(15), [web3.utils.soliditySha3('seventh'), web3.utils.soliditySha3('heaven')]);358 assert.equal(await storage.getStatus(13), 4);359 assert.equal(await storage.getStatus(14), 8);360 assert.equal(await storage.getStatus(15), 4);361 await manager.approveInvoice(2, [web3.utils.soliditySha3('seventh'), web3.utils.soliditySha3('heaven')], 222);362 assert.equal(await storage.getStatus(13), 4);363 assert.equal(await storage.getStatus(14), 4);364 assert.equal(await storage.getStatus(15), 4);365 assert.equal((await storage.getNumOfInvoices()), numOfInvoices);366 });367 it('reverse same invoice and same bank, multiple duplicates status 4 success', async () => {368 const storage = await InvoiceStorage.deployed();369 const manager = await InvoiceManager.deployed();370 assert.deepEqual(await storage.getDataHash(13), [web3.utils.soliditySha3('seventh'), web3.utils.soliditySha3('heaven')]);371 assert.deepEqual(await storage.getDataHash(14), [web3.utils.soliditySha3('seventh'), web3.utils.soliditySha3('heaven')]);372 assert.deepEqual(await storage.getDataHash(15), [web3.utils.soliditySha3('seventh'), web3.utils.soliditySha3('heaven')]);373 assert.equal(await storage.getStatus(13), 4);374 assert.equal(await storage.getStatus(14), 4);375 assert.equal(await storage.getStatus(15), 4);376 await manager.reverseInvoice(1, [web3.utils.soliditySha3('seventh'), web3.utils.soliditySha3('heaven')], 222);377 assert.equal(await storage.getStatus(13), 8);378 assert.equal(await storage.getStatus(14), 4);379 assert.equal(await storage.getStatus(15), 4);380 await manager.reverseInvoice(2, [web3.utils.soliditySha3('seventh'), web3.utils.soliditySha3('heaven')], 222);381 assert.equal(await storage.getStatus(13), 8);382 assert.equal(await storage.getStatus(14), 8);383 assert.equal(await storage.getStatus(15), 1);384 assert.equal((await storage.getNumOfInvoices()), numOfInvoices);385 });386 it('reverse same invoice and same bank, multiple duplicates status 8 ONLY success', async () => {387 const storage = await InvoiceStorage.deployed();388 const manager = await InvoiceManager.deployed();389 assert.deepEqual(await storage.getDataHash(13), [web3.utils.soliditySha3('seventh'), web3.utils.soliditySha3('heaven')]);390 assert.deepEqual(await storage.getDataHash(14), [web3.utils.soliditySha3('seventh'), web3.utils.soliditySha3('heaven')]);391 assert.deepEqual(await storage.getDataHash(15), [web3.utils.soliditySha3('seventh'), web3.utils.soliditySha3('heaven')]);392 assert.equal(await storage.getStatus(13), 8);393 assert.equal(await storage.getStatus(14), 8);394 assert.equal(await storage.getStatus(15), 1);395 await manager.reverseInvoice(3, [web3.utils.soliditySha3('seventh'), web3.utils.soliditySha3('heaven')], 222);396 assert.equal(await storage.getStatus(13), 3);397 assert.equal(await storage.getStatus(14), 3);398 assert.equal(await storage.getStatus(15), 3);399 assert.equal((await storage.getNumOfInvoices()), numOfInvoices);400 });401 it('approve same invoice and different bank, multiple duplicates status 3 ONLY success', async () => {402 const storage = await InvoiceStorage.deployed();403 const manager = await InvoiceManager.deployed();404 assert.deepEqual(await storage.getDataHash(13), [web3.utils.soliditySha3('seventh'), web3.utils.soliditySha3('heaven')]);405 assert.deepEqual(await storage.getDataHash(14), [web3.utils.soliditySha3('seventh'), web3.utils.soliditySha3('heaven')]);406 assert.deepEqual(await storage.getDataHash(15), [web3.utils.soliditySha3('seventh'), web3.utils.soliditySha3('heaven')]);407 assert.equal(await storage.getStatus(13), 3);408 assert.equal(await storage.getStatus(14), 3);409 assert.equal(await storage.getStatus(15), 3);410 await manager.approveInvoice(1, [web3.utils.soliditySha3('seventh'), web3.utils.soliditySha3('heaven')], 222);411 assert.equal(await storage.getStatus(13), 1);412 assert.equal(await storage.getStatus(14), 8);413 assert.equal(await storage.getStatus(15), 8);414 assert.equal((await storage.getNumOfInvoices()), numOfInvoices);415 });416 it('approve same invoice and different bank, multiple duplicates status 8 ONLY success', async () => {417 const storage = await InvoiceStorage.deployed();418 const manager = await InvoiceManager.deployed();419 await manager.approveInvoice(1, [web3.utils.soliditySha3('eighth'), web3.utils.soliditySha3('gate')], 222);420 await manager.approveInvoice(2, [web3.utils.soliditySha3('eighth'), web3.utils.soliditySha3('gate')], 222);421 assert.equal(await storage.getStatus(16), 4);422 assert.equal(await storage.getStatus(17), 4);423 await manager.approveInvoice(3, [web3.utils.soliditySha3('eighth'), web3.utils.soliditySha3('gate')], 222);424 assert.equal(await storage.getStatus(16), 4);425 assert.equal(await storage.getStatus(17), 4);426 assert.equal(await storage.getStatus(18), 4);427 assert.deepEqual(await storage.getDataHash(16), [web3.utils.soliditySha3('eighth'), web3.utils.soliditySha3('gate')]);428 assert.deepEqual(await storage.getDataHash(17), [web3.utils.soliditySha3('eighth'), web3.utils.soliditySha3('gate')]);429 assert.deepEqual(await storage.getDataHash(18), [web3.utils.soliditySha3('eighth'), web3.utils.soliditySha3('gate')]);430 numOfInvoices += 3;431 assert.equal((await storage.getNumOfInvoices()), numOfInvoices);432 });433 it('finance same invoice and same bank, multiple duplicates status 4 success', async () => {434 const storage = await InvoiceStorage.deployed();435 const manager = await InvoiceManager.deployed();436 await manager.approveInvoice(1, [web3.utils.soliditySha3('ninth'), web3.utils.soliditySha3('cloud')], 222);437 await manager.approveInvoice(2, [web3.utils.soliditySha3('ninth'), web3.utils.soliditySha3('cloud')], 222);438 await manager.approveInvoice(3, [web3.utils.soliditySha3('ninth'), web3.utils.soliditySha3('cloud')], 222);439 assert.deepEqual(await storage.getDataHash(19), [web3.utils.soliditySha3('ninth'), web3.utils.soliditySha3('cloud')]);440 assert.deepEqual(await storage.getDataHash(20), [web3.utils.soliditySha3('ninth'), web3.utils.soliditySha3('cloud')]);441 assert.deepEqual(await storage.getDataHash(21), [web3.utils.soliditySha3('ninth'), web3.utils.soliditySha3('cloud')]);442 assert.equal(await storage.getStatus(19), 4);443 assert.equal(await storage.getStatus(20), 4);444 assert.equal(await storage.getStatus(21), 4);445 await manager.reverseInvoice(1, [web3.utils.soliditySha3('ninth'), web3.utils.soliditySha3('cloud')], 222);446 assert.equal(await storage.getStatus(19), 8);447 assert.equal(await storage.getStatus(20), 4);448 assert.equal(await storage.getStatus(21), 4);449 await manager.financeInvoice(2, [web3.utils.soliditySha3('ninth'), web3.utils.soliditySha3('cloud')], 222);450 assert.equal(await storage.getStatus(19), 9);451 assert.equal(await storage.getStatus(20), 6);452 assert.equal(await storage.getStatus(21), 5);453 await manager.financeInvoice(1, [web3.utils.soliditySha3('ninth'), web3.utils.soliditySha3('cloud')], 222);454 assert.equal(await storage.getStatus(19), 9);455 assert.equal(await storage.getStatus(20), 6);456 assert.equal(await storage.getStatus(21), 5);457 numOfInvoices += 3;458 assert.deepEqual(await storage.getDataHash(16), [web3.utils.soliditySha3('eighth'), web3.utils.soliditySha3('gate')]);459 assert.deepEqual(await storage.getDataHash(17), [web3.utils.soliditySha3('eighth'), web3.utils.soliditySha3('gate')]);460 assert.deepEqual(await storage.getDataHash(18), [web3.utils.soliditySha3('eighth'), web3.utils.soliditySha3('gate')]);461 assert.equal(await storage.getStatus(16), 4);462 assert.equal(await storage.getStatus(17), 4);463 assert.equal(await storage.getStatus(18), 4);464 await manager.financeInvoice(1, [web3.utils.soliditySha3('eighth'), web3.utils.soliditySha3('gate')], 222);465 assert.equal(await storage.getStatus(16), 6);466 assert.equal(await storage.getStatus(17), 5);467 assert.equal(await storage.getStatus(18), 5);468 assert.equal((await storage.getNumOfInvoices()), numOfInvoices);469 });470 it('finance same invoice and same bank, multiple duplicates status 7 success', async () => {471 const storage = await InvoiceStorage.deployed();472 const manager = await InvoiceManager.deployed();473 assert.deepEqual(await storage.getDataHash(16), [web3.utils.soliditySha3('eighth'), web3.utils.soliditySha3('gate')]);474 assert.deepEqual(await storage.getDataHash(17), [web3.utils.soliditySha3('eighth'), web3.utils.soliditySha3('gate')]);475 assert.deepEqual(await storage.getDataHash(18), [web3.utils.soliditySha3('eighth'), web3.utils.soliditySha3('gate')]);476 assert.equal(await storage.getStatus(16), 6);477 assert.equal(await storage.getStatus(17), 5);478 assert.equal(await storage.getStatus(18), 5);479 await manager.financeInvoice(2, [web3.utils.soliditySha3('eighth'), web3.utils.soliditySha3('gate')], 222);480 assert.equal(await storage.getStatus(16), 7);481 assert.equal(await storage.getStatus(17), 7);482 assert.equal(await storage.getStatus(18), 5);483 assert.equal((await storage.getNumOfInvoices()), numOfInvoices);484 });485 it('finance same invoice and same bank, multiple duplicates status 8 ONLY success', async () => {486 const storage = await InvoiceStorage.deployed();487 const manager = await InvoiceManager.deployed();488 assert.deepEqual(await storage.getDataHash(13), [web3.utils.soliditySha3('seventh'), web3.utils.soliditySha3('heaven')]);489 assert.deepEqual(await storage.getDataHash(14), [web3.utils.soliditySha3('seventh'), web3.utils.soliditySha3('heaven')]);490 assert.deepEqual(await storage.getDataHash(15), [web3.utils.soliditySha3('seventh'), web3.utils.soliditySha3('heaven')]);491 assert.equal(await storage.getStatus(13), 1);492 assert.equal(await storage.getStatus(14), 8);493 assert.equal(await storage.getStatus(15), 8);494 await manager.financeInvoice(1, [web3.utils.soliditySha3('seventh'), web3.utils.soliditySha3('heaven')], 222);495 assert.equal(await storage.getStatus(13), 2);496 assert.equal(await storage.getStatus(14), 9);497 assert.equal(await storage.getStatus(15), 9);498 assert.equal((await storage.getNumOfInvoices()), numOfInvoices);499 });500 it('approve same invoice and same bank, multiple duplicates bad status (does not add invoice) fail', async () => {501 const storage = await InvoiceStorage.deployed();502 const manager = await InvoiceManager.deployed();503 await manager.approveInvoice(1, [web3.utils.soliditySha3('tenth'), web3.utils.soliditySha3('hen')], 222);504 await manager.approveInvoice(2, [web3.utils.soliditySha3('tenth'), web3.utils.soliditySha3('hen')], 222);505 await storage.setStatus(22, 9);506 await storage.setStatus(23, 9);507 await manager.approveInvoice(3, [web3.utils.soliditySha3('tenth'), web3.utils.soliditySha3('hen')], 222);508 assert.equal(await storage.getStatus(22), 9);509 assert.equal(await storage.getStatus(23), 9);510 numOfInvoices += 2;511 assert.equal((await storage.getNumOfInvoices()), numOfInvoices);512 });513 // await expectRevert(manager.useCode(514 // codeHashJSON.codeHashes[1],515 // { from: accounts[0] }516 // ), 'only voting machine has access');...

Full Screen

Full Screen

schedule.draf.js

Source:schedule.draf.js Github

copy

Full Screen

...235 item.icon = 'fa-calendar-o'236 item.colorIcon = 'blue'237 }238 if (item.schd_d01_m != null) {239 item.schd_d01_m = jet.getStatus(item.schd_d01_m)240 }241 if (item.schd_d01_a != null) {242 item.schd_d01_a = jet.getStatus(item.schd_d01_a)243 }244 if (item.schd_d01_n != null) {245 item.schd_d01_n = jet.getStatus(item.schd_d01_n)246 }247 if (item.schd_d02_m != null) {248 item.schd_d02_m = jet.getStatus(item.schd_d02_m)249 }250 if (item.schd_d02_a != null) {251 item.schd_d02_a = jet.getStatus(item.schd_d02_a)252 }253 if (item.schd_d02_n != null) {254 item.schd_d02_n = jet.getStatus(item.schd_d02_n)255 }256 if (item.schd_d03_m != null) {257 item.schd_d03_m = jet.getStatus(item.schd_d03_m)258 }259 if (item.schd_d03_a != null) {260 item.schd_d03_a = jet.getStatus(item.schd_d03_a)261 }262 if (item.schd_d03_n != null) {263 item.schd_d03_n = jet.getStatus(item.schd_d03_n)264 }265 if (item.schd_d04_m != null) {266 item.schd_d04_m = jet.getStatus(item.schd_d04_m)267 }268 if (item.schd_d04_a != null) {269 item.schd_d04_a = jet.getStatus(item.schd_d04_a)270 }271 if (item.schd_d04_n != null) {272 item.schd_d04_n = jet.getStatus(item.schd_d04_n)273 }274 if (item.schd_d05_m != null) {275 item.schd_d05_m = jet.getStatus(item.schd_d05_m)276 }277 if (item.schd_d05_a != null) {278 item.schd_d05_a = jet.getStatus(item.schd_d05_a)279 }280 if (item.schd_d05_n != null) {281 item.schd_d05_n = jet.getStatus(item.schd_d05_n)282 }283 if (item.schd_d06_m != null) {284 item.schd_d06_m = jet.getStatus(item.schd_d06_m)285 }286 if (item.schd_d06_a != null) {287 item.schd_d06_a = jet.getStatus(item.schd_d06_a)288 }289 if (item.schd_d06_n != null) {290 item.schd_d06_n = jet.getStatus(item.schd_d06_n)291 }292 if (item.schd_d07_m != null) {293 item.schd_d07_m = jet.getStatus(item.schd_d07_m)294 }295 if (item.schd_d07_a != null) {296 item.schd_d07_a = jet.getStatus(item.schd_d07_a)297 }298 if (item.schd_d07_n != null) {299 item.schd_d07_n = jet.getStatus(item.schd_d07_n)300 }301 if (item.schd_d08_m != null) {302 item.schd_d08_m = jet.getStatus(item.schd_d08_m)303 }304 if (item.schd_d08_a != null) {305 item.schd_d08_a = jet.getStatus(item.schd_d08_a)306 }307 if (item.schd_d08_n != null) {308 item.schd_d08_n = jet.getStatus(item.schd_d08_n)309 }310 if (item.schd_d09_m != null) {311 item.schd_d09_m = jet.getStatus(item.schd_d09_m)312 }313 if (item.schd_d09_a != null) {314 item.schd_d09_a = jet.getStatus(item.schd_d09_a)315 }316 if (item.schd_d09_n != null) {317 item.schd_d09_n = jet.getStatus(item.schd_d09_n)318 }319 if (item.schd_d10_m != null) {320 item.schd_d10_m = jet.getStatus(item.schd_d10_m)321 }322 if (item.schd_d10_a != null) {323 item.schd_d10_a = jet.getStatus(item.schd_d10_a)324 }325 if (item.schd_d10_n != null) {326 item.schd_d10_n = jet.getStatus(item.schd_d10_n)327 }328 if (item.schd_d11_m != null) {329 item.schd_d11_m = jet.getStatus(item.schd_d11_m)330 }331 if (item.schd_d11_a != null) {332 item.schd_d11_a = jet.getStatus(item.schd_d11_a)333 }334 if (item.schd_d11_n != null) {335 item.schd_d11_n = jet.getStatus(item.schd_d11_n)336 }337 if (item.schd_d12_m != null) {338 item.schd_d12_m = jet.getStatus(item.schd_d12_m)339 }340 if (item.schd_d12_a != null) {341 item.schd_d12_a = jet.getStatus(item.schd_d12_a)342 }343 if (item.schd_d12_n != null) {344 item.schd_d12_n = jet.getStatus(item.schd_d12_n)345 }346 if (item.schd_d13_m != null) {347 item.schd_d13_m = jet.getStatus(item.schd_d13_m)348 }349 if (item.schd_d13_a != null) {350 item.schd_d13_a = jet.getStatus(item.schd_d13_a)351 }352 if (item.schd_d13_n != null) {353 item.schd_d13_n = jet.getStatus(item.schd_d13_n)354 }355 if (item.schd_d14_m != null) {356 item.schd_d14_m = jet.getStatus(item.schd_d14_m)357 }358 if (item.schd_d14_a != null) {359 item.schd_d14_a = jet.getStatus(item.schd_d14_a)360 }361 if (item.schd_d14_n != null) {362 item.schd_d14_n = jet.getStatus(item.schd_d14_n)363 }364 if (item.schd_d15_m != null) {365 item.schd_d15_m = jet.getStatus(item.schd_d15_m)366 }367 if (item.schd_d15_a != null) {368 item.schd_d15_a = jet.getStatus(item.schd_d15_a)369 }370 if (item.schd_d15_n != null) {371 item.schd_d15_n = jet.getStatus(item.schd_d15_n)372 }373 if (item.schd_d16_m != null) {374 item.schd_d16_m = jet.getStatus(item.schd_d16_m)375 }376 if (item.schd_d16_a != null) {377 item.schd_d16_a = jet.getStatus(item.schd_d16_a)378 }379 if (item.schd_d16_n != null) {380 item.schd_d16_n = jet.getStatus(item.schd_d16_n)381 }382 if (item.schd_d17_m != null) {383 item.schd_d17_m = jet.getStatus(item.schd_d17_m)384 }385 if (item.schd_d17_a != null) {386 item.schd_d17_a = jet.getStatus(item.schd_d17_a)387 }388 if (item.schd_d17_n != null) {389 item.schd_d17_n = jet.getStatus(item.schd_d17_n)390 }391 if (item.schd_d18_m != null) {392 item.schd_d18_m = jet.getStatus(item.schd_d18_m)393 }394 if (item.schd_d18_a != null) {395 item.schd_d18_a = jet.getStatus(item.schd_d18_a)396 }397 if (item.schd_d18_n != null) {398 item.schd_d18_n = jet.getStatus(item.schd_d18_n)399 }400 if (item.schd_d19_m != null) {401 item.schd_d19_m = jet.getStatus(item.schd_d19_m)402 }403 if (item.schd_d19_a != null) {404 item.schd_d19_a = jet.getStatus(item.schd_d19_a)405 }406 if (item.schd_d19_n != null) {407 item.schd_d19_n = jet.getStatus(item.schd_d19_n)408 }409 if (item.schd_d20_m != null) {410 item.schd_d20_m = jet.getStatus(item.schd_d20_m)411 }412 if (item.schd_d20_a != null) {413 item.schd_d20_a = jet.getStatus(item.schd_d20_a)414 }415 if (item.schd_d20_n != null) {416 item.schd_d20_n = jet.getStatus(item.schd_d20_n)417 }418 if (item.schd_d21_m != null) {419 item.schd_d21_m = jet.getStatus(item.schd_d21_m)420 }421 if (item.schd_d21_a != null) {422 item.schd_d21_a = jet.getStatus(item.schd_d21_a)423 }424 if (item.schd_d21_n != null) {425 item.schd_d21_n = jet.getStatus(item.schd_d21_n)426 }427 if (item.schd_d22_m != null) {428 item.schd_d22_m = jet.getStatus(item.schd_d22_m)429 }430 if (item.schd_d22_a != null) {431 item.schd_d22_a = jet.getStatus(item.schd_d22_a)432 }433 if (item.schd_d22_n != null) {434 item.schd_d22_n = jet.getStatus(item.schd_d22_n)435 }436 if (item.schd_d23_m != null) {437 item.schd_d23_m = jet.getStatus(item.schd_d23_m)438 }439 if (item.schd_d23_a != null) {440 item.schd_d23_a = jet.getStatus(item.schd_d23_a)441 }442 if (item.schd_d23_n != null) {443 item.schd_d23_n = jet.getStatus(item.schd_d23_n)444 }445 if (item.schd_d24_m != null) {446 item.schd_d24_m = jet.getStatus(item.schd_d24_m)447 }448 if (item.schd_d24_a != null) {449 item.schd_d24_a = jet.getStatus(item.schd_d24_a)450 }451 if (item.schd_d24_n != null) {452 item.schd_d24_n = jet.getStatus(item.schd_d24_n)453 }454 if (item.schd_d25_m != null) {455 item.schd_d25_m = jet.getStatus(item.schd_d25_m)456 }457 if (item.schd_d25_a != null) {458 item.schd_d25_a = jet.getStatus(item.schd_d25_a)459 }460 if (item.schd_d25_n != null) {461 item.schd_d25_n = jet.getStatus(item.schd_d25_n)462 }463 if (item.schd_d26_m != null) {464 item.schd_d26_m = jet.getStatus(item.schd_d26_m)465 }466 if (item.schd_d26_a != null) {467 item.schd_d26_a = jet.getStatus(item.schd_d26_a)468 }469 if (item.schd_d26_n != null) {470 item.schd_d26_n = jet.getStatus(item.schd_d26_n)471 }472 if (item.schd_d27_m != null) {473 item.schd_d27_m = jet.getStatus(item.schd_d27_m)474 }475 if (item.schd_d27_a != null) {476 item.schd_d27_a = jet.getStatus(item.schd_d27_a)477 }478 if (item.schd_d27_n != null) {479 item.schd_d27_n = jet.getStatus(item.schd_d27_n)480 }481 if (item.schd_d28_m != null) {482 item.schd_d28_m = jet.getStatus(item.schd_d28_m)483 }484 if (item.schd_d28_a != null) {485 item.schd_d28_a = jet.getStatus(item.schd_d28_a)486 }487 if (item.schd_d28_n != null) {488 item.schd_d28_n = jet.getStatus(item.schd_d28_n)489 }490 if (item.schd_d29_m != null) {491 item.schd_d29_m = jet.getStatus(item.schd_d29_m)492 }493 if (item.schd_d29_a != null) {494 item.schd_d29_a = jet.getStatus(item.schd_d29_a)495 }496 if (item.schd_d29_n != null) {497 item.schd_d29_n = jet.getStatus(item.schd_d29_n)498 }499 if (item.schd_d30_m != null) {500 item.schd_d30_m = jet.getStatus(item.schd_d30_m)501 }502 if (item.schd_d30_a != null) {503 item.schd_d30_a = jet.getStatus(item.schd_d30_a)504 }505 if (item.schd_d30_n != null) {506 item.schd_d30_n = jet.getStatus(item.schd_d30_n)507 }508 if (item.schd_d31_m != null) {509 item.schd_d31_m = jet.getStatus(item.schd_d31_m)510 }511 if (item.schd_d31_a != null) {512 item.schd_d31_a = jet.getStatus(item.schd_d31_a)513 }514 if (item.schd_d31_n != null) {515 item.schd_d31_n = jet.getStatus(item.schd_d31_n)516 }517 // get ot518 // $http({519 // url:'API/LISTOFVALUE/sumDataTable.php',520 // method:'POST',521 // data:{522 // 'user_id':item.Mem_ID,523 // 'month_no':$scope.schObj.MONTHNO,524 // 'year_no':$scope.schObj.YEAR,525 // 'ward_no':$scope.schObj.COSTID526 // }527 // }).then(function (resp){528 // $scope.sumTotal = resp.data;529 $http({530 url:'API/DRAF/getUserSumOTData.php',531 method:'POST',532 data:{533 'user_id':item.Mem_ID,534 'month_id':$scope.schObj.MONTHNO,535 'year_id':$scope.schObj.YEAR,536 'ward_id':$scope.schObj.COSTID537 }538 }).then(function (resp){539 item.cTotal = resp.data;540 $scope.OTTotal = $scope.OTTotal + item.cTotal541 $rootScope.criteria.OTTotal = $rootScope.criteria.OTTotal + parseInt(item.cTotal)542 })543 $http({544 url:'API/DRAF/getUserSumHRData.php',545 method:'POST',546 data:{547 'user_id':item.Mem_ID,548 'month_id':$scope.schObj.MONTHNO,549 'year_id':$scope.schObj.YEAR,550 'ward_id':$scope.schObj.COSTID551 }552 }).then(function (resp){553 item.cHour = resp.data;554 if(item.schd_mphr == 0){555 item.cOT = parseInt(item.cHour)*(parseInt(item.Position_OTRate)/8)556 } else {557 item.cOT = parseInt(item.cHour)*(parseInt(item.schd_mphr))558 }559 item.cMoneyOT = Number(item.cOT.toFixed(1)).toLocaleString()560 $rootScope.criteria.OTMoneyTotal = $rootScope.criteria.OTMoneyTotal + parseInt(item.cOT)561 $rootScope.criteria.OTMoneyTotalStr = Number($rootScope.criteria.OTMoneyTotal.toFixed(1)).toLocaleString()562 })563 // })564 $http({565 url:'API/DRAF/getUserSumNMData.php',566 method:'POST',567 data:{568 'user_id':item.Mem_ID,569 'month_id':$scope.schObj.MONTHNO,570 'year_id':$scope.schObj.YEAR,571 'ward_id':$scope.schObj.COSTID572 }573 }).then(function (resp){574 item.sumNMTotal = resp.data575 $rootScope.criteria.NMTotal = $rootScope.criteria.NMTotal + parseInt(item.sumNMTotal)576 })577 // $http({578 // url:'API/LISTOFVALUE/sumNMDataTable.php',579 // method:'POST',580 // data:{581 // 'user_id':item.Mem_ID,582 // 'month_no':$scope.schObj.MONTHNO,583 // 'year_no':$scope.schObj.YEAR,584 // 'ward_no':$scope.schObj.COSTID585 // }586 // }).then(function (resp){587 // $scope.sumNMTotalObj = resp.data;588 // item.sumNMTotal = $scope.sumNMTotalObj.NM589 // $rootScope.criteria.NMTotal = $rootScope.criteria.NMTotal + item.sumNMTotal590 // })591 $http({592 url:'API/SCHEDULE/DRAF/getScheduleOffCount.php',593 method:'POST',594 data:{595 'user_id':item.Mem_ID596 }597 }).then(function (resp){598 $scope.countSch = resp.data;599 item.stale = parseInt($scope.countSch.stale)600 $rootScope.criteria.cStale = $rootScope.criteria.cStale + item.stale601 })602 })603 $scope.drawColorTable($scope.schObj.MONTHNO,$scope.schObj.YEAR)604 })605 })606 }607 $rootScope.criteria.search()608 $scope.drawColorTable = function (month,year){609 var str = year+"-"+month610 $scope.monthTotal = moment(str, "YYYY-MM").daysInMonth()611 $scope.monthTotalBtn = $scope.monthTotal + APP.TABLE_DRAF;612 var i = 1;613 while (i <= $scope.monthTotal) {614 $scope.colorNum(i,month,year)615 i++;616 }617 }618 $scope.checkBackup = function (params_ward,params_month,params_year){619 $http({620 url:'API/SCHEDULE/DRAF/checkBackupHasData.php',621 method:'POST',622 data:{623 'ward_id':params_ward,624 'month_id':params_month,625 'year_id':params_year626 }627 }).then(function (resp){628 $scope.checkBackupObj = resp.data;629 $rootScope.criteria.chbackup = $scope.checkBackupObj.c630 if($scope.checkBackupObj.c > 0){631 $scope.setBackupColor = 'green'632 $scope.setBackupIcon = 'fa-check-circle'633 $scope.setBackupStatus = 'บันทึกแล้ว'634 } else {635 $scope.setBackupColor = 'yellow'636 $scope.setBackupIcon = 'fa-question-circle'637 $scope.setBackupStatus = 'ไม่มีการบันทึก'638 }639 })640 }641 $scope.saveSeq = function (){642 console.log($rootScope.criteria.personalList);643 // jet.getStatus(item.schd_d27_m).then(function (m27){item.schd_d27_m = m27})644 myFunction.confirmSaveBox().result.then(function(ok) {645 if (ok) {646 if (jet.saveSeqService($rootScope.criteria.personalList) == 1){647 $scope.app.addAlert('gritter-success', 'การบันทึกเสร็จสมบูรณ์', 4000);648 }649 }650 })651 }652 $scope.saveTemp = function (){653 myFunction.confirmSaveBox().result.then(function(ok) {654 if (ok) {655 backup.save($scope.schObj).then(function (resp){656 if(resp == 1){657 $scope.app.addAlert('gritter-success', 'การบันทึกเสร็จสมบูรณ์', 4000);...

Full Screen

Full Screen

mainReducer.js

Source:mainReducer.js Github

copy

Full Screen

...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 () {...

Full Screen

Full Screen

keybinding.spec.js

Source:keybinding.spec.js Github

copy

Full Screen

1const pti = require('puppeteer-to-istanbul');2const puppeteer = require('puppeteer');3const path = require('path');4const testPage = path.resolve(__dirname, './test.html');5/** @type { import('puppeteer').Page } */6let page7let browser8let getStatus;9function sleep(time) {10 return new Promise((resolve) => {11 setTimeout(resolve, time);12 });13}14beforeAll(async () => {15 browser = await puppeteer.launch();16 page = await browser.newPage();17 await page.coverage.startJSCoverage();18 await page.goto(`file://${testPage}`);19 await page.evaluate(() => {20 window.handlerHelper = (handlerSymbol) => {21 const status = handlerSymbol + 'Status';22 window[handlerSymbol] = () => {23 window[status] = window[status] ? (window[status] + 1) : 1;24 };25 return window[handlerSymbol];26 }27 window.getHandler = (handlerSymbol) => {28 return window[handlerSymbol];29 }30 window.clearHelper = (handlerSymbol) => {31 delete window[handlerSymbol];32 delete window[handlerSymbol + 'Status'];33 }34 });35 getStatus = (handlerSymbol) => {36 return window[handlerSymbol + 'Status']37 }38});39afterAll(async () => {40 const jsCoverage = await page.coverage.stopJSCoverage();41 pti.write([...jsCoverage]);42 await browser.close();43});44describe('keybinding basic functionality', () => {45 beforeEach(async () => {46 await page.evaluate(() => {47 window.keybind = new Keybinding();48 });49 });50 afterEach(async () => {51 await page.evaluate(() => {52 window.keybind.destroy();53 delete window.keybind;54 clearHelper('case1');55 clearHelper('case2');56 clearHelper('case3');57 clearHelper('case4');58 clearHelper('case5'); 59 });60 });61 test('keybinding on/off method should work as expect', async () => {62 await page.evaluate(() => {63 keybind.on('ctrl + a', handlerHelper('case1'));64 });65 await page.keyboard.down('ControlLeft');66 await page.keyboard.down('a');67 await page.keyboard.up('ControlLeft');68 await page.keyboard.up('a');69 expect(await page.evaluate(getStatus, 'case1')).toBe(1);70 await page.keyboard.down('ControlLeft');71 await page.keyboard.down('a');72 await page.keyboard.up('ControlLeft');73 await page.keyboard.up('a');74 expect(await page.evaluate(getStatus, 'case1')).toBe(2);75 await page.evaluate(() => {76 keybind.off('ctrl + a', getHandler('case1'));77 });78 await page.keyboard.down('ControlLeft');79 await page.keyboard.down('a');80 await page.keyboard.up('ControlLeft');81 await page.keyboard.up('a');82 expect(await page.evaluate(getStatus, 'case1')).toBe(2);83 await page.evaluate(() => {84 clearHelper('case1');85 });86 })87 test('on/off method should be case-insensitive and space-trimming', async () => {88 await page.evaluate(() => {89 keybind.on('ShiFt + A', handlerHelper('case1'));90 });91 await page.keyboard.down('ShiftLeft');92 await page.keyboard.down('a');93 await page.keyboard.up('ShiftLeft');94 await page.keyboard.up('a');95 expect(await page.evaluate(getStatus, 'case1')).toBe(1);96 await page.evaluate(() => {97 keybind.off('shIFt + a', getHandler('case1'));98 });99 await page.keyboard.down('ShiftLeft');100 await page.keyboard.down('a');101 await page.keyboard.up('ShiftLeft');102 await page.keyboard.up('a');103 expect(await page.evaluate(getStatus, 'case1')).toBe(1);104 await page.evaluate(() => {105 clearHelper('case1');106 });107 });108 test('delay keyup event should work as expected', async() => {109 await page.evaluate(() => {110 keybind.on('shift + a', handlerHelper('case1'));111 });112 await page.keyboard.down('ShiftLeft');113 await page.keyboard.down('a');114 await sleep(100);115 await page.keyboard.up('a');116 expect(await page.evaluate(getStatus, 'case1')).toBe(1);117 await page.keyboard.down('a');118 await page.keyboard.up('a');119 expect(await page.evaluate(getStatus, 'case1')).toBe(2);120 await page.keyboard.up('ShiftLeft');121 });122 test('drop keyup event should work as expected', async () => {123 await page.evaluate(() => {124 keybind.on('shift + a', handlerHelper('case1'));125 });126 await page.keyboard.down('ShiftLeft');127 await page.keyboard.down('a');128 await sleep(100);129 expect(await page.evaluate(getStatus, 'case1')).toBe(1);130 await page.keyboard.down('a');131 await sleep(100);132 expect(await page.evaluate(getStatus, 'case1')).toBe(2);133 await page.keyboard.down('a');134 await sleep(100);135 expect(await page.evaluate(getStatus, 'case1')).toBe(3);136 await page.keyboard.up('ShiftLeft');137 });138 test('shift modifier', async () => {139 await page.evaluate(() => {140 keybind.on('shift + a', handlerHelper('case1'));141 });142 await page.keyboard.down('ShiftLeft');143 await page.keyboard.down('a');144 expect(await page.evaluate(getStatus, 'case1')).toBe(1);145 await page.keyboard.down('a');146 await page.keyboard.down('a');147 await page.keyboard.down('a');148 expect(await page.evaluate(getStatus, 'case1')).toBe(4);149 await page.keyboard.down('ShiftRight');150 expect(await page.evaluate(getStatus, 'case1')).toBe(4);151 await page.keyboard.up('a');152 await page.keyboard.up('ShiftLeft');153 await page.keyboard.up('ShiftRight');154 await page.evaluate(() => {155 keybind.off('shift + a', getHandler('case1'));156 clearHelper('case1');157 });158 });159 test.each(160 ['control', 'ctrl']161 )('control modifier: %s', async (key) => {162 const bindKey = `${key} + a`;163 await page.evaluate((bindKey) => {164 keybind.on(bindKey, handlerHelper('case1'));165 }, bindKey);166 await page.keyboard.down('ControlLeft');167 await page.keyboard.down('a');168 expect(await page.evaluate(getStatus, 'case1')).toBe(1);169 await page.keyboard.down('a');170 await page.keyboard.down('a');171 await page.keyboard.down('a');172 expect(await page.evaluate(getStatus, 'case1')).toBe(4);173 await page.keyboard.down('ControlRight');174 expect(await page.evaluate(getStatus, 'case1')).toBe(4);175 await page.keyboard.up('a');176 await page.keyboard.up('ControlLeft');177 await page.keyboard.up('ControlRight');178 await page.evaluate((bindKey) => {179 keybind.off(bindKey, getHandler('case1'));180 clearHelper('case1');181 }, bindKey);182 });183 test.each(184 ['meta', 'command', 'windows', 'cmd']185 )('meta modifier: %s', async (key) => {186 const bindKey = `${key} + a`;187 await page.evaluate((bindKey) => {188 keybind.on(bindKey, handlerHelper('case1'));189 }, bindKey);190 await page.keyboard.down('MetaLeft');191 await page.keyboard.down('a');192 expect(await page.evaluate(getStatus, 'case1')).toBe(1);193 await page.keyboard.down('a');194 await page.keyboard.down('a');195 await page.keyboard.down('a');196 expect(await page.evaluate(getStatus, 'case1')).toBe(4);197 await page.keyboard.down('MetaRight');198 expect(await page.evaluate(getStatus, 'case1')).toBe(4);199 await page.keyboard.up('a');200 await page.keyboard.up('MetaLeft');201 await page.keyboard.up('MetaRight');202 await page.evaluate((bindKey) => {203 keybind.off(bindKey, getHandler('case1'));204 clearHelper('case1');205 }, bindKey);206 });207 test.each(208 ['alt', 'option']209 )('alt modifier: %s', async (key) => {210 const bindKey = `${key} + a`;211 await page.evaluate((bindKey) => {212 keybind.on(bindKey, handlerHelper('case1'));213 }, bindKey);214 await page.keyboard.down('AltLeft');215 await page.keyboard.down('a');216 expect(await page.evaluate(getStatus, 'case1')).toBe(1);217 await page.keyboard.down('a');218 await page.keyboard.down('a');219 await page.keyboard.down('a');220 expect(await page.evaluate(getStatus, 'case1')).toBe(4);221 await page.keyboard.down('AltLeft');222 expect(await page.evaluate(getStatus, 'case1')).toBe(4);223 await page.keyboard.up('a');224 await page.keyboard.up('AltLeft');225 await page.keyboard.up('AltRight');226 await page.evaluate((bindKey) => {227 keybind.off(bindKey, getHandler('case1'));228 clearHelper('case1');229 }, bindKey);230 });231 test.each([232 ['left', 'ArrowLeft'],233 ['up', 'ArrowUp'],234 ['right', 'ArrowRight'],235 ['down', 'ArrowDown'],236 ['space', ' '],237 ['esc', 'Escape'],238 ['enter', 'Enter'],239 ['tab', 'Tab'],240 ...('1,2,3,4,5,6,7,8,9,10,11,12'.split(',').map(val => [`f${val}`, `F${val}`]))241 ])('special key: %s', async (bindKey, simulateKey) => {242 await page.evaluate((bindKey) => {243 keybind.on(bindKey, handlerHelper('case1'));244 }, bindKey);245 await page.keyboard.down(simulateKey);246 await page.keyboard.up(simulateKey);247 expect(await page.evaluate(getStatus, 'case1')).toBe(1);248 await page.keyboard.down(simulateKey);249 await page.keyboard.up(simulateKey);250 await page.keyboard.down(simulateKey);251 await page.keyboard.up(simulateKey);252 await page.keyboard.down(simulateKey);253 await page.keyboard.up(simulateKey);254 expect(await page.evaluate(getStatus, 'case1')).toBe(4);255 await page.evaluate((bindKey) => {256 keybind.off(bindKey, getHandler('case1'));257 }, bindKey);258 await page.keyboard.down(simulateKey);259 await page.keyboard.up(simulateKey);260 expect(await page.evaluate(getStatus, 'case1')).toBe(4);261 await page.evaluate(() => {262 clearHelper('case1');263 });264 });265 test('should not call handler after destroy', async() => {266 await page.evaluate(() => {267 window.keybind2 = new Keybinding();268 keybind2.on('ctrl + a', handlerHelper('case1'));269 })270 await page.keyboard.down('ControlLeft');271 await page.keyboard.down('a');272 await page.keyboard.up('ControlLeft');273 await page.keyboard.up('a');274 expect(await page.evaluate(getStatus, 'case1')).toBe(1);275 await page.keyboard.down('ControlLeft');276 await page.keyboard.down('a');277 await page.keyboard.up('ControlLeft');278 await page.keyboard.up('a');279 expect(await page.evaluate(getStatus, 'case1')).toBe(2);280 await page.evaluate(() => {281 window.keybind2.destroy();282 });283 await page.keyboard.down('ControlLeft');284 await page.keyboard.down('a');285 await page.keyboard.up('ControlLeft');286 await page.keyboard.up('a');287 expect(await page.evaluate(getStatus, 'case1')).toBe(2);288 await page.evaluate(() => {289 clearHelper('case1');290 delete window.keybind2;291 })292 });293});294describe('keybinding scope functionality', () => {295 beforeAll(async () => {296 await page.evaluate(() => {297 window.keybind = new Keybinding();298 });299 });300 afterAll(async () => {301 await page.evaluate(() => {302 window.keybind.destroy();303 delete window.keybind;304 });305 });306 beforeEach(async () => {307 await page.evaluate(() => {308 keybind.on('ctrl + a', handlerHelper('case1'));309 keybind.on('ctrl + a', handlerHelper('case2'), 'scope2');310 keybind.on('ctrl + a', handlerHelper('case3'), 'scope3');311 });312 });313 afterEach(async () => {314 await page.evaluate(() => {315 keybind.off('ctrl + a', getHandler('case1'));316 keybind.off('ctrl + a', getHandler('case2'), 'scope2');317 keybind.off('ctrl + a', getHandler('case3'), 'scope3');318 clearHelper('case1');319 clearHelper('case2');320 clearHelper('case3');321 });322 });323 test('default enable/disable should work as expected', async () => {324 await page.keyboard.down('ControlLeft');325 await page.keyboard.down('a');326 await page.keyboard.up('ControlLeft');327 await page.keyboard.up('a');328 expect(await page.evaluate(getStatus, 'case1')).toBe(1);329 expect(await page.evaluate(getStatus, 'case2')).toBe(1);330 expect(await page.evaluate(getStatus, 'case3')).toBe(1);331 await page.evaluate(() => {332 window.keybind.disable();333 });334 await page.keyboard.down('ControlLeft');335 await page.keyboard.down('a');336 await page.keyboard.up('ControlLeft');337 await page.keyboard.up('a');338 expect(await page.evaluate(getStatus, 'case1')).toBe(1);339 expect(await page.evaluate(getStatus, 'case2')).toBe(1);340 expect(await page.evaluate(getStatus, 'case3')).toBe(1);341 await page.evaluate(() => {342 window.keybind.enable();343 });344 await page.keyboard.down('ControlLeft');345 await page.keyboard.down('a');346 await page.keyboard.up('ControlLeft');347 await page.keyboard.up('a');348 expect(await page.evaluate(getStatus, 'case1')).toBe(2);349 expect(await page.evaluate(getStatus, 'case2')).toBe(2);350 expect(await page.evaluate(getStatus, 'case3')).toBe(2);351 });352 test('enable/disable should work with parameter', async () => {353 await page.keyboard.down('ControlLeft');354 await page.keyboard.down('a');355 await page.keyboard.up('ControlLeft');356 await page.keyboard.up('a');357 expect(await page.evaluate(getStatus, 'case1')).toBe(1);358 expect(await page.evaluate(getStatus, 'case2')).toBe(1);359 expect(await page.evaluate(getStatus, 'case3')).toBe(1);360 await page.evaluate(() => {361 keybind.disable('scope2');362 });363 await page.keyboard.down('ControlLeft');364 await page.keyboard.down('a');365 await page.keyboard.up('ControlLeft');366 await page.keyboard.up('a');367 expect(await page.evaluate(getStatus, 'case1')).toBe(2);368 expect(await page.evaluate(getStatus, 'case2')).toBe(1);369 expect(await page.evaluate(getStatus, 'case3')).toBe(2);370 await page.evaluate(() => {371 keybind.disable('scope3');372 });373 await page.keyboard.down('ControlLeft');374 await page.keyboard.down('a');375 await page.keyboard.up('ControlLeft');376 await page.keyboard.up('a');377 expect(await page.evaluate(getStatus, 'case1')).toBe(3);378 expect(await page.evaluate(getStatus, 'case2')).toBe(1);379 expect(await page.evaluate(getStatus, 'case3')).toBe(2);380 await page.evaluate(() => {381 keybind.enable();382 });383 await page.keyboard.down('ControlLeft');384 await page.keyboard.down('a');385 await page.keyboard.up('ControlLeft');386 await page.keyboard.up('a');387 expect(await page.evaluate(getStatus, 'case1')).toBe(4);388 expect(await page.evaluate(getStatus, 'case2')).toBe(2);389 expect(await page.evaluate(getStatus, 'case3')).toBe(3);390 });...

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

state_test.js

Source:state_test.js Github

copy

Full Screen

2var State = require('../lib/state.js');3describe('State', function() {4 describe('State()', function () {5 var s1 = State();6 it('should return pending when getStatus()', function() {7 var a = {};8 assert.equal('pending', s1.getStatus());9 });10 it('should return Error when run() beacuse no machine', function() {11 assert.throws(function () {12 s1.run();13 });14 });15 it('should return pending when after run() and get error', function() {16 assert.equal('pending', s1.getStatus());17 });18 it('should return pending when done() and run() get error', function() {19 assert.equal('pending', s1.done().getStatus());20 });21 });22 describe('State(machine, options)', function () {23 var i = 0;24 var machine = function () {25 return 'c';26 };27 var options = {28 afterDoing: function () {29 i++;30 },31 afterDone: function () {32 i++;33 }34 };35 var s1 = State(machine, options);36 it('should return pending when getStatus()', function() {37 var a = {};38 assert.equal('pending', s1.getStatus());39 });40 it('should return pending when done()', function() {41 assert.equal('pending', s1.done().getStatus());42 });43 it('should return "c" when run()', function() {44 assert.equal('c', s1.run());45 });46 it('should return 1 after run() and do afterDoing()', function() {47 assert.equal(1, i);48 });49 it('should return doing when after run()', function() {50 assert.equal('doing', s1.getStatus());51 });52 it('should return undefined when again run()', function() {53 assert.equal(undefined, s1.run());54 });55 it('should return 1 after again run() and do afterDoing()', function() {56 assert.equal(1, i);57 });58 it('should return doing when after again run()', function() {59 assert.equal('doing', s1.getStatus());60 });61 it('should return done when done()', function() {62 assert.equal('done', s1.done().getStatus());63 });64 it('should return 2 after done() and do afterDone()', function() {65 assert.equal(2, i);66 });67 it('should return done when agin done()', function() {68 assert.equal('done', s1.done().getStatus());69 });70 it('should return 2 after agin done() and do afterDone()', function() {71 assert.equal(2, i);72 });73 });74 describe('State(machine, options) and machine isPromise setTimeout 100', function () {75 var machine = function () {76 var promise = new Promise(function (resolve) {77 setTimeout(function () {78 resolve();79 }, 100);80 });81 return promise;82 };83 var s2 = State(machine2);84 var machine2 = function () {85 var promise = new Promise(function (resolve, reject) {86 setTimeout(function () {87 reject();88 }, 100);89 });90 return promise;91 };92 var s1 = State(machine);93 it('should return true when run() instanceof Promise', function() {94 assert.instanceOf(s1.run(), Promise);95 });96 it('should return false when agian run() instanceof Promise', function() {97 assert.notInstanceOf(s1.run(), Promise);98 });99 it('should return doing when after run() and getStatus()', function() {100 assert.equal('doing', s1.getStatus());101 });102 setTimeout(function () {103 it('should return done when after run() dalay 500 and getStatus() and promise is reslove', function() {104 assert.equal('done', s1.getStatus());105 });106 }, 500);107 setTimeout(function () {108 it('should return done when after run() dalay 500 and getStatus() and promise is reject', function() {109 assert.equal('done', s2.getStatus());110 });111 }, 500);112 });113 describe('State(machine, options) and machine like Promise', function () {114 var i = 0;115 var machine = function () {116 return {117 then: function (cb) {118 cb && cb();119 }120 };121 };122 var s1 = State(machine);123 s1.run();124 it('should return done when getStatus()', function() {125 var a = {};126 assert.equal('done', s1.getStatus());127 });128 });...

Full Screen

Full Screen

UpdateTab.js

Source:UpdateTab.js Github

copy

Full Screen

1// Copyright (c) 2019 LG Electronics, Inc.2//3// Licensed under the Apache License, Version 2.0 (the "License");4// you may not use this file except in compliance with the License.5// You may obtain a copy of the License at6//7// http://www.apache.org/licenses/LICENSE-2.08//9// Unless required by applicable law or agreed to in writing, software10// distributed under the License is distributed on an "AS IS" BASIS,11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.12// See the License for the specific language governing permissions and13// limitations under the License.14//15// SPDX-License-Identifier: Apache-2.016import React from 'react';17import {Layout, Cell, Row, Column} from '@enact/ui/Layout';18import {createToast, subscribe} from '../components/LunaAPI';19import ControlView from './ControlView';20import DetailView from './DetailView';21const SERVICE_SWUPDATER = 'com.webos.service.swupdater';22const URI_SERVICE_SWUPDATER = 'luna://' + SERVICE_SWUPDATER;23const ID_NONE = "";24const STATUS_NONE = "none";25const STATUS_COMPLETED = "completed";26class UpdateTab extends React.Component {27 constructor() {28 super();29 this.state = {30 id: ID_NONE,31 status: STATUS_NONE,32 softwareModules: [],33 };34 this.onGetStatus = this.onGetStatus.bind(this);35 }36 onGetStatus(res) {37 console.log("onGetStatus");38 const id = res.id || ID_NONE;39 const status = res.status || STATUS_NONE;40 const softwareModules = res.softwareModules || [];41 if (id !== ID_NONE && this.state.id === ID_NONE) {42 // createToast(`Update available<br> ${softwareModules[0].name} (${softwareModules[0].version})`);43 }44 if (status === STATUS_COMPLETED && this.state.status !== STATUS_COMPLETED) {45 // createToast(`Update completed<br> ${softwareModules[0].name} (${softwareModules[0].version})`);46 }47 this.setState({48 id: id,49 status: status,50 softwareModules: softwareModules,51 });52 }53 componentDidMount() {54 const {serverStatus} = this.props;55 if (serverStatus && serverStatus.connected) {56 this.getStatus = subscribe(URI_SERVICE_SWUPDATER, 'getStatus', {}, this.onGetStatus);57 }58 }59 componentWillUnmount() {60 if (this.getStatus) {61 this.getStatus.cancel();62 this.getStatus = null;63 }64 }65 shouldComponentUpdate(nextProps, nextState) {66 if (this.props.serverStatus !== nextProps.serverStatus) {67 if (nextProps.serverStatus.connected) {68 this.getStatus = subscribe(URI_SERVICE_SWUPDATER, 'getStatus', {}, this.onGetStatus);69 } else {70 if (this.getStatus) {71 this.getStatus.cancel();72 this.getStatus = null;73 }74 }75 return false;76 }77 return true;78 }79 render() {80 const {status, softwareModules} = this.state;81 return (82 <Layout style={{height: '100%'}}>83 <Cell size="25%">84 <ControlView actionId={this.state.id} status={status}/>85 </Cell>86 <Cell>87 <DetailView softwareModules={softwareModules}/>88 </Cell>89 </Layout>90 );91 }92}...

Full Screen

Full Screen

browser_gcli_inspect.js

Source:browser_gcli_inspect.js Github

copy

Full Screen

...42}43function testCreateCommands() {44 type("inspec");45 is(gcliterm.completeNode.textContent, " inspect", "Completion for \"inspec\"");46 is(requisition.getStatus().toString(), "ERROR", "inspec is ERROR");47 type("inspect");48 is(requisition.getStatus().toString(), "ERROR", "inspect is ERROR");49 type("inspect h1");50 is(requisition.getStatus().toString(), "ERROR", "inspect h1 is ERROR");51 type("inspect span");52 is(requisition.getStatus().toString(), "ERROR", "inspect span is ERROR");53 type("inspect div");54 is(requisition.getStatus().toString(), "VALID", "inspect div is VALID");55 type("inspect .someclass");56 is(requisition.getStatus().toString(), "VALID", "inspect .someclass is VALID");57 type("inspect #someid");58 is(requisition.getStatus().toString(), "VALID", "inspect #someid is VALID");59 type("inspect button[disabled]");60 is(requisition.getStatus().toString(), "VALID", "inspect button[disabled] is VALID");61 type("inspect p>strong");62 is(requisition.getStatus().toString(), "VALID", "inspect p>strong is VALID");63 type("inspect :root");64 is(requisition.getStatus().toString(), "VALID", "inspect :root is VALID");65}66function type(command) {67 gcliterm.inputNode.value = command.slice(0, -1);68 gcliterm.inputNode.focus();69 EventUtils.synthesizeKey(command.slice(-1), {});...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const wd = require('wd');2const chai = require('chai');3const chaiAsPromised = require('chai-as-promised');4chai.use(chaiAsPromised);5const should = chai.should();6const caps = {7};8describe('test', function() {9 let driver;10 before(async function() {11 await driver.init(caps);12 });13 after(async function() {14 await driver.quit();15 });16 it('should get status', async function() {17 await driver.getStatus().should.eventually.exist;18 });19});20const wd = require('wd');21const chai = require('chai');22const chaiAsPromised = require('chai-as-promised');23chai.use(chaiAsPromised);24const should = chai.should();25const caps = {26};27describe('test', function() {28 let driver;29 before(async function() {30 await driver.init(caps);31 });32 after(async function() {33 await driver.quit();34 });35 it('should get status', async function() {36 await driver.getStatus().should.eventually.exist;37 });38});39const wd = require('wd');40const chai = require('chai');41const chaiAsPromised = require('chai-as-promised');42chai.use(chaiAsPromised);43const should = chai.should();44const caps = {

Full Screen

Using AI Code Generation

copy

Full Screen

1var wd = require('wd');2driver.init({3}).then(function() {4 return driver.getStatus();5}).then(function(status) {6 console.log(status);7}).catch(function(err) {8 console.log(err);9});

Full Screen

Using AI Code Generation

copy

Full Screen

1const { exec } = require('child_process');2exec('node ./node_modules/appium-xcuitest-driver/lib/commands/status.js', (err, stdout, stderr) => {3 if (err) {4 console.error(`exec error: ${err}`);5 return;6 }7 console.log(`stdout: ${stdout}`);8 console.log(`stderr: ${stderr}`);9});10const { exec } = require('child_process');11exec('node ./node_modules/appium-xcuitest-driver/lib/commands/status.js', (err, stdout, stderr) => {12 if (err) {13 console.error(`exec error: ${err}`);14 return;15 }16 console.log(`stdout: ${stdout}`);17 console.log(`stderr: ${stderr}`);18});19const { exec } = require('child_process');20exec('node ./node_modules/appium-xcuitest-driver/lib/commands/status.js', (err, stdout, stderr) => {21 if (err) {22 console.error(`exec error: ${err}`);23 return;24 }25 console.log(`stdout: ${stdout}`);26 console.log(`stderr: ${stderr}`);27});28const { exec } = require('child_process');29exec('node ./node_modules/appium-xcuitest-driver/lib/commands/status.js', (err, stdout, stderr) => {30 if (err) {31 console.error(`exec error: ${err}`);32 return;33 }34 console.log(`stdout: ${stdout}`);35 console.log(`stderr: ${stderr}`);36});37const { exec } = require('child_process');38exec('node ./node_modules/appium-xcuitest-driver/lib/commands/status.js', (err, stdout, stderr) => {39 if (err) {40 console.error(`exec error: ${err}`);41 return;42 }43 console.log(`stdout: ${stdout}`);44 console.log(`stderr: ${stderr}`);45});46const { exec

Full Screen

Using AI Code Generation

copy

Full Screen

1var driver = wd.promiseChainRemote("localhost", 4723);2driver.init({3}).then(function () {4 return driver.getStatus();5}).then(function (status) {6 console.log(status);7});8{ build:9 { version: '1.7.1',10 os: [Object] },11 { name: 'iOS',12 kernelVersion: 'Darwin Kernel Version 17.3.0: Thu Nov 9 21:57:44 PST 2017; root:xnu-4570.31.3~1/RELEASE_X86_64' } }13var driver = wd.promiseChainRemote("localhost", 4723);14driver.init({15}).then(function () {16 return driver.getStatus();17}).then(function (status) {18 console.log(status);19}).catch(function (err) {20 console.log("Appium server is not running");21});

Full Screen

Using AI Code Generation

copy

Full Screen

1var webdriverio = require('webdriverio');2var options = {3 desiredCapabilities: {4 }5};6 .remote(options)7 .init()8 .getStatus()9 .then(function(status) {10 console.log(status);11 })12 .end();

Full Screen

Using AI Code Generation

copy

Full Screen

1const wd = require('wd');2async function main() {3 await driver.init({4 });5 let status = await driver.getStatus();6 console.log(status);7}8main();9const wd = require('wd');10async function main() {11 await driver.init({12 });13 let time = await driver.getDeviceTime();14 console.log(time);15}16main();17const wd = require('wd');18async function main() {19 await driver.init({20 });21 await driver.launchApp();22}23main();24const wd = require('wd');25async function main() {26 await driver.init({

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('Appium XCUITest Driver Test', function() {2 it('should get status from XCUITest Driver', function() {3 return driver.getStatus().then(function(status) {4 console.log(status);5 });6 });7});8exports.config = {9 capabilities: [{10 }],11};12{ build:13 { version: '1.6.4',14 time: '2017-03-16T22:26:18.000Z' },15 { name: 'iOS',16 arch: 'x86_64' },17 java: { version: '1.8.0_112' },18 javascript: { version: 'node.js v6.9.1' },19 appium: { version: '1.6.4' } }

Full Screen

Using AI Code Generation

copy

Full Screen

1driver.getStatus().then((status) => {2 console.log(status);3});4 });5});6exports.config = {7 capabilities: [{8 }],9};10{ build:11 { version: '1.6.4',12 time: '2017-03-16T22:26:18.000Z' },13 { name: 'iOS',14 arch: 'x86_64' },15 java: { version: '1.8.0_112' },16 javascript: { version: 'node.js v6.9.1' },17 appium: { version: '1.6.4' } }

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 Xcuitest Driver automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Sign up Free
_

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful