Skip to content
Myr

fix(client): Fix `parseResponse` not parsing json in react native (#4399)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

* Fix parseResponse not working properly in react native * Run format:fix & lint:fix * add a test ---------

authored by Igor Zhukovin · committed by GitHub · parent 7f4311c · Browse files · 2 files+31 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Trailers

  • Co-authored-by: Yusuke Wada <yusuke@kamawada.com>

Diff stats

2 files+31 added−2 removed

  • tests:+20 added−0 removed
  • other:+11 added−2 removed

2 files+31 added−2 removed

modified:src/client/fetch-result-please.ts+11 added-2 removed
modified:src/client/utils.test.ts+20 added
333 unmodified lines
334 >335 type _verify = Expect<Equal<ResultType, { message: string }>>336 }),337 ])338339 it('should parse json response with _bodyInit when body is undefined', async () => {340 const mockFetch = vi.fn().mockResolvedValue({341 ok: true,342 status: 200,343 headers: new Headers({ 'content-type': 'application/json' }),344 body: undefined,345 _bodyInit: '{"message":"test"}',346 json: async () => ({ message: 'test' }),347 })348349 global.fetch = mockFetch350351 const mockClientResponse = {352 $get: mockFetch,353 }354355 const result = await parseResponse(mockClientResponse.$get())356 expect(result).toEqual({ message: 'test' })357 })358})