Skip to content
This repository has been archived by the owner on Jul 1, 2020. It is now read-only.

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
giovd8 committed Apr 10, 2020
1 parent e9b8115 commit 6a6d0a8
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
17 changes: 17 additions & 0 deletions bot.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// test bot
const { checkChatId, sendMessage } = require("./server");

// CHATID TEST
// eslint-disable-next-line require-jsdoc
function getRandomArbitrary(min, max) {
return Math.floor(Math.random() * (max - min + 1) + min);
}
const chatId = getRandomArbitrary(100000000, 999999999);
test("Chat id: ", () => {
expect(checkChatId(chatId)).toBe(true);
});

// SEND MESSAGE TEST da cambiare undefined
test("sendMessage", () => {
expect(sendMessage("ciao", "226026285")).toBe(undefined);
});
5 changes: 4 additions & 1 deletion server.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,11 @@ const sendMessage = (message, chatId) => {
.post(
`https://api.telegram.org/bot${tokenBot}/sendMessage?chat_id=${chatId}&text=${message}`
)
.then(() => {
.then((res) => {
console.log("Messaggio inviato con successo");
console.log(res.response.status);
console.log(res.data);
res.json("OK");
})
.catch((err) => {
console.log(
Expand Down

0 comments on commit 6a6d0a8

Please sign in to comment.