@ -22,7 +22,9 @@ describe('[Chat]', function() {
. set ( credentials )
. send ( {
text : 'Sample message' ,
alias : 'Gruggy' ,
emoji : ':smirk:' ,
avatar : 'http://res.guggy.com/logo_128.png' ,
} )
. expect ( 'Content-Type' , 'application/json' )
. expect ( 400 )
@ -38,8 +40,10 @@ describe('[Chat]', function() {
. set ( credentials )
. send ( {
channel : 'general' ,
alias : 'Gruggy' ,
text : 'Sample message' ,
emoji : ':smirk:' ,
avatar : 'http://res.guggy.com/logo_128.png' ,
attachments : [ {
color : '#ff0000' ,
text : 'Yay for gruggy!' ,
@ -74,7 +78,9 @@ describe('[Chat]', function() {
. set ( credentials )
. send ( {
channel : 'general' ,
alias : 'Gruggy' ,
text : 'Sample message' ,
avatar : 'http://res.guggy.com/logo_128.png' ,
emoji : ':smirk:' ,
attachments : [ {
color : '#ff0000' ,
@ -99,7 +105,9 @@ describe('[Chat]', function() {
. send ( {
channel : 'general' ,
text : 'Sample message' ,
alias : 'Gruggy' ,
emoji : ':smirk:' ,
avatar : 'http://res.guggy.com/logo_128.png' ,
attachments : [ {
color : '#ff0000' ,
text : 'Yay for gruggy!' ,
@ -123,7 +131,9 @@ describe('[Chat]', function() {
. send ( {
channel : 'general' ,
text : 'Sample message' ,
alias : 'Gruggy' ,
emoji : ':smirk:' ,
avatar : 'http://res.guggy.com/logo_128.png' ,
attachments : [ {
color : '#ff0000' ,
text : 'Yay for gruggy!' ,
@ -147,7 +157,9 @@ describe('[Chat]', function() {
. send ( {
channel : 'general' ,
text : 'Sample message' ,
alias : 'Gruggy' ,
emoji : ':smirk:' ,
avatar : 'http://res.guggy.com/logo_128.png' ,
attachments : [ {
color : '#ff0000' ,
text : 'Yay for gruggy!' ,
@ -180,6 +192,7 @@ describe('[Chat]', function() {
text : 'Sample message' ,
emoji : ':smirk:' ,
avatar : 'javascript:alert("xss")' ,
alias : 'Gruggy' ,
attachments : [ {
color : '#ff0000' ,
text : 'Yay for gruggy!' ,
@ -210,7 +223,9 @@ describe('[Chat]', function() {
. send ( {
channel : 'general' ,
text : 'Sample message' ,
alias : 'Gruggy' ,
emoji : ':smirk:' ,
avatar : 'http://res.guggy.com/logo_128.png' ,
attachments : [ {
color : '#ff0000' ,
text : 'Yay for gruggy!' ,
@ -243,6 +258,8 @@ describe('[Chat]', function() {
channel : 'general' ,
text : 'Sample message' ,
emoji : ':smirk:' ,
alias : 'Gruggy' ,
avatar : 'http://res.guggy.com/logo_128.png' ,
attachments : [ {
color : '#ff0000' ,
text : 'Yay for gruggy!' ,
@ -268,6 +285,8 @@ describe('[Chat]', function() {
channel : 'general' ,
text : 'Sample message' ,
emoji : ':smirk:' ,
alias : 'Gruggy' ,
avatar : 'http://res.guggy.com/logo_128.png' ,
attachments : [ {
color : '#ff0000' ,
text : 'Yay for gruggy!' ,
@ -292,7 +311,9 @@ describe('[Chat]', function() {
. send ( {
channel : 'general' ,
text : 'Sample message' ,
alias : 'Gruggy' ,
emoji : ':smirk:' ,
avatar : 'http://res.guggy.com/logo_128.png' ,
attachments : [ {
color : '#ff0000' ,
text : 'Yay for gruggy!' ,
@ -316,7 +337,9 @@ describe('[Chat]', function() {
. send ( {
channel : 'general' ,
text : 'Sample message' ,
alias : 'Gruggy' ,
emoji : ':smirk:' ,
avatar : 'http://res.guggy.com/logo_128.png' ,
attachments : [ {
color : '#ff0000' ,
text : 'Yay for gruggy!' ,
@ -339,8 +362,10 @@ describe('[Chat]', function() {
. set ( credentials )
. send ( {
channel : 'general' ,
alias : 'Gruggy' ,
text : 'Sample message' ,
emoji : ':smirk:' ,
avatar : 'http://res.guggy.com/logo_128.png' ,
attachments : [ {
color : '#ff0000' ,
text : 'Yay for gruggy!' ,
@ -367,6 +392,8 @@ describe('[Chat]', function() {
channel : 'general' ,
text : 'Sample message' ,
emoji : ':smirk:' ,
alias : 'Gruggy' ,
avatar : 'http://res.guggy.com/logo_128.png' ,
attachments : [ {
color : '#ff0000' ,
text : 'Yay for gruggy!' ,
@ -399,7 +426,7 @@ describe('[Chat]', function() {
. end ( done ) ;
} ) ;
it ( 'should throw an error when the user try to set alias and avatar and he is not a BOT user ' , ( done ) => {
it ( 'should return statusCode 200 when postMessage successfully ' , ( done ) => {
request . post ( api ( 'chat.postMessage' ) )
. set ( credentials )
. send ( {
@ -408,42 +435,6 @@ describe('[Chat]', function() {
alias : 'Gruggy' ,
emoji : ':smirk:' ,
avatar : 'http://res.guggy.com/logo_128.png' ,
attachments : [ {
color : '#ff0000' ,
text : 'Yay for gruggy!' ,
ts : '2016-12-09T16:53:06.761Z' ,
thumb _url : 'http://res.guggy.com/logo_128.png' ,
message _link : 12 ,
collapsed : false ,
author _name : 'Bradley Hilton' ,
author _link : 'https://rocket.chat/' ,
author _icon : 'https://avatars.githubusercontent.com/u/850391?v=3' ,
title : 'Attachment Example' ,
title _link : 'https://youtube.com' ,
title _link _download : 'https://youtube.com' ,
image _url : 'http://res.guggy.com/logo_128.png' ,
audio _url : 'http://www.w3schools.com/tags/horse.mp3' ,
video _url : 'http://www.w3schools.com/tags/movie.mp4' ,
fields : '' ,
} ] ,
} )
. expect ( 'Content-Type' , 'application/json' )
. expect ( 400 )
. expect ( ( res ) => {
expect ( res . body ) . to . have . property ( 'success' , false ) ;
expect ( res . body ) . to . have . property ( 'error' ) ;
} )
. end ( done ) ;
} ) ;
it ( 'should return statusCode 200 when postMessage successfully' , ( done ) => {
request . post ( api ( 'chat.postMessage' ) )
. set ( credentials )
. send ( {
channel : 'general' ,
text : 'Sample message' ,
emoji : ':smirk:' ,
attachments : [ {
color : '#ff0000' ,
text : 'Yay for gruggy!' ,
@ -506,7 +497,9 @@ describe('[Chat]', function() {
. send ( {
message : {
text : 'Sample message' ,
alias : 'Gruggy' ,
emoji : ':smirk:' ,
avatar : 'http://res.guggy.com/logo_128.png' ,
} ,
} )
. expect ( 'Content-Type' , 'application/json' )
@ -524,8 +517,10 @@ describe('[Chat]', function() {
. set ( credentials )
. send ( {
channel : 'general' ,
alias : 'Gruggy' ,
text : 'Sample message' ,
emoji : ':smirk:' ,
avatar : 'http://res.guggy.com/logo_128.png' ,
attachments : [ {
color : '#ff0000' ,
text : 'Yay for gruggy!' ,
@ -549,7 +544,9 @@ describe('[Chat]', function() {
. send ( {
channel : 'general' ,
text : 'Sample message' ,
alias : 'Gruggy' ,
emoji : ':smirk:' ,
avatar : 'http://res.guggy.com/logo_128.png' ,
attachments : [ {
color : '#ff0000' ,
text : 'Yay for gruggy!' ,
@ -573,7 +570,9 @@ describe('[Chat]', function() {
. send ( {
channel : 'general' ,
text : 'Sample message' ,
alias : 'Gruggy' ,
emoji : ':smirk:' ,
avatar : 'http://res.guggy.com/logo_128.png' ,
attachments : [ {
color : '#ff0000' ,
text : 'Yay for gruggy!' ,
@ -597,7 +596,9 @@ describe('[Chat]', function() {
. send ( {
channel : 'general' ,
text : 'Sample message' ,
alias : 'Gruggy' ,
emoji : ':smirk:' ,
avatar : 'http://res.guggy.com/logo_128.png' ,
attachments : [ {
color : '#ff0000' ,
text : 'Yay for gruggy!' ,
@ -624,43 +625,6 @@ describe('[Chat]', function() {
} ) ;
it ( 'should throw an error when it has some properties with the wrong type(attachments.title_link_download, attachments.fields, message_link)' , ( done ) => {
request . post ( api ( 'chat.sendMessage' ) )
. set ( credentials )
. send ( {
message : {
channel : 'general' ,
text : 'Sample message' ,
emoji : ':smirk:' ,
attachments : [ {
color : '#ff0000' ,
text : 'Yay for gruggy!' ,
ts : '2016-12-09T16:53:06.761Z' ,
thumb _url : 'http://res.guggy.com/logo_128.png' ,
message _link : 12 ,
collapsed : false ,
author _name : 'Bradley Hilton' ,
author _link : 'https://rocket.chat/' ,
author _icon : 'https://avatars.githubusercontent.com/u/850391?v=3' ,
title : 'Attachment Example' ,
title _link : 'https://youtube.com' ,
title _link _download : 'https://youtube.com' ,
image _url : 'http://res.guggy.com/logo_128.png' ,
audio _url : 'http://www.w3schools.com/tags/horse.mp3' ,
video _url : 'http://www.w3schools.com/tags/movie.mp4' ,
fields : '' ,
} ] ,
} ,
} )
. expect ( 'Content-Type' , 'application/json' )
. expect ( 400 )
. expect ( ( res ) => {
expect ( res . body ) . to . have . property ( 'success' , false ) ;
expect ( res . body ) . to . have . property ( 'error' ) ;
} )
. end ( done ) ;
} ) ;
it ( 'should throw an error when the user try to set alias and avatar and he is not a BOT user' , ( done ) => {
request . post ( api ( 'chat.sendMessage' ) )
. set ( credentials )
. send ( {
@ -708,7 +672,9 @@ describe('[Chat]', function() {
_id : message . _id ,
rid : 'GENERAL' ,
msg : 'Sample message' ,
alias : 'Gruggy' ,
emoji : ':smirk:' ,
avatar : 'http://res.guggy.com/logo_128.png' ,
attachments : [ {
color : '#ff0000' ,
text : 'Yay for gruggy!' ,