@@ -107,6 +107,44 @@ describe("client", () => {
107107 }
108108 } ) ;
109109
110+ it ( "calls 'conversations.create' with the given token and content" , async ( ) => {
111+ try {
112+ const args = {
113+ name : "pull-request-review-010101" ,
114+ } ;
115+ const response = {
116+ ok : true ,
117+ channel : {
118+ id : "C0101010101" ,
119+ name : "pull-request-review-010101" ,
120+ is_channel : true ,
121+ created : 1730425428 ,
122+ } ,
123+ } ;
124+ mocks . core . getInput . withArgs ( "method" ) . returns ( "chat.postMessage" ) ;
125+ mocks . core . getInput . withArgs ( "token" ) . returns ( "xoxb-example" ) ;
126+ mocks . core . getInput . withArgs ( "payload" ) . returns ( JSON . stringify ( args ) ) ;
127+ mocks . api . resolves ( response ) ;
128+ await send ( mocks . core ) ;
129+ assert . deepEqual ( mocks . api . getCall ( 0 ) . firstArg , "chat.postMessage" ) ;
130+ assert . deepEqual ( mocks . api . getCall ( 0 ) . lastArg , args ) ;
131+ assert . equal ( mocks . core . setOutput . getCall ( 0 ) . firstArg , "ok" ) ;
132+ assert . equal ( mocks . core . setOutput . getCall ( 0 ) . lastArg , true ) ;
133+ assert . equal ( mocks . core . setOutput . getCall ( 1 ) . firstArg , "response" ) ;
134+ assert . equal (
135+ mocks . core . setOutput . getCall ( 1 ) . lastArg ,
136+ JSON . stringify ( response ) ,
137+ ) ;
138+ assert . equal ( mocks . core . setOutput . getCall ( 2 ) . firstArg , "channel_id" ) ;
139+ assert . equal ( mocks . core . setOutput . getCall ( 2 ) . lastArg , "C0101010101" ) ;
140+ assert . equal ( mocks . core . setOutput . getCall ( 3 ) . firstArg , "time" ) ;
141+ assert . equal ( mocks . core . setOutput . getCalls ( ) . length , 4 ) ;
142+ } catch ( error ) {
143+ console . error ( error ) ;
144+ assert . fail ( "Unexpected error when calling the method" ) ;
145+ }
146+ } ) ;
147+
110148 it ( "calls 'files.uploadV2' with the provided token and content" , async ( ) => {
111149 try {
112150 const args = {
0 commit comments