@@ -38,99 +38,99 @@ describe('GcloudPubSubService', () => {
3838 const data = 'You Tried Your Best and You Failed Miserably. The Lesson Is Never Try'
3939 const gcloudPubSubLibMock = {
4040 topic : jest . fn ( ) . mockReturnThis ( ) ,
41- publish : jest . fn ( ( buffer ) => {
42- expect ( buffer ) . toMatchSnapshot ( )
41+ publishMessage : jest . fn ( ( { data } ) => {
42+ expect ( data ) . toMatchSnapshot ( )
4343 } ) ,
4444 }
4545
4646 service . gcloudPubSubLib = gcloudPubSubLibMock as any
4747 service . publishMessage ( topic , data )
48- expect ( gcloudPubSubLibMock . publish ) . toHaveBeenCalled ( )
48+ expect ( gcloudPubSubLibMock . publishMessage ) . toHaveBeenCalled ( )
4949 } )
5050 it ( 'handles Buffer as data' , ( ) => {
5151 const topic = 'Homer'
5252 const data = 'You Tried Your Best and You Failed Miserably. The Lesson Is Never Try'
5353 const gcloudPubSubLibMock = {
5454 topic : jest . fn ( ) . mockReturnThis ( ) ,
55- publish : jest . fn ( ( buffer ) => {
56- expect ( buffer ) . toMatchSnapshot ( )
55+ publishMessage : jest . fn ( ( { data } ) => {
56+ expect ( data ) . toMatchSnapshot ( )
5757 } ) ,
5858 }
5959
6060 service . gcloudPubSubLib = gcloudPubSubLibMock as any
6161 service . publishMessage ( topic , Buffer . from ( data ) )
62- expect ( gcloudPubSubLibMock . publish ) . toHaveBeenCalled ( )
62+ expect ( gcloudPubSubLibMock . publishMessage ) . toHaveBeenCalled ( )
6363 } )
6464 it ( 'handles an array of numbers as data' , ( ) => {
6565 const topic = 'Homer'
6666 const data = [ 10 , 20 , 30 , 40 , 50 ]
6767 const gcloudPubSubLibMock = {
6868 topic : jest . fn ( ) . mockReturnThis ( ) ,
69- publish : jest . fn ( ( buffer ) => {
70- expect ( buffer ) . toMatchSnapshot ( )
69+ publishMessage : jest . fn ( ( { data } ) => {
70+ expect ( data ) . toMatchSnapshot ( )
7171 } ) ,
7272 }
7373
7474 service . gcloudPubSubLib = gcloudPubSubLibMock as any
7575 service . publishMessage ( topic , data )
76- expect ( gcloudPubSubLibMock . publish ) . toHaveBeenCalled ( )
76+ expect ( gcloudPubSubLibMock . publishMessage ) . toHaveBeenCalled ( )
7777 } )
7878 it ( 'handles an ArrayBuffer as data' , ( ) => {
7979 const topic = 'Homer'
8080 const data = new ArrayBuffer ( 1 )
8181 const gcloudPubSubLibMock = {
8282 topic : jest . fn ( ) . mockReturnThis ( ) ,
83- publish : jest . fn ( ( buffer ) => {
84- expect ( buffer ) . toMatchSnapshot ( )
83+ publishMessage : jest . fn ( ( { data } ) => {
84+ expect ( data ) . toMatchSnapshot ( )
8585 } ) ,
8686 }
8787
8888 service . gcloudPubSubLib = gcloudPubSubLibMock as any
8989 service . publishMessage ( topic , data )
90- expect ( gcloudPubSubLibMock . publish ) . toHaveBeenCalled ( )
90+ expect ( gcloudPubSubLibMock . publishMessage ) . toHaveBeenCalled ( )
9191 } )
9292 it ( 'handles a SharedArrayBuffer as data' , ( ) => {
9393 const topic = 'Homer'
9494 const data = new SharedArrayBuffer ( 1 )
9595 const gcloudPubSubLibMock = {
9696 topic : jest . fn ( ) . mockReturnThis ( ) ,
97- publish : jest . fn ( ( buffer ) => {
98- expect ( buffer ) . toMatchSnapshot ( )
97+ publishMessage : jest . fn ( ( { data } ) => {
98+ expect ( data ) . toMatchSnapshot ( )
9999 } ) ,
100100 }
101101
102102 service . gcloudPubSubLib = gcloudPubSubLibMock as any
103103 service . publishMessage ( topic , data )
104- expect ( gcloudPubSubLibMock . publish ) . toHaveBeenCalled ( )
104+ expect ( gcloudPubSubLibMock . publishMessage ) . toHaveBeenCalled ( )
105105 } )
106106 it ( 'handles a Uint8Array as data' , ( ) => {
107107 const topic = 'Homer'
108108 const data = new Uint8Array ( [ 1 , 2 , 3 ] )
109109 const gcloudPubSubLibMock = {
110110 topic : jest . fn ( ) . mockReturnThis ( ) ,
111- publish : jest . fn ( ( buffer ) => {
112- expect ( buffer ) . toMatchSnapshot ( )
111+ publishMessage : jest . fn ( ( { data } ) => {
112+ expect ( data ) . toMatchSnapshot ( )
113113 } ) ,
114114 }
115115
116116 service . gcloudPubSubLib = gcloudPubSubLibMock as any
117117 service . publishMessage ( topic , data )
118- expect ( gcloudPubSubLibMock . publish ) . toHaveBeenCalled ( )
118+ expect ( gcloudPubSubLibMock . publishMessage ) . toHaveBeenCalled ( )
119119 } )
120120 it ( 'handles a string and binary encoding' , ( ) => {
121121 const topic = 'Homer'
122122 const data = 'You Tried Your Best and You Failed Miserably. The Lesson Is Never Try'
123123 const encoding = 'binary'
124124 const gcloudPubSubLibMock = {
125125 topic : jest . fn ( ) . mockReturnThis ( ) ,
126- publish : jest . fn ( ( buffer ) => {
127- expect ( buffer ) . toMatchSnapshot ( )
126+ publishMessage : jest . fn ( ( { data } ) => {
127+ expect ( data ) . toMatchSnapshot ( )
128128 } ) ,
129129 }
130130
131131 service . gcloudPubSubLib = gcloudPubSubLibMock as any
132132 service . publishMessage ( topic , data , { } , encoding )
133- expect ( gcloudPubSubLibMock . publish ) . toHaveBeenCalled ( )
133+ expect ( gcloudPubSubLibMock . publishMessage ) . toHaveBeenCalled ( )
134134 } )
135135 } )
136136 } )
0 commit comments