-
Notifications
You must be signed in to change notification settings - Fork 4
/
whatsapp.spec.ts
118 lines (102 loc) · 3.23 KB
/
whatsapp.spec.ts
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
import Sendchamp from "../src";
import { mobile, publicKey } from "../src/config";
import { SendchampMode, WhatsAppType } from "../src/constants/types";
import { WHATSAPP } from "../src/services";
describe("WHATSAPP", () => {
let sendchamp: Sendchamp;
let whatsapp: WHATSAPP;
beforeEach(() => {
sendchamp = new Sendchamp({
publicKey,
mode: SendchampMode.live,
});
whatsapp = sendchamp.WHATSAPP;
});
afterEach(() => {
sendchamp = undefined as unknown as Sendchamp;
whatsapp = undefined as unknown as WHATSAPP;
});
test.only("whatsapp.verifyNumber()", async () => {
const res = await whatsapp.verifyNumber({
phone_number: mobile,
});
expect(res.status).toBe("success");
expect(res.code).toBe(200);
expect(res.data).toBeDefined();
});
test("whatsapp.sendTemplate()", async () => {
const res = await whatsapp.sendTemplate({
type: WhatsAppType.template,
recipient: mobile,
sender: mobile,
template_code: "b0f729d5-e3c4-4db5-82c2-36e7fa23644a",
custom_data: {
"1": "test",
"2": "1234",
"3": "5",
},
});
expect(res.status).toBe("success");
expect(res.code).not.toBe("06");
expect(res.data.provider_reference).toBeDefined();
});
test("whatsapp.sendText()", async () => {
const res = await whatsapp.sendText({
type: WhatsAppType.text,
recipient: mobile,
sender: mobile,
message: "test_whatsapp_message",
});
expect(res.status).toBe("success");
expect(res.code).toBe(200);
expect(res.data.provider_reference).toBeDefined();
});
test("whatsapp.sendAudio()", async () => {
const res = await whatsapp.sendAudio({
type: WhatsAppType.audio,
recipient: mobile,
sender: mobile,
message: "test_whatsapp_message",
link: "https://sample-videos.com/audio/mp3/crowd-cheering.mp3",
});
expect(res.status).toBe("success");
expect(res.code).toBe(200);
expect(res.data.provider_reference).toBeDefined();
});
test("whatsapp.sendVideo()", async () => {
const res = await whatsapp.sendVideo({
type: WhatsAppType.video,
recipient: mobile,
sender: mobile,
link: "https://sample-videos.com/video123/mp4/720/big_buck_bunny_720p_1mb.mp4",
});
expect(res.status).toBe("success");
expect(res.code).toBe(200);
expect(res.data.provider_reference).toBeDefined();
});
test("whatsapp.sendLocation()", async () => {
const res = await whatsapp.sendLocation({
type: WhatsAppType.location,
recipient: mobile,
sender: mobile,
name: mobile,
address: "Av. Angélica, 2530 - Bela Vista, São Paulo - SP, 01228-200",
latitude: -23.55361,
longitude: -46.662787,
});
expect(res.status).toBe("success");
expect(res.code).toBe(200);
expect(res.data.provider_reference).toBeDefined();
});
test("whatsapp.sendSticker()", async () => {
const res = await whatsapp.sendSticker({
type: WhatsAppType.sticker,
recipient: mobile,
sender: mobile,
link: "https://studio.posit.us/api/samples/sticker.webp",
});
expect(res.status).toBe("success");
expect(res.code).toBe(200);
expect(res.data.provider_reference).toBeDefined();
});
});