@@ -3,7 +3,10 @@ import {
33 createTestableVertex ,
44 FakeExplorer ,
55} from "@/utils/testing" ;
6- import { patchEntityDetails } from "./patchEntityDetails" ;
6+ import {
7+ patchEntityDetails ,
8+ PatchEntityDetailsError ,
9+ } from "./patchEntityDetails" ;
710import { createQueryClient } from "@/core/queryClient" ;
811import {
912 createResultScalar ,
@@ -222,4 +225,77 @@ describe("patchEntityDetails", () => {
222225
223226 expect ( result ) . toStrictEqual ( [ expectedBundle ] ) ;
224227 } ) ;
228+
229+ it ( "should throw when source vertex not found" , async ( ) => {
230+ const explorer = new FakeExplorer ( ) ;
231+ const client = createQueryClient ( { explorer } ) ;
232+
233+ const edge = createTestableEdge ( ) ;
234+ explorer . addTestableEdge ( edge ) ;
235+ explorer . vertexMap . delete ( edge . source . id ) ;
236+
237+ await expect ( ( ) =>
238+ patchEntityDetails ( client , [ edge . asFragmentResult ( ) ] )
239+ ) . rejects . toThrow (
240+ new PatchEntityDetailsError ( "Failed to fetch the details of 1 vertex." )
241+ ) ;
242+ } ) ;
243+
244+ it ( "should throw when target vertex not found" , async ( ) => {
245+ const explorer = new FakeExplorer ( ) ;
246+ const client = createQueryClient ( { explorer } ) ;
247+
248+ const edge = createTestableEdge ( ) ;
249+ explorer . addTestableEdge ( edge ) ;
250+ explorer . vertexMap . delete ( edge . target . id ) ;
251+
252+ await expect ( ( ) =>
253+ patchEntityDetails ( client , [ edge . asFragmentResult ( ) ] )
254+ ) . rejects . toThrow (
255+ new PatchEntityDetailsError ( "Failed to fetch the details of 1 vertex." )
256+ ) ;
257+ } ) ;
258+
259+ it ( "should throw when edge full details not found" , async ( ) => {
260+ const explorer = new FakeExplorer ( ) ;
261+ const client = createQueryClient ( { explorer } ) ;
262+
263+ const edge = createTestableEdge ( ) ;
264+ explorer . addTestableEdge ( edge ) ;
265+ explorer . edgeMap . delete ( edge . id ) ;
266+
267+ await expect ( ( ) =>
268+ patchEntityDetails ( client , [ edge . asFragmentResult ( ) ] )
269+ ) . rejects . toThrow (
270+ new PatchEntityDetailsError ( "Failed to fetch the details of 1 edge." )
271+ ) ;
272+ } ) ;
273+
274+ it ( "should throw when multiple vertices and edges are not found" , async ( ) => {
275+ const explorer = new FakeExplorer ( ) ;
276+ const client = createQueryClient ( { explorer } ) ;
277+
278+ const vertex = createTestableVertex ( ) ;
279+ const edge1 = createTestableEdge ( ) ;
280+ const edge2 = createTestableEdge ( ) ;
281+ explorer . addTestableVertex ( vertex ) ;
282+ explorer . addTestableEdge ( edge1 ) ;
283+ explorer . addTestableEdge ( edge2 ) ;
284+ explorer . vertexMap . delete ( vertex . id ) ;
285+ explorer . vertexMap . delete ( edge1 . source . id ) ;
286+ explorer . edgeMap . delete ( edge1 . id ) ;
287+ explorer . edgeMap . delete ( edge2 . id ) ;
288+
289+ await expect ( ( ) =>
290+ patchEntityDetails ( client , [
291+ vertex . asFragmentResult ( ) ,
292+ edge1 . asFragmentResult ( ) ,
293+ edge2 . asFragmentResult ( ) ,
294+ ] )
295+ ) . rejects . toThrow (
296+ new PatchEntityDetailsError (
297+ "Failed to fetch the details of 2 vertices and 2 edges."
298+ )
299+ ) ;
300+ } ) ;
225301} ) ;
0 commit comments