@@ -30,7 +30,7 @@ describe('basic tests (hello function)', () => {
30
30
} )
31
31
32
32
log ( 'invoke hello' )
33
- const { data, error } = await fclient . invoke ( 'hello' , { responseType : 'text' } )
33
+ const { data, error } = await fclient . invoke < string > ( 'hello' , { responseType : 'text' } )
34
34
35
35
log ( 'assert no error' )
36
36
assert . isNull ( error )
@@ -45,7 +45,7 @@ describe('basic tests (hello function)', () => {
45
45
fclient . setAuth ( apiKey )
46
46
47
47
log ( 'invoke hello' )
48
- const { data, error } = await fclient . invoke ( 'hello' , { responseType : 'text' } )
48
+ const { data, error } = await fclient . invoke < string > ( 'hello' , { responseType : 'text' } )
49
49
50
50
log ( 'assert no error' )
51
51
assert . isNull ( error )
@@ -61,13 +61,12 @@ describe('basic tests (hello function)', () => {
61
61
fclient . setAuth ( wrongKey )
62
62
63
63
log ( 'invoke hello' )
64
- const { data, error } = await fclient . invoke ( 'hello' , { responseType : 'text' } )
64
+ const { data, error } = await fclient . invoke < string > ( 'hello' , { responseType : 'text' } )
65
65
66
66
log ( 'check error' )
67
67
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 )
71
70
} )
72
71
73
72
it ( 'invoke hello: auth override by setAuth wrong key' , async ( ) => {
@@ -80,13 +79,12 @@ describe('basic tests (hello function)', () => {
80
79
fclient . setAuth ( wrongKey )
81
80
82
81
log ( 'invoke hello' )
83
- const { data, error } = await fclient . invoke ( 'hello' , { responseType : 'text' } )
82
+ const { data, error } = await fclient . invoke < string > ( 'hello' , { responseType : 'text' } )
84
83
85
84
log ( 'check error' )
86
85
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 )
90
88
} )
91
89
92
90
it ( 'invoke hello: auth override by setAuth right key' , async ( ) => {
@@ -101,7 +99,7 @@ describe('basic tests (hello function)', () => {
101
99
fclient . setAuth ( apiKey )
102
100
103
101
log ( 'invoke hello' )
104
- const { data, error } = await fclient . invoke ( 'hello' , { responseType : 'text' } )
102
+ const { data, error } = await fclient . invoke < string > ( 'hello' , { responseType : 'text' } )
105
103
106
104
log ( 'assert no error' )
107
105
assert . isNull ( error )
@@ -114,7 +112,7 @@ describe('basic tests (hello function)', () => {
114
112
const fclient = new FunctionsClient ( `http://localhost:${ relay . container . getMappedPort ( 8081 ) } ` )
115
113
116
114
log ( 'invoke hello with Authorization header' )
117
- const { data, error } = await fclient . invoke ( 'hello' , {
115
+ const { data, error } = await fclient . invoke < string > ( 'hello' , {
118
116
responseType : 'text' ,
119
117
headers : {
120
118
Authorization : `Bearer ${ apiKey } ` ,
@@ -136,7 +134,7 @@ describe('basic tests (hello function)', () => {
136
134
fclient . setAuth ( wrongKey )
137
135
138
136
log ( 'invoke hello with Authorization header' )
139
- const { data, error } = await fclient . invoke ( 'hello' , {
137
+ const { data, error } = await fclient . invoke < string > ( 'hello' , {
140
138
responseType : 'text' ,
141
139
headers : {
142
140
Authorization : `Bearer ${ apiKey } ` ,
@@ -157,7 +155,7 @@ describe('basic tests (hello function)', () => {
157
155
158
156
const wrongKey = sign ( { name : 'anon' } , 'wrong_jwt' )
159
157
log ( 'invoke hello with wrong Authorization header' )
160
- const { data, error } = await fclient . invoke ( 'hello' , {
158
+ const { data, error } = await fclient . invoke < string > ( 'hello' , {
161
159
responseType : 'text' ,
162
160
headers : {
163
161
Authorization : `Bearer ${ wrongKey } ` ,
@@ -166,23 +164,23 @@ describe('basic tests (hello function)', () => {
166
164
167
165
log ( 'check error' )
168
166
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 )
172
169
} )
173
170
174
- it ( 'invoke missing function' , async ( ) => {
171
+ it . skip ( 'invoke missing function' , async ( ) => {
175
172
log ( 'create FunctionsClient' )
176
173
const fclient = new FunctionsClient ( `http://localhost:${ relay . container . getMappedPort ( 8081 ) } ` , {
177
174
Authorization : `Bearer ${ apiKey } ` ,
178
175
} )
179
176
180
177
log ( 'invoke hello' )
181
- const { data, error } = await fclient . invoke ( 'missing' , { responseType : 'text' } )
178
+ const { data, error } = await fclient . invoke < string > ( 'missing' , { responseType : 'text' } )
182
179
183
180
log ( 'check error' )
184
181
assert . isNotNull ( error )
185
- // todo check error and data
182
+ assert . equal ( error ?. message , 'Invalid JWT' )
183
+ assert . isNull ( data )
186
184
} )
187
185
188
186
it ( 'invoke with custom fetch' , async ( ) => {
@@ -199,7 +197,7 @@ describe('basic tests (hello function)', () => {
199
197
)
200
198
201
199
log ( 'invoke hello' )
202
- const { data, error } = await fclient . invoke ( '' , { responseType : 'text' } )
200
+ const { data, error } = await fclient . invoke < string > ( '' , { responseType : 'text' } )
203
201
204
202
log ( 'assert no error' )
205
203
assert . isNull ( error )
@@ -221,13 +219,13 @@ describe('basic tests (hello function)', () => {
221
219
)
222
220
223
221
log ( 'invoke hello' )
224
- const { data, error } = await fclient . invoke ( '' , { responseType : 'text' } )
222
+ const { data, error } = await fclient . invoke < string > ( '' , { responseType : 'text' } )
225
223
226
224
log ( 'check error' )
227
225
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 )
231
229
} )
232
230
233
231
it ( 'invoke hello with custom fetch override header' , async ( ) => {
@@ -247,7 +245,7 @@ describe('basic tests (hello function)', () => {
247
245
)
248
246
249
247
log ( 'invoke hello with Authorization header' )
250
- const { data, error } = await fclient . invoke ( 'hello' , {
248
+ const { data, error } = await fclient . invoke < string > ( 'hello' , {
251
249
responseType : 'text' ,
252
250
} )
253
251
0 commit comments