@@ -30,7 +30,7 @@ describe('basic tests (hello function)', () => {
3030 } )
3131
3232 log ( 'invoke hello' )
33- const { data, error } = await fclient . invoke ( 'hello' , { responseType : 'text' } )
33+ const { data, error } = await fclient . invoke < string > ( 'hello' , { responseType : 'text' } )
3434
3535 log ( 'assert no error' )
3636 assert . isNull ( error )
@@ -45,7 +45,7 @@ describe('basic tests (hello function)', () => {
4545 fclient . setAuth ( apiKey )
4646
4747 log ( 'invoke hello' )
48- const { data, error } = await fclient . invoke ( 'hello' , { responseType : 'text' } )
48+ const { data, error } = await fclient . invoke < string > ( 'hello' , { responseType : 'text' } )
4949
5050 log ( 'assert no error' )
5151 assert . isNull ( error )
@@ -61,13 +61,12 @@ describe('basic tests (hello function)', () => {
6161 fclient . setAuth ( wrongKey )
6262
6363 log ( 'invoke hello' )
64- const { data, error } = await fclient . invoke ( 'hello' , { responseType : 'text' } )
64+ const { data, error } = await fclient . invoke < string > ( 'hello' , { responseType : 'text' } )
6565
6666 log ( 'check error' )
6767 assert . isNotNull ( error )
68- // todo check error
69- log ( `assert ${ data } is equal to 'Invalid JWT'` )
70- assert . equal ( data , 'Invalid JWT' )
68+ assert . equal ( error ?. message , 'Invalid JWT' )
69+ assert . isNull ( data )
7170 } )
7271
7372 it ( 'invoke hello: auth override by setAuth wrong key' , async ( ) => {
@@ -80,13 +79,12 @@ describe('basic tests (hello function)', () => {
8079 fclient . setAuth ( wrongKey )
8180
8281 log ( 'invoke hello' )
83- const { data, error } = await fclient . invoke ( 'hello' , { responseType : 'text' } )
82+ const { data, error } = await fclient . invoke < string > ( 'hello' , { responseType : 'text' } )
8483
8584 log ( 'check error' )
8685 assert . isNotNull ( error )
87- // todo check error
88- log ( `assert ${ data } is equal to 'Invalid JWT'` )
89- assert . equal ( data , 'Invalid JWT' )
86+ assert . equal ( error ?. message , 'Invalid JWT' )
87+ assert . isNull ( data )
9088 } )
9189
9290 it ( 'invoke hello: auth override by setAuth right key' , async ( ) => {
@@ -101,7 +99,7 @@ describe('basic tests (hello function)', () => {
10199 fclient . setAuth ( apiKey )
102100
103101 log ( 'invoke hello' )
104- const { data, error } = await fclient . invoke ( 'hello' , { responseType : 'text' } )
102+ const { data, error } = await fclient . invoke < string > ( 'hello' , { responseType : 'text' } )
105103
106104 log ( 'assert no error' )
107105 assert . isNull ( error )
@@ -114,7 +112,7 @@ describe('basic tests (hello function)', () => {
114112 const fclient = new FunctionsClient ( `http://localhost:${ relay . container . getMappedPort ( 8081 ) } ` )
115113
116114 log ( 'invoke hello with Authorization header' )
117- const { data, error } = await fclient . invoke ( 'hello' , {
115+ const { data, error } = await fclient . invoke < string > ( 'hello' , {
118116 responseType : 'text' ,
119117 headers : {
120118 Authorization : `Bearer ${ apiKey } ` ,
@@ -136,7 +134,7 @@ describe('basic tests (hello function)', () => {
136134 fclient . setAuth ( wrongKey )
137135
138136 log ( 'invoke hello with Authorization header' )
139- const { data, error } = await fclient . invoke ( 'hello' , {
137+ const { data, error } = await fclient . invoke < string > ( 'hello' , {
140138 responseType : 'text' ,
141139 headers : {
142140 Authorization : `Bearer ${ apiKey } ` ,
@@ -157,7 +155,7 @@ describe('basic tests (hello function)', () => {
157155
158156 const wrongKey = sign ( { name : 'anon' } , 'wrong_jwt' )
159157 log ( 'invoke hello with wrong Authorization header' )
160- const { data, error } = await fclient . invoke ( 'hello' , {
158+ const { data, error } = await fclient . invoke < string > ( 'hello' , {
161159 responseType : 'text' ,
162160 headers : {
163161 Authorization : `Bearer ${ wrongKey } ` ,
@@ -166,23 +164,23 @@ describe('basic tests (hello function)', () => {
166164
167165 log ( 'check error' )
168166 assert . isNotNull ( error )
169- // todo check error
170- log ( `assert ${ data } is equal to 'Invalid JWT'` )
171- assert . equal ( data , 'Invalid JWT' )
167+ assert . equal ( error ?. message , 'Invalid JWT' )
168+ assert . isNull ( data )
172169 } )
173170
174- it ( 'invoke missing function' , async ( ) => {
171+ it . skip ( 'invoke missing function' , async ( ) => {
175172 log ( 'create FunctionsClient' )
176173 const fclient = new FunctionsClient ( `http://localhost:${ relay . container . getMappedPort ( 8081 ) } ` , {
177174 Authorization : `Bearer ${ apiKey } ` ,
178175 } )
179176
180177 log ( 'invoke hello' )
181- const { data, error } = await fclient . invoke ( 'missing' , { responseType : 'text' } )
178+ const { data, error } = await fclient . invoke < string > ( 'missing' , { responseType : 'text' } )
182179
183180 log ( 'check error' )
184181 assert . isNotNull ( error )
185- // todo check error and data
182+ assert . equal ( error ?. message , 'Invalid JWT' )
183+ assert . isNull ( data )
186184 } )
187185
188186 it ( 'invoke with custom fetch' , async ( ) => {
@@ -199,7 +197,7 @@ describe('basic tests (hello function)', () => {
199197 )
200198
201199 log ( 'invoke hello' )
202- const { data, error } = await fclient . invoke ( '' , { responseType : 'text' } )
200+ const { data, error } = await fclient . invoke < string > ( '' , { responseType : 'text' } )
203201
204202 log ( 'assert no error' )
205203 assert . isNull ( error )
@@ -221,13 +219,13 @@ describe('basic tests (hello function)', () => {
221219 )
222220
223221 log ( 'invoke hello' )
224- const { data, error } = await fclient . invoke ( '' , { responseType : 'text' } )
222+ const { data, error } = await fclient . invoke < string > ( '' , { responseType : 'text' } )
225223
226224 log ( 'check error' )
227225 assert . isNotNull ( error )
228- // todo check error
229- log ( ` assert ${ data } is equal to 'Only POST requests are supported'` )
230- assert . equal ( data , 'Only POST requests are supported' )
226+ log ( `assert ${ error ?. message } is equal to 'Only POST and OPTIONS requests are supported'` )
227+ assert . equal ( error ?. message , 'Only POST and OPTIONS requests are supported' )
228+ assert . isNull ( data )
231229 } )
232230
233231 it ( 'invoke hello with custom fetch override header' , async ( ) => {
@@ -247,7 +245,7 @@ describe('basic tests (hello function)', () => {
247245 )
248246
249247 log ( 'invoke hello with Authorization header' )
250- const { data, error } = await fclient . invoke ( 'hello' , {
248+ const { data, error } = await fclient . invoke < string > ( 'hello' , {
251249 responseType : 'text' ,
252250 } )
253251
0 commit comments