@@ -31,7 +31,7 @@ describe('WickrBot', function() {
3131 bot . listen ( 'foo' , spyFn )
3232 bot . handleMessage ( ) ( fakeMsg )
3333
34- sinon . assert . calledOnceWithExactly ( spyFn , JSON . parse ( fakeMsg ) , [ 'bar' , 'baz' ] )
34+ sinon . assert . calledOnceWithMatch ( spyFn , JSON . parse ( fakeMsg ) , [ 'bar' , 'baz' ] )
3535 } )
3636
3737 describe ( '#handleMessage' , function ( ) {
@@ -53,6 +53,26 @@ describe('WickrBot', function() {
5353 bot . handleMessage ( ) ( fakeMsg )
5454 } )
5555
56+ it ( 'sets the `is_room` field to `true` on messages sent to a room' , function ( ) {
57+ let fakeMsg = '{"msgtype": 1000, "message": "/foo@fake-bot bar baz"}'
58+ let spyFn = sinon . spy ( )
59+ let bot = new WickrBot ( this . wickr , 'foo' )
60+
61+ bot . listen ( 'foo' , spyFn )
62+ bot . handleMessage ( ) ( fakeMsg )
63+ sinon . assert . calledOnceWithExactly ( spyFn , { is_room : true , ...JSON . parse ( fakeMsg ) } , [ 'bar' , 'baz' ] )
64+ } )
65+
66+ it ( 'sets the `is_room` field to `false` on messages sent in a 1:1' , function ( ) {
67+ let fakeMsg = '{"msgtype": 1000, "receiver": "bob", "message": "/foo@fake-bot bar baz"}'
68+ let spyFn = sinon . spy ( )
69+ let bot = new WickrBot ( this . wickr , 'foo' )
70+
71+ bot . listen ( 'foo' , spyFn )
72+ bot . handleMessage ( ) ( fakeMsg )
73+ sinon . assert . calledOnceWithExactly ( spyFn , { is_room : false , ...JSON . parse ( fakeMsg ) } , [ 'bar' , 'baz' ] )
74+ } )
75+
5676 it ( 'calls the default listener for non-slash command messages' , function ( ) {
5777 let fakeMsg = '{"msgtype": 1000, "message": "hey what\'s up?"}'
5878 let spyFn = sinon . spy ( )
@@ -61,7 +81,7 @@ describe('WickrBot', function() {
6181 bot . setDefaultHandler ( spyFn )
6282 bot . handleMessage ( ) ( fakeMsg )
6383
64- sinon . assert . calledOnceWithExactly ( spyFn , JSON . parse ( fakeMsg ) , [ 'hey' , 'what\'s' , 'up?' ] )
84+ sinon . assert . calledOnceWithMatch ( spyFn , JSON . parse ( fakeMsg ) , [ 'hey' , 'what\'s' , 'up?' ] )
6585 } )
6686
6787 it ( 'calls the file handler for files' , function ( ) {
@@ -72,7 +92,7 @@ describe('WickrBot', function() {
7292 bot . setFileHandler ( spyFn )
7393 bot . handleMessage ( ) ( fakeMsg )
7494
75- sinon . assert . calledOnceWithExactly ( spyFn , JSON . parse ( fakeMsg ) , undefined )
95+ sinon . assert . calledOnceWithMatch ( spyFn , JSON . parse ( fakeMsg ) , undefined )
7696 } )
7797
7898 it ( 'calls the default handler for any message type' , function ( ) {
@@ -83,7 +103,7 @@ describe('WickrBot', function() {
83103 bot . setDefaultHandler ( spyFn )
84104 bot . handleMessage ( ) ( fakeMsg )
85105
86- sinon . assert . calledOnceWithExactly ( spyFn , JSON . parse ( fakeMsg ) , undefined )
106+ sinon . assert . calledOnceWithMatch ( spyFn , JSON . parse ( fakeMsg ) , undefined )
87107 } )
88108
89109 it ( 'prefers the file handler over the default handler for file type messages' , function ( ) {
@@ -95,7 +115,7 @@ describe('WickrBot', function() {
95115 bot . setDefaultHandler ( spyFnDefault )
96116 bot . handleMessage ( ) ( fakeMsg )
97117
98- sinon . assert . calledOnceWithExactly ( spyFn , JSON . parse ( fakeMsg ) , undefined )
118+ sinon . assert . calledOnceWithMatch ( spyFn , JSON . parse ( fakeMsg ) , undefined )
99119 sinon . assert . notCalled ( spyFnDefault )
100120 } )
101121 } )
0 commit comments