@@ -631,7 +631,7 @@ it("throws PrismicError if response is not 200, 400, 401, 403, or 404", async (c
631
631
const client = createTestClient ( ) ;
632
632
633
633
const queryEndpoint = new URL (
634
- "documents/search" ,
634
+ "./ documents/search" ,
635
635
`${ client . endpoint } /` ,
636
636
) . toString ( ) ;
637
637
@@ -684,6 +684,60 @@ it("throws NotFoundError if repository does not exist", async (ctx) => {
684
684
await expect ( ( ) => client . get ( ) ) . rejects . toThrowError ( prismic . NotFoundError ) ;
685
685
} ) ;
686
686
687
+ it ( "throws RefNotFoundError if ref does not exist" , async ( ctx ) => {
688
+ const queryResponse = {
689
+ type : "api_notfound_error" ,
690
+ message : "message" ,
691
+ } ;
692
+
693
+ mockPrismicRestAPIV2 ( { ctx } ) ;
694
+
695
+ const client = createTestClient ( ) ;
696
+
697
+ const queryEndpoint = new URL (
698
+ "./documents/search" ,
699
+ `${ client . endpoint } /` ,
700
+ ) . toString ( ) ;
701
+
702
+ ctx . server . use (
703
+ msw . rest . get ( queryEndpoint , ( _req , res , ctx ) => {
704
+ return res ( ctx . status ( 404 ) , ctx . json ( queryResponse ) ) ;
705
+ } ) ,
706
+ ) ;
707
+
708
+ await expect ( ( ) => client . get ( ) ) . rejects . toThrowError ( queryResponse . message ) ;
709
+ await expect ( ( ) => client . get ( ) ) . rejects . toThrowError (
710
+ prismic . RefNotFoundError ,
711
+ ) ;
712
+ } ) ;
713
+
714
+ it ( "throws RefExpiredError if ref is expired" , async ( ctx ) => {
715
+ const queryResponse = {
716
+ type : "api_validation_error" ,
717
+ message : "message" ,
718
+ } ;
719
+
720
+ mockPrismicRestAPIV2 ( { ctx } ) ;
721
+
722
+ const client = createTestClient ( ) ;
723
+
724
+ const queryEndpoint = new URL (
725
+ "./documents/search" ,
726
+ `${ client . endpoint } /` ,
727
+ ) . toString ( ) ;
728
+
729
+ ctx . server . use (
730
+ msw . rest . get ( queryEndpoint , ( _req , res , ctx ) => {
731
+ return res ( ctx . status ( 410 ) , ctx . json ( queryResponse ) ) ;
732
+ } ) ,
733
+ ) ;
734
+
735
+ await expect ( ( ) => client . get ( ) ) . rejects . toThrowError ( queryResponse . message ) ;
736
+ await expect ( ( ) => client . get ( ) ) . rejects . toThrowError (
737
+ prismic . RefExpiredError ,
738
+ ) ;
739
+ } ) ;
740
+
687
741
it ( "retries after `retry-after` milliseconds if response code is 429" , async ( ctx ) => {
688
742
const retryAfter = 200 ; // ms
689
743
/**
0 commit comments