add guildscheduledevents to unit test mock
Compile the repository / compile (pull_request) Successful in 14m58s Details
Run unit tests / test (pull_request) Successful in 4m18s Details

This commit is contained in:
kenobi 2023-07-17 23:31:00 +02:00
parent dc66c277b2
commit a2adef808f
1 changed files with 13 additions and 2 deletions

View File

@ -3,7 +3,7 @@ import VoteController, { Vote, VoteMessageInfo } from "../../server/helper/vote.
import { JellyfinHandler } from "../../server/jellyfin/handler" import { JellyfinHandler } from "../../server/jellyfin/handler"
import { ExtendedClient } from "../../server/structures/client" import { ExtendedClient } from "../../server/structures/client"
import { VoteMessage } from "../../server/helper/messageIdentifiers" import { VoteMessage } from "../../server/helper/messageIdentifiers"
test('parse votes from vote message', () => { test('parse votes from vote message', async () => {
const testMovies = [ const testMovies = [
'Movie1', 'Movie1',
'Movie2', 'Movie2',
@ -33,6 +33,17 @@ test('parse votes from vote message', () => {
const msg: VoteMessage = <VoteMessage><unknown>{ const msg: VoteMessage = <VoteMessage><unknown>{
cleanContent: testMessage, cleanContent: testMessage,
guild:{
id:testGuildId,
scheduledEvents:{
fetch: jest.fn().mockImplementation((input:any)=>{
if(input === testEventId)
return {
scheduledStartAt: testEventDate
}
})
}
},
reactions: { reactions: {
cache: { cache: {
get: jest.fn().mockImplementation((input: any) => { get: jest.fn().mockImplementation((input: any) => {
@ -46,7 +57,7 @@ test('parse votes from vote message', () => {
} }
} }
const result = voteController.parseVotesFromVoteMessage(msg, 'requestId') const result = await voteController.parseVoteInfoFromVoteMessage(msg, 'requestId')
console.log(JSON.stringify(result)) console.log(JSON.stringify(result))
expect(Array.isArray(result)).toBe(false) expect(Array.isArray(result)).toBe(false)
expect(result.eventId).toEqual(testEventId) expect(result.eventId).toEqual(testEventId)