@@ -78,7 +78,7 @@ Object.keys(jwtTokens).forEach((jwtTokenName) => {
78
78
const mockCsrfToken = 'thetokenvalue' ;
79
79
const mockApiEndpointPath = `${ process . env . BASE_URL } /api/v1/test` ;
80
80
81
- global . location = { ...global . location , assign : jest . fn ( ) } ;
81
+ global . location ?? = { ...global . location , assign : jest . fn ( ) } ;
82
82
83
83
const mockCookies = new Cookies ( ) ;
84
84
@@ -885,17 +885,16 @@ describe('fetchAuthenticatedUser', () => {
885
885
886
886
// These tests all make real network calls to http://httpbin.org.
887
887
describe ( 'Cache Functionality' , ( ) => {
888
- const getUrl = 'http ://httpbin.org/get ' ;
889
- const postUrl = 'http ://httpbin.org/post ' ;
890
- const requestId = 'get-httpbin ' ;
888
+ const getUrl = 'https ://jsonplaceholder.typicode.com/posts/1 ' ;
889
+ const postUrl = 'https ://jsonplaceholder.typicode.com/posts ' ;
890
+ const requestId = 'get-jsonplaceholder-posts ' ;
891
891
892
892
const getWithRequestId = async ( config = { } ) => cachedClient . get ( getUrl , {
893
893
id : requestId ,
894
894
...config ,
895
895
} ) ;
896
896
897
897
const postWithRequestId = async ( config = { } ) => cachedClient . post ( postUrl , {
898
- id : requestId ,
899
898
...config ,
900
899
} ) ;
901
900
@@ -1001,15 +1000,15 @@ describe('Cache Functionality', () => {
1001
1000
} ) ;
1002
1001
1003
1002
it ( 'GET request: refreshes the jwt token' , async ( ) => {
1004
- const response = await cachedClient . get ( 'https://httpbin.org/get' ) ;
1003
+ const response = await cachedClient . get ( getUrl ) ;
1005
1004
expectSingleCallToJwtTokenRefresh ( ) ;
1006
1005
expectNoCallToCsrfTokenFetch ( ) ;
1007
1006
expectRequestToHaveJwtAuth ( response . config ) ;
1008
1007
} ) ;
1009
1008
1010
1009
[ 'post' , 'put' , 'patch' , 'delete' ] . forEach ( ( method ) => {
1011
1010
it ( `${ method . toUpperCase ( ) } : refreshes the csrf and jwt tokens` , async ( ) => {
1012
- const response = await cachedClient [ method ] ( `https://httpbin.org/ ${ method } ` ) ;
1011
+ const response = await cachedClient [ method ] ( method === 'post' ? postUrl : getUrl ) ;
1013
1012
expectSingleCallToJwtTokenRefresh ( ) ;
1014
1013
expectSingleCallToCsrfTokenFetch ( ) ;
1015
1014
expectRequestToHaveJwtAuth ( response . config ) ;
@@ -1035,7 +1034,7 @@ describe('Cache Functionality', () => {
1035
1034
[ 'post' , 'put' , 'patch' , 'delete' ] . forEach ( ( method ) => {
1036
1035
it ( `${ method . toUpperCase ( ) } : refreshes the csrf token but does not attempt to refresh the jwt token` , async ( ) => {
1037
1036
setJwtCookieTo ( jwtTokens . valid . encoded ) ;
1038
- const response = await cachedClient [ method ] ( `https://httpbin.org/ ${ method } ` , {
1037
+ const response = await cachedClient [ method ] ( method === 'post' ? postUrl : getUrl , {
1039
1038
id : requestId ,
1040
1039
} ) ;
1041
1040
expectNoCallToJwtTokenRefresh ( ) ;
@@ -1057,7 +1056,7 @@ describe('Cache Functionality', () => {
1057
1056
it ( `${ method . toUpperCase ( ) } : throws an error and calls logError` , async ( ) => {
1058
1057
expect . hasAssertions ( ) ;
1059
1058
try {
1060
- await cachedClient [ method ] ( `https://httpbin.org/ ${ method } ` , {
1059
+ await cachedClient [ method ] ( getUrl , {
1061
1060
id : requestId ,
1062
1061
} ) ;
1063
1062
} catch ( err ) {
0 commit comments