UNPKG

@uneiotech/elisa_whatsapp

Version:

Elisa WhatsApp is a library to stable a communication between channels and server.

44 lines (40 loc) 1.29 kB
import {ElisaWhatsApp} from '../index' import { IConfig, IMessage,IResponse } from '../types'; import { RequestError } from 'request-promise/errors'; test("Testing: Call Services Url or params not valid",()=>{ const config:IConfig = { apiKey:"2222222", url:"www.elisaactive.com" } const elisaWhatsApp = new ElisaWhatsApp(config) const message:IMessage = { numberTo:"099999", type:"text", message:"My message" } return expect(elisaWhatsApp.sendMessage(message)).rejects.not.toStrictEqual( { "message":"", "ok": false, "status": 500 } ) }) test("Testing: Call Services Url server of Elisa, key invalidate",()=>{ const config:IConfig = { apiKey:"c98db123-e2b2-4005-a76d-7dc78dc7185d", url :"https://api.maytapi.com/api/82e8ace0-9dbf-4f65-b23c-d7eccf3ec12c/6185/sendMessage" } const elisaWhatsApp = new ElisaWhatsApp(config) const message:IMessage = { numberTo:"022222", type:"text", message:"My message" } const data = elisaWhatsApp.sendMessage(message) expect(data).rejects.toEqual({ ok:false, status:200, message:"Secret key does not match! Please check your secret key." }) })