@ -24,7 +24,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 )
@ -40,8 +42,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!' ,
@ -76,7 +80,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' ,
@ -100,7 +106,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!' ,
@ -146,7 +156,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!' ,
@ -178,6 +190,7 @@ describe('[Chat]', function() {
text : 'Sample message' ,
emoji : ':smirk:' ,
avatar : 'javascript:alert("xss")' ,
alias : 'Gruggy' ,
attachments : [ {
color : '#ff0000' ,
text : 'Yay for gruggy!' ,
@ -207,7 +220,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!' ,
@ -239,6 +254,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!' ,
@ -263,6 +280,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!' ,
@ -286,7 +305,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!' ,
@ -309,7 +330,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!' ,
@ -331,8 +354,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!' ,
@ -358,6 +383,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!' ,
@ -390,7 +417,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 ( {
@ -399,42 +426,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!' ,
@ -497,7 +488,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' )
@ -515,8 +508,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!' ,
@ -539,7 +534,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!' ,
@ -562,7 +559,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!' ,
@ -585,7 +584,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!' ,
@ -611,43 +612,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 ( {
@ -695,7 +659,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!' ,