File tree 1 file changed +35
-0
lines changed
1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change
1
+ import fetch from 'jest-fetch-mock' ;
2
+ import { StitchAdminClientFactory } from '../src/admin' ;
3
+
4
+ describe ( 'Recaptcha' , ( ) => {
5
+ const token = 'my-little-token' ;
6
+
7
+ beforeEach ( async ( ) => {
8
+ global [ 'fetch' ] = fetch ;
9
+ fetch . mockResponseOnce ( Promise . resolve ( ) ) ;
10
+ let adminClient = await StitchAdminClientFactory . create ( ) ;
11
+ await adminClient . verifyRecaptcha ( token ) ;
12
+ } ) ;
13
+
14
+ afterEach ( ( ) => fetch . resetMocks ( ) ) ;
15
+
16
+ it ( 'should be verified with cors enabled' , ( ) => {
17
+ expect ( fetch . mock . calls . length ) . toEqual ( 1 ) ;
18
+ expect ( fetch . mock . calls [ 0 ] [ 1 ] . cors ) . toBeTruthy ( ) ;
19
+ } ) ;
20
+
21
+ it ( 'should allow cookies to be sent with the request' , ( ) => {
22
+ expect ( fetch . mock . calls . length ) . toEqual ( 1 ) ;
23
+ expect ( fetch . mock . calls [ 0 ] [ 1 ] . credentials ) . toEqual ( 'include' ) ;
24
+ } ) ;
25
+
26
+ it ( 'should use URLSearchParams to submit token' , ( ) => {
27
+ expect ( fetch . mock . calls . length ) . toEqual ( 1 ) ;
28
+ expect ( fetch . mock . calls [ 0 ] [ 1 ] . body ) . toBeInstanceOf ( URLSearchParams ) ;
29
+ } ) ;
30
+
31
+ it ( 'should let the request determine the Content Type' , ( ) => {
32
+ expect ( fetch . mock . calls . length ) . toEqual ( 1 ) ;
33
+ expect ( fetch . mock . calls [ 0 ] [ 1 ] . headers [ 'Content-Type' ] ) . toBeUndefined ( ) ;
34
+ } ) ;
35
+ } ) ;
You can’t perform that action at this time.
0 commit comments