it('fail to status transaction 404 with non exists order_id',()=>{ let snap = new Snap(generateConfig()); return snap.transaction.status('non exists order_id') .then((res)=>{ }) .catch((e)=>{ expect(e.message).to.includes('404'); }) })
it('fail to create transaction with zero gross_amount',()=>{ let config = generateConfig(); let snap = new Snap(config); let param = generateParamMin(); param.transaction_details.gross_amount = 0; return snap.createTransaction() .then((res)=>{ }) .catch((e)=>{ expect(e.message).to.includes('400'); }) })
it("should log to stdout and buffer in coloring off", () => { const intercept = xstdout.intercept(true); try { logger.coloring(false); logger.buffering(true); logger.log("test", "hello", 1, "world"); } finally { intercept.restore(); } expect(intercept.stdout.join("")).includes("test hello 1 world"); expect(logger.buffer.join("")).includes("test hello 1 world"); });
it('able to cancel',()=>{ let core = new CoreApi(generateConfig()); return core.transaction.cancel(reuseOrderId[1]) .then((res)=>{ expect(res.status_code).to.equals('200'); expect(res.transaction_status).to.includes('cancel'); }) })
it('should create user with default role of user', async () => { const res = await request(app) .post('/api/v1/users') .set('Authorization', `Bearer ${adminAccessToken}`) .send(user) .expect(201); delete user.password; user.role = 'user'; expect(res.body.data.role).to.equal('user'); expect(res.body.data).to.includes(user); });
it("should log to stdout in coloring off", () => { const intercept = xstdout.intercept(true); try { logger.coloring(false); logger.log("test", "hello", 1, "world"); } finally { intercept.restore(); } expect(intercept.stdout.join("")).includes("test hello 1 world"); });
it('fail to getFacilitatorBankAccounts: not authorized due to non facilitator account',()=>{ let iris = new Iris(generateConfig()); return iris.getFacilitatorBalance() .catch((e)=>{ expect(e.message).to.includes('not authorized'); }) })
it('fail to create transaction 400 with no param',()=>{ let config = generateConfig(); let snap = new Snap(config); return snap.createTransaction() .then((res)=>{ }) .catch((e)=>{ expect(e.message).to.includes('400'); }) })
it('fail to charge 401 with no serverKey',()=>{ let core = new CoreApi(generateConfig()); core.apiConfig.serverKey = null; return core.charge(generateParamMin()) .catch((e)=>{ expect(e.message).to.includes('401'); }) })
it('fail to refund non settlement transaction',()=>{ let core = new CoreApi(generateConfig()); let parameter = { "amount": 5000, "reason": "for some reason" } return core.transaction.refund(reuseOrderId[2],parameter) .catch((e)=>{ expect(e.message).to.includes('412'); }) })
it('fail to charge 400 with zero gross_amount',()=>{ let core = new CoreApi(generateConfig()); let parameter = generateParamMin(); parameter.transaction_details.gross_amount=0; return core.charge(parameter) .catch((e)=>{ expect(e.message).to.includes('400'); }) })
it('fail to card point inquiry 402',()=>{ let core = new CoreApi(generateConfig()); return core.cardPointInquiry(tokenId) .catch((e)=>{ expect(e.message).to.includes('402'); }) })
it('fail to create transaction 401 with no serverKey',()=>{ let config = generateConfig(); config.serverKey = ''; let snap = new Snap(config); return snap.createTransaction(generateParamMin()) .then((res)=>{ }) .catch((e)=>{ expect(e.message).to.includes('401'); }) })
it('fail to direct refund non settlement transaction',()=>{ let core = new CoreApi(generateConfig()); let parameter = { "amount": 5000, "reason": "for some reason" } return core.transaction.refundDirect(reuseOrderId[2],parameter) .catch((e)=>{ expect(e.message).to.includes('412'); }) })
it('fail to status transaction 401 with no serverKey',()=>{ let config = generateConfig(); config.serverKey = ''; let snap = new Snap(config); return snap.transaction.status('non exists order_id') .then((res)=>{ }) .catch((e)=>{ expect(e.message).to.includes('401'); }) })