@@ -314,6 +314,60 @@ class ParseQueryResponseTests: XCTestCase {
314314 }
315315 }
316316
317+ func testExtensionsEntryNotNullWhenProvidedInResponseAccompanyingDataEntry( ) throws {
318+ let query = HumanQuery ( id: " 9999 " )
319+
320+ let response = GraphQLResponse ( operation: query, body: [
321+ " data " : [ " human " : NSNull ( ) ] ,
322+ " extensions " : [ : ]
323+ ] )
324+
325+ let ( result, _) = try response. parseResult ( ) . await ( )
326+
327+ XCTAssertNotNil ( result. extensions)
328+ }
329+
330+ func testExtensionsValuesWhenPopulatedInResponse( ) throws {
331+ let query = HumanQuery ( id: " 9999 " )
332+
333+ let response = GraphQLResponse ( operation: query, body: [
334+ " data " : [ " human " : NSNull ( ) ] ,
335+ " extensions " : [ " parentKey " : [ " childKey " : " someValue " ] ]
336+ ] )
337+
338+ let ( result, _) = try response. parseResult ( ) . await ( )
339+ let extensionsDictionary = result. extensions
340+ let childDictionary = extensionsDictionary ? [ " parentKey " ] as? JSONObject
341+
342+ XCTAssertNotNil ( extensionsDictionary)
343+ XCTAssertNotNil ( childDictionary)
344+ XCTAssertEqual ( childDictionary, [ " childKey " : " someValue " ] )
345+ }
346+
347+ func testExtensionsEntryNullWhenNotProvidedInResponse( ) throws {
348+ let query = HumanQuery ( id: " 9999 " )
349+
350+ let response = GraphQLResponse ( operation: query, body: [
351+ " data " : [ " human " : NSNull ( ) ]
352+ ] )
353+
354+ let ( result, _) = try response. parseResult ( ) . await ( )
355+
356+ XCTAssertNil ( result. extensions)
357+ }
358+
359+ func testExtensionsEntryNotNullWhenDataEntryNotProvidedInResponse( ) throws {
360+ let query = HumanQuery ( id: " 9999 " )
361+
362+ let response = GraphQLResponse ( operation: query, body: [
363+ " extensions " : [ : ]
364+ ] )
365+
366+ let ( result, _) = try response. parseResult ( ) . await ( )
367+
368+ XCTAssertNotNil ( result. extensions)
369+ }
370+
317371 // MARK: Mutations
318372
319373 func testCreateReviewForEpisode( ) throws {
0 commit comments