1616import { MemoryKvStore } from "@fedify/fedify/federation" ;
1717import type { Actor } from "@fedify/fedify/vocab" ;
1818import { assertEquals } from "@std/assert/equals" ;
19+ import type { BotImpl } from "./bot-impl.ts" ;
1920import { createBot } from "./bot.ts" ;
2021import type { FollowRequest } from "./follow.ts" ;
21- import type { Message , MessageClass } from "./message.ts" ;
22+ import type { Message , MessageClass , SharedMessage } from "./message.ts" ;
23+ import type { Like } from "./reaction.ts" ;
2224import type { Session } from "./session.ts" ;
2325
2426Deno . test ( "createBot()" , async ( ) => {
2527 const kv = new MemoryKvStore ( ) ;
26- const bot = createBot ( { kv, identifier : "bot-id" , username : "bot" } ) ;
28+ const bot = createBot < void > ( { kv, identifier : "bot-id" , username : "bot" } ) ;
29+ const { impl } = bot as unknown as { impl : BotImpl < void > } ;
2730 const _federation = bot . federation ;
2831 assertEquals ( bot . identifier , "bot-id" ) ;
2932 const session = bot . getSession ( "https://example.com" ) ;
@@ -32,24 +35,59 @@ Deno.test("createBot()", async () => {
3235 function onFollow ( _session : Session < void > , _followRequest : FollowRequest ) { }
3336 bot . onFollow = onFollow ;
3437 assertEquals ( bot . onFollow , onFollow ) ;
38+ assertEquals ( impl . onFollow , onFollow ) ;
3539
3640 function onUnfollow ( _session : Session < void > , _follower : Actor ) { }
3741 bot . onUnfollow = onUnfollow ;
3842 assertEquals ( bot . onUnfollow , onUnfollow ) ;
43+ assertEquals ( impl . onUnfollow , onUnfollow ) ;
44+
45+ function onAcceptFollow ( _session : Session < void > , _accepter : Actor ) { }
46+ bot . onAcceptFollow = onAcceptFollow ;
47+ assertEquals ( bot . onAcceptFollow , onAcceptFollow ) ;
48+ assertEquals ( impl . onAcceptFollow , onAcceptFollow ) ;
49+
50+ function onRejectFollow ( _session : Session < void > , _rejecter : Actor ) { }
51+ bot . onRejectFollow = onRejectFollow ;
52+ assertEquals ( bot . onRejectFollow , onRejectFollow ) ;
53+ assertEquals ( impl . onRejectFollow , onRejectFollow ) ;
3954
4055 function onMention (
4156 _session : Session < void > ,
4257 _message : Message < MessageClass , void > ,
4358 ) { }
4459 bot . onMention = onMention ;
4560 assertEquals ( bot . onMention , onMention ) ;
61+ assertEquals ( impl . onMention , onMention ) ;
4662
4763 function onReply (
4864 _session : Session < void > ,
4965 _message : Message < MessageClass , void > ,
5066 ) { }
5167 bot . onReply = onReply ;
5268 assertEquals ( bot . onReply , onReply ) ;
69+ assertEquals ( impl . onReply , onReply ) ;
70+
71+ function onMessage (
72+ _session : Session < void > ,
73+ _message : Message < MessageClass , void > ,
74+ ) { }
75+ bot . onMessage = onMessage ;
76+ assertEquals ( bot . onMessage , onMessage ) ;
77+ assertEquals ( impl . onMessage , onMessage ) ;
78+
79+ function onSharedMessage (
80+ _session : Session < void > ,
81+ _message : SharedMessage < MessageClass , void > ,
82+ ) { }
83+ bot . onSharedMessage = onSharedMessage ;
84+ assertEquals ( bot . onSharedMessage , onSharedMessage ) ;
85+ assertEquals ( impl . onSharedMessage , onSharedMessage ) ;
86+
87+ function onLike ( _session : Session < void > , _like : Like < void > ) { }
88+ bot . onLike = onLike ;
89+ assertEquals ( bot . onLike , onLike ) ;
90+ assertEquals ( impl . onLike , onLike ) ;
5391
5492 const response = await bot . fetch (
5593 new Request (
0 commit comments