Improve code coverage

This commit is contained in:
Cadence Ember 2023-10-07 22:47:31 +13:00
parent 0b40a50254
commit 0e56255f82
8 changed files with 118 additions and 10 deletions

View file

@ -1,7 +1,7 @@
// @ts-check
const {test} = require("supertape")
const {eventSenderIsFromDiscord} = require("./utils")
const {eventSenderIsFromDiscord, getEventIDHash} = require("./utils")
test("sender type: matrix user", t => {
t.notOk(eventSenderIsFromDiscord("@cadence:cadence.moe"))
@ -14,3 +14,12 @@ test("sender type: ooye bot", t => {
test("sender type: ooye puppet", t => {
t.ok(eventSenderIsFromDiscord("@_ooye_sheep:cadence.moe"))
})
test("event hash: hash is the same each time", t => {
const eventID = "$example"
t.equal(getEventIDHash(eventID), getEventIDHash(eventID))
})
test("event hash: hash is different for different inputs", t => {
t.notEqual(getEventIDHash("$Ij3qo7NxMA4VPexlAiIx2CB9JbsiGhJeyt-2OvkAUe1"), getEventIDHash("$Ij3qo7NxMA4VPexlAiIx2CB9JbsiGhJeyt-2OvkAUe2"))
})