@@ -2,6 +2,7 @@ import fetch from 'jest-fetch-mock';
22import { renderHook , act , waitFor } from '@testing-library/react' ;
33import useCollection from './useCollection' ;
44import wrapper from './wrapper' ;
5+ import { ApiError } from '../utils/ApiError' ;
56
67describe ( 'useCollection' , ( ) => {
78 beforeEach ( ( ) => {
@@ -31,11 +32,14 @@ describe('useCollection', () => {
3132
3233 const { result } = renderHook ( ( ) => useCollection ( 'nonexistent' ) , { wrapper } ) ;
3334 await waitFor ( ( ) =>
34- expect ( result . current . error ) . toEqual ( {
35- status : 404 ,
36- statusText : 'Not Found' ,
37- detail : { error : 'Collection not found' } ,
38- } )
35+ expect ( result . current . error ) . toEqual (
36+ new ApiError (
37+ 'Not Found' ,
38+ 404 ,
39+ { error : 'Collection not found' } ,
40+ 'https://fake-stac-api.net/collections/nonexistent'
41+ )
42+ )
3943 ) ;
4044 } ) ;
4145
@@ -49,11 +53,14 @@ describe('useCollection', () => {
4953
5054 const { result } = renderHook ( ( ) => useCollection ( 'abc' ) , { wrapper } ) ;
5155 await waitFor ( ( ) =>
52- expect ( result . current . error ) . toEqual ( {
53- status : 400 ,
54- statusText : 'Bad Request' ,
55- detail : { error : 'Wrong query' } ,
56- } )
56+ expect ( result . current . error ) . toEqual (
57+ new ApiError (
58+ 'Bad Request' ,
59+ 400 ,
60+ { error : 'Wrong query' } ,
61+ 'https://fake-stac-api.net/search'
62+ )
63+ )
5764 ) ;
5865 } ) ;
5966
@@ -64,11 +71,9 @@ describe('useCollection', () => {
6471
6572 const { result } = renderHook ( ( ) => useCollection ( 'abc' ) , { wrapper } ) ;
6673 await waitFor ( ( ) =>
67- expect ( result . current . error ) . toEqual ( {
68- status : 400 ,
69- statusText : 'Bad Request' ,
70- detail : 'Wrong query' ,
71- } )
74+ expect ( result . current . error ) . toEqual (
75+ new ApiError ( 'Bad Request' , 400 , 'Wrong query' , 'https://fake-stac-api.net/search' )
76+ )
7277 ) ;
7378 } ) ;
7479
0 commit comments