supertest('https://192.168.99.100:8080') .post('/notification/sendEmail') .send({payload}) .end((err, res) => { if (err) { reject(new Error('An error occured with the payment service, err: ' + err)) } resolve(res.body) })
.send({user, booking}) .expect((res) => { console.log(res.body) }) .expect(200, done)
.send({user, booking}) .expect((res) => { res.body.should.containEql({ cinema: booking.cinema, schedule: now.toString(),
.get(`/cinemas?cityId=${location.city}`) .expect((res) => { res.body.should.containEql(testCinemasCity[0]) res.body.should.containEql(testCinemasCity[1]) }) .expect(200, done) .get('/cinemas/588ac3a02d029a6d15d0b5c4') .expect((res) => { res.body.should.containEql(testCinemaId) }) .expect(200, done) .get('/cinemas/588ababf2d029a6d15d0b5bf/1') .expect((res) => { res.body.should.containEql(testSchedulesMovie[0]) res.body.should.containEql(testSchedulesMovie[1]) }) .expect(200, done)
.send({payload}) .expect((res) => { should.ok(res.body) }) .expect(200, done)
supertest('https://192.168.99.100:8080') .post('/payment/makePurchase') .send({paymentOrder}) .end((err, res) => { if (err) { reject(new Error('An error occured with the payment service, err: ' + err)) } resolve(res.body.paid) })
step('check unspent transaction from address 1', () => { return Promise.resolve() .then(() => { return supertest(context.httpServer1.app) .get('/blockchain/transactions/unspent') .query({ address: context.address1 }) .expect(200) .expect((res) => { assert.equal(res.body.length, 3, `Expected unspent transactions of address '${context.address1}' to be '3'`); }); }); });
step('get wallets', () => { return Promise.resolve() .then(() => { return supertest(context.httpServer1.app) .get('/operator/wallets') .expect(200) .expect((res) => { assert.equal(res.body.length, 1, 'Expected 1 wallet.'); assert.equal(res.body[0].addresses.length, 2, 'Expected 2 addresses.'); }); }); });
step('check confirmations from server 2 for the created transaction', () => { return Promise.resolve() .then(() => { return supertest(context.httpServer2.app) .get(`/node/transactions/${context.transactionId}/confirmations`) .expect(200) .expect((res) => { assert.equal(res.body.confirmations, 2, `Expected confirmations of transaction '${context.transactionId}' to be '2'`); }); }); });
step('get wallet', () => { return Promise.resolve() .then(() => { return supertest(context.httpServer1.app) .get(`/operator/wallets/${context.walletId}`) .expect(200) .expect((res) => { assert.equal(res.body.addresses.length, 2, 'Expected 2 addresses.'); }); }); });
step('check address 2 balance', () => { return Promise.resolve() .then(() => { return supertest(context.httpServer1.app) .get(`/operator/${context.address2}/balance`) .expect(200) .expect((res) => { assert.equal(res.body.balance, 1000000000, `Expected balance of address '${context.address2}' to be '1000000000'`); }); }); });
step('check address 1 balance', () => { return Promise.resolve() .then(() => { return supertest(context.httpServer1.app) .get(`/operator/${context.address1}/balance`) .expect(200) .expect((res) => { assert.equal(res.body.balance, 9000000000, `Expected balance of address '${context.address1}' to be '9000000000'`); }); }); });
step('get wallet addresses', () => { return Promise.resolve() .then(() => { return supertest(context.httpServer1.app) .get(`/operator/wallets/${context.walletId}/addresses`) .expect(200) .expect((res) => { assert.equal(res.body.length, 2, 'Expected 2 addresses.'); }); }); });
step('check confirmations from server 1 for the created transaction', () => { return Promise.resolve() .then(() => { return supertest(context.httpServer1.app) .get(`/node/transactions/${context.transactionId}/confirmations`) .expect(200) .expect((res) => { assert.equal(res.body.confirmations, 2, `Expected confirmations of transaction '${context.transactionId}' to be '2'`); }); }); });