11import { describe , expect , test } from "bun:test" ;
2- import type { Message } from "discord.js" ;
32import { config } from "../../Config.js" ;
43import {
54 buildStarboardMessageContent ,
65 type StarboardContentRenderOptions ,
76} from "./starboard.content.js" ;
8-
9- interface ReactionStub {
10- emoji : {
11- name : string | null ;
12- id : string | null ;
13- } ;
14- count : number | null ;
15- }
16-
17- const createMessageWithReactions = (
18- url : string ,
19- reactions : ReactionStub [ ] ,
20- ) : Pick < Message , "url" | "reactions" > => {
21- return {
22- url,
23- reactions : {
24- cache : {
25- find : (
26- predicate : ( reaction : ReactionStub ) => boolean ,
27- ) : ReactionStub | undefined => reactions . find ( predicate ) ,
28- } ,
29- } ,
30- } as Pick < Message , "url" | "reactions" > ;
31- } ;
7+ import { createMessageWithUrlAndReactions } from "./starboard.test-utils.js" ;
328
339const starboardRenderOptions : StarboardContentRenderOptions = {
3410 emojiId : config . starboard . emojiId ,
@@ -43,15 +19,18 @@ describe("buildStarboardMessageContent", () => {
4319 throw new Error ( "antiStarboard config is required for this test" ) ;
4420 }
4521
46- const message = createMessageWithReactions ( "https://discord.test/message" , [
47- {
48- emoji : {
49- name : antiStarboard . emojiId ,
50- id : null ,
22+ const message = createMessageWithUrlAndReactions (
23+ "https://discord.test/message" ,
24+ [
25+ {
26+ emoji : {
27+ name : antiStarboard . emojiId ,
28+ id : null ,
29+ } ,
30+ count : 2 ,
5131 } ,
52- count : 2 ,
53- } ,
54- ] ) ;
32+ ] ,
33+ ) ;
5534
5635 expect (
5736 buildStarboardMessageContent ( message , 5 , starboardRenderOptions ) ,
@@ -61,7 +40,7 @@ describe("buildStarboardMessageContent", () => {
6140 } ) ;
6241
6342 test ( "omits the anti-star hint when there are no anti-stars" , ( ) => {
64- const message = createMessageWithReactions (
43+ const message = createMessageWithUrlAndReactions (
6544 "https://discord.test/message" ,
6645 [ ] ,
6746 ) ;
@@ -77,15 +56,18 @@ describe("buildStarboardMessageContent", () => {
7756 throw new Error ( "antiStarboard config is required for this test" ) ;
7857 }
7958
80- const message = createMessageWithReactions ( "https://discord.test/message" , [
81- {
82- emoji : {
83- name : antiStarboard . emojiId ,
84- id : null ,
59+ const message = createMessageWithUrlAndReactions (
60+ "https://discord.test/message" ,
61+ [
62+ {
63+ emoji : {
64+ name : antiStarboard . emojiId ,
65+ id : null ,
66+ } ,
67+ count : 2 ,
8568 } ,
86- count : 2 ,
87- } ,
88- ] ) ;
69+ ] ,
70+ ) ;
8971
9072 expect (
9173 buildStarboardMessageContent ( message , 2 , {
0 commit comments