@@ -14,21 +14,21 @@ describe('fetchFromAPI', () => {
1414 fetchFromAPI ( {
1515 asPath : '/p/1' ,
1616 } )
17- expect ( fetchMock ) . toHaveBeenCalledWith ( '/api/p/1' , { headers } )
17+ expect ( fetchMock ) . toHaveBeenCalledWith ( '/api/p/1' , { credentials : 'include' , headers } )
1818 } )
1919
2020 it ( 'should call /api when the path is /' , ( ) => {
2121 fetchFromAPI ( {
2222 asPath : '/' ,
2323 } )
24- expect ( fetchMock ) . toHaveBeenCalledWith ( '/api' , { headers } )
24+ expect ( fetchMock ) . toHaveBeenCalledWith ( '/api' , { credentials : 'include' , headers } )
2525 } )
2626
2727 it ( 'should append query params directly to api if the root with query params is called' , ( ) => {
2828 fetchFromAPI ( {
2929 asPath : '/?test=1' ,
3030 } )
31- expect ( fetchMock ) . toHaveBeenCalledWith ( '/api?test=1' , { headers } )
31+ expect ( fetchMock ) . toHaveBeenCalledWith ( '/api?test=1' , { credentials : 'include' , headers } )
3232 } )
3333 } )
3434
@@ -50,6 +50,7 @@ describe('fetchFromAPI', () => {
5050 } ,
5151 } )
5252 expect ( fetchMock ) . toHaveBeenCalledWith ( 'https://www.domain.com/api/p/1?_includeAppData=1' , {
53+ credentials : 'include' ,
5354 headers : {
5455 ...headers ,
5556 'x-next-page' : '/api/p/[productId]' ,
@@ -71,6 +72,7 @@ describe('fetchFromAPI', () => {
7172 } )
7273
7374 expect ( fetchMock ) . toHaveBeenCalledWith ( 'http://localhost:3001/api/p/1?_includeAppData=1' , {
75+ credentials : 'include' ,
7476 headers : {
7577 ...headers ,
7678 'x-next-page' : '/api/p/[productId]' ,
@@ -92,6 +94,7 @@ describe('fetchFromAPI', () => {
9294 } ,
9395 } )
9496 expect ( fetchMock ) . toHaveBeenCalledWith ( 'http://localhost/api/p/1?_includeAppData=1' , {
97+ credentials : 'include' ,
9598 headers : {
9699 ...headers ,
97100 host : 'localhost' ,
@@ -111,6 +114,7 @@ describe('fetchFromAPI', () => {
111114 expect ( fetchMock ) . toHaveBeenCalledWith (
112115 'https://www.domain.com/api/foo?x=1&_includeAppData=1' ,
113116 {
117+ credentials : 'include' ,
114118 headers : {
115119 ...headers ,
116120 'x-next-page' : '/api/foo' ,
0 commit comments