@@ -52,12 +52,27 @@ describe('body accessors', () => {
52
52
expect ( { json : 'body' } ) . toStrictEqual ( await testResponse . json )
53
53
} )
54
54
test ( 'rejects on invalid content-type' , async ( ) => {
55
- const mockResponse = new Response ( "<h1>hi</h1>" , { status : 200 , headers : new Headers ( { 'Content-Type' : 'text/plain ' } ) } )
55
+ const mockResponse = new Response ( "<h1>hi</h1>" , { status : 200 , headers : new Headers ( { 'Content-Type' : 'text/json ' } ) } )
56
56
const testResponse = new FetchResponse ( mockResponse )
57
57
58
58
expect ( testResponse . json ) . rejects . toBeInstanceOf ( Error )
59
59
} )
60
60
} )
61
+ describe ( 'application/vnd.api+json' , ( ) => {
62
+ test ( 'works multiple times' , async ( ) => {
63
+ const mockResponse = new Response ( JSON . stringify ( { json : 'body' } ) , { status : 200 , headers : new Headers ( { 'Content-Type' : 'application/vnd.api+json' } ) } )
64
+ const testResponse = new FetchResponse ( mockResponse )
65
+
66
+ expect ( { json : 'body' } ) . toStrictEqual ( await testResponse . json )
67
+ expect ( { json : 'body' } ) . toStrictEqual ( await testResponse . json )
68
+ } )
69
+ test ( 'rejects on invalid content-type' , async ( ) => {
70
+ const mockResponse = new Response ( "<h1>hi</h1>" , { status : 200 , headers : new Headers ( { 'Content-Type' : 'application/plain' } ) } )
71
+ const testResponse = new FetchResponse ( mockResponse )
72
+
73
+ expect ( testResponse . json ) . rejects . toBeInstanceOf ( Error )
74
+ } )
75
+ } )
61
76
describe ( 'turbostream' , ( ) => {
62
77
const mockTurboStreamMessage = `
63
78
<turbo-stream action="append" target="mock_collection"><template>
0 commit comments