41 lines
937 B
JavaScript
41 lines
937 B
JavaScript
|
const test = require("tap").test;
|
||
|
const rangi = require("rangi");
|
||
|
|
||
|
const lib = require("../lib");
|
||
|
|
||
|
test("Initial menu, display balances, exit", async (t) => {
|
||
|
const sessionId = lib.newSession();
|
||
|
|
||
|
t.plan(3);
|
||
|
|
||
|
t.test("Display menu and Sarafu balance", async (t) => {
|
||
|
await lib.wait(3000);
|
||
|
const r = await lib.ussdClient(sessionId);
|
||
|
console.log(rangi.cyan(r.text));
|
||
|
|
||
|
t.equal(r.code, "CON");
|
||
|
t.match(r.text, /Balance/g);
|
||
|
t.end();
|
||
|
});
|
||
|
|
||
|
t.test("Go to My Sarafu menu", async (t) => {
|
||
|
await lib.wait(3000);
|
||
|
const r = await lib.ussdClient(sessionId, "2");
|
||
|
console.log(rangi.cyan(r.text));
|
||
|
|
||
|
t.equal(r.code, "CON");
|
||
|
t.match(r.text, /SRF/g);
|
||
|
t.end();
|
||
|
});
|
||
|
|
||
|
t.test("Exit", async (t) => {
|
||
|
await lib.wait(3000);
|
||
|
const r = await lib.ussdClient(sessionId, "2*00");
|
||
|
console.log(rangi.cyan(r.text));
|
||
|
|
||
|
t.equal(r.code, "END");
|
||
|
t.match(r.text, /Thank/g);
|
||
|
t.end();
|
||
|
});
|
||
|
});
|