Skip to content

Commit b49f192

Browse files
unit tests added
1 parent 27fd7c5 commit b49f192

File tree

6 files changed

+3140
-19
lines changed

6 files changed

+3140
-19
lines changed

Diff for: CHANGELOG.md

+7-3
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,20 @@
88

99
## 0.2.1
1010

11-
- examples added
11+
- Examples added
1212

1313
## 1.0.0
1414

1515
- Initial version
1616

1717
## 1.0.1
1818

19-
- more examples added
19+
- Eore examples added
2020

2121
## 1.0.2
2222

23-
- more examples added
23+
- More examples added
24+
25+
## 1.0.3
26+
27+
- Unit tests added

Diff for: README.md

+5-7
Original file line numberDiff line numberDiff line change
@@ -103,14 +103,13 @@ const webirr = require('webirr');
103103
async function main()
104104
{
105105
const apiKey = 'YOUR_API_KEY';
106-
const merchantId = 'YOUR_MERCHANT_ID';
107-
106+
108107
var api = new webirr.WeBirrClient(apiKey, true);
109108

110-
var paymentCode = 'PAYMENT_CODE_YOU_SAVED_AFTER_CREATING_A_NEW_BILL' // suchas as '141 263 782';
109+
var paymentCode = 'PAYMENT_CODE_YOU_SAVED_AFTER_CREATING_A_NEW_BILL'; // suchas as '141 263 782';
111110

112111
console.log('Getting Payment Status...');
113-
var r = await api.getPaymentStatus('624549955')
112+
var r = await api.getPaymentStatus('624549955');
114113

115114
if (!r.error) {
116115
// success
@@ -165,14 +164,13 @@ const webirr = require('webirr');
165164
async function main()
166165
{
167166
const apiKey = 'YOUR_API_KEY';
168-
const merchantId = 'YOUR_MERCHANT_ID';
169167

170168
var api = new webirr.WeBirrClient(apiKey, true);
171169

172-
var paymentCode = 'PAYMENT_CODE_YOU_SAVED_AFTER_CREATING_A_NEW_BILL' // suchas as '141 263 782';
170+
var paymentCode = 'PAYMENT_CODE_YOU_SAVED_AFTER_CREATING_A_NEW_BILL'; // suchas as '141 263 782';
173171

174172
console.log('Deleting Bill...');
175-
res = await api.deleteBill(paymentCode);
173+
var res = await api.deleteBill(paymentCode);
176174

177175
if (!res.error) {
178176
// success

Diff for: __test__/webirr.test.js

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
require('jest');
2+
const webirr = require('webirr');
3+
4+
const sampleBill = {
5+
amount: '270.90',
6+
customerCode: 'cc01',
7+
customerName: 'Elias Haileselassie',
8+
time: '2021-07-22 22:14',
9+
description: 'hotel booking',
10+
billReference: 'drt/2021/125',
11+
merchantID: 'x',
12+
};
13+
14+
test('createBill should get error from WebService on invalid api key - TestEnv', async () => {
15+
16+
var bill = sampleBill;
17+
18+
var api = new webirr.WeBirrClient('x', true);
19+
var res = await api.createBill(bill);
20+
21+
expect(res.error.length > 0).toBe(true); // should contain error
22+
23+
});
24+
25+
test('createBill should get error from WebService on invalid api key - ProdEnv', async () => {
26+
27+
var bill = sampleBill;
28+
29+
var api = new webirr.WeBirrClient('x', false);
30+
var res = await api.createBill(bill);
31+
32+
expect(res.error.length > 0).toBe(true); // should contain error
33+
34+
});
35+
36+
test('updateBill should get error from WebService on invalid api key', async () => {
37+
38+
var bill = sampleBill;
39+
40+
var api = new webirr.WeBirrClient('x', true);
41+
var res = await api.updateBill(bill);
42+
43+
expect(res.error.length > 0).toBe(true); // should contain error
44+
45+
});
46+
47+
test('deleteBill should get error from WebService on invalid api key', async () => {
48+
49+
var api = new webirr.WeBirrClient('x', true);
50+
var res = await api.deleteBill('xxxx');
51+
52+
expect(res.error.length > 0).toBe(true); // should contain error
53+
54+
});
55+
56+
test('getPaymentStatus should get error from WebService on invalid api key', async () => {
57+
58+
var api = new webirr.WeBirrClient('x', true);
59+
var res = await api.getPaymentStatus('xxxx');
60+
61+
expect(res.error.length > 0).toBe(true); // should contain error
62+
63+
});
64+
65+
66+
67+
68+
69+
70+

0 commit comments

Comments
 (0)