@ -45,7 +45,7 @@ describe("notifyReplyCommentCreated", () => {
smtpPass : "smtp-pass" ,
} ) ;
await notifyReplyCommentCreated ( { parentId : 100 , actorUserId : 1 , replyBody : "hello" } , deps ) ;
await notifyReplyCommentCreated ( { postId : 10 , commentId : 200 , p arentId : 100 , actorUserId : 1 , replyBody : "hello" } , deps ) ;
expect ( state . sendMailCalled ) . toBe ( false ) ;
} ) ;
@ -54,7 +54,7 @@ describe("notifyReplyCommentCreated", () => {
const { deps , state } = createDeps ( ) ;
deps . getReceiverNotifyEnabled = async ( ) = > false ;
await notifyReplyCommentCreated ( { parentId : 100 , actorUserId : 1 , replyBody : "hello" } , deps ) ;
await notifyReplyCommentCreated ( { postId : 10 , commentId : 201 , p arentId : 100 , actorUserId : 1 , replyBody : "hello" } , deps ) ;
expect ( state . sendMailCalled ) . toBe ( false ) ;
} ) ;
@ -62,7 +62,7 @@ describe("notifyReplyCommentCreated", () => {
test ( "无 parentId -> 不发送" , async ( ) = > {
const { deps , state } = createDeps ( ) ;
await notifyReplyCommentCreated ( { parentId : null , actorUserId : 1 , replyBody : "hello" } , deps ) ;
await notifyReplyCommentCreated ( { postId : 10 , commentId : 202 , p arentId : null , actorUserId : 1 , replyBody : "hello" } , deps ) ;
expect ( state . sendMailCalled ) . toBe ( false ) ;
} ) ;
@ -71,8 +71,19 @@ describe("notifyReplyCommentCreated", () => {
const { deps , state } = createDeps ( ) ;
deps . getParentAuthorUserId = async ( ) = > 1 ;
await notifyReplyCommentCreated ( { parentId : 100 , actorUserId : 1 , replyBody : "hello" } , deps ) ;
await notifyReplyCommentCreated ( { postId : 10 , commentId : 203 , p arentId : 100 , actorUserId : 1 , replyBody : "hello" } , deps ) ;
expect ( state . sendMailCalled ) . toBe ( false ) ;
} ) ;
test ( "发送异常 -> 不抛出(best-effort)" , async ( ) = > {
const { deps } = createDeps ( ) ;
deps . sendMail = async ( ) = > {
throw new Error ( "smtp send failed" ) ;
} ;
await expect (
notifyReplyCommentCreated ( { postId : 10 , commentId : 204 , parentId : 100 , actorUserId : 1 , replyBody : "hello" } , deps ) ,
) . resolves . toBeUndefined ( ) ;
} ) ;
} ) ;