-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.js
More file actions
79 lines (56 loc) · 2.29 KB
/
test.js
File metadata and controls
79 lines (56 loc) · 2.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import assert from "assert/strict";
import request from "supertest"
import express from "express"
import crypto from 'crypto';
import apiService from "./services/apiService.js"
import router from "./router.js"
import bodyParser from "body-parser";
const requestRouter = router
const app = express();
app.use(bodyParser.urlencoded({extended : true}))
app.use(bodyParser.json())
app.use("/api/v1",requestRouter)
let accountReference;
let payload = {
"customerName": "Tester", "customerEmail": crypto.randomBytes(20).toString('hex') + "@tester.com",
"accountName": "tester", "contractCode": "7059707855", "bvn": "21212121212","getAllAvaibleBanks":true
};
let token;
beforeEach(async () =>{
token = await apiService.getAccessToken()
})
describe('Assert Access Token Request', ()=>{
it('confirm that request is successful', async()=>{
assert.notStrictEqual(token,false);
})
})
describe('Check Reserved Account Creation', ()=>{
it('confirm that reserved account creation works', async () => {
accountReference = crypto.randomBytes(20).toString('hex');
const testPayload = { ...payload, accountReference };
const resp = await request(app).
post("/api/v1/trx/reservedAccount").
send(testPayload).
set("Content-Type", "application/json");
assert.strictEqual(resp.status,200);
assert.strictEqual(resp.body.status, 'success')
})
})
describe('Get Reserved Account Details', () => {
it('confirm that reserved account details retrieval works', async () => {
const url = "/api/v1/trx/reservedAccount/" + accountReference
const resp = await request(app).
get(url).set("Content-Type", "application/json");
assert.strictEqual(resp.status,200);
assert.strictEqual(resp.body.status, 'success')
});
});
describe('Check Reserved Account Deallocation', () => {
it('confirm that reserved account deallocation works', async () => {
const url = "/api/v1/trx/reservedAccount/" + accountReference
const resp = await request(app).
delete(url).set("Content-Type", "application/json");
assert.strictEqual(resp.status,200);
assert.strictEqual(resp.body.status, 'success')
});
});