Repository: honojs/hono
File: src/utils/body.test.ts (TypeScript)

Code before:
    })
    const data = new FormData()
    data.append('file', file1)
    data.append('file', file2)

    const req = createRequest(FORM_URL, 'POST', data)

    const result = await parseBody(req, { all: true })
    expect(result).toMatchObject({
      file: [
        { name: 'file1', type: 'application/octet-stream' },
        { name: 'file2', type: 'application/octet-stream' },
      ],
    })
  })

  it('should parse multiple values if key ends with `[]`', async () => {
    const data = new FormData()
    data.append('file[]', 'aaa')
    data.append('file[]', 'bbb')
    data.append('message', 'hello')

    const req = createRequest(FORM_URL, 'POST', data)

    expect(await parseBody(req, { all: true })).toEqual({
      file: ['aaa', 'bbb'],
      message: 'hello',
    })
  })

  it('should return blank object if body is JSON', async () => {
    const payload = { message: 'hello hono' }

    const req = createRequest('http://localhost/json', 'POST', JSON.stringify(payload), {
      'Content-Type': 'application/json',
    })

    expect(await parseBody(req)).toEqual({})
  })

  describe('Return type', () => {
    let req: Request
    beforeEach(() => {
      req = createRequest(FORM_URL, 'POST', new FormData())
    })

    it('without options', async () => {
      expectTypeOf((await parseBody(req))['key']).toEqualTypeOf<string | File>()
    })

    it('{all: true}', async () => {

Review comment (bug):
I think this test is wrong. We have to test the case where the value is single.

In my opinion, we should not strip `[]` because it prevents the introduction of breaking changes. So the ideal test is as follows:

```ts
it('should parse single value as array if the key has []', async () => {
  const data = new FormData()
  data.append('foo[]', 'bar')
  const req = createRequest(FORM_URL, 'POST', data)
  expect(await parseBody(req, { all: true })).toEqual({
    'foo[]': ['bar'],
  })
})
```

@sor4chi What do you think of this?

Code after:
    })
    const data = new FormData()
    data.append('file', file1)
    data.append('file', file2)

    const req = createRequest(FORM_URL, 'POST', data)

    const result = await parseBody(req, { all: true })
    expect(result).toMatchObject({
      file: [
        { name: 'file1', type: 'application/octet-stream' },
        { name: 'file2', type: 'application/octet-stream' },
      ],
    })
  })

  it('should parse multiple values if key ends with `[]`', async () => {
    const data = new FormData()
    data.append('file[]', 'aaa')
    data.append('file[]', 'bbb')
    data.append('message', 'hello')

    const req = createRequest(FORM_URL, 'POST', data)

    expect(await parseBody(req, { all: true })).toEqual({
      'file[]': ['aaa', 'bbb'],
      message: 'hello',
    })
  })

  it('should parse single value as array if the key has `[]`', async () => {
    const data = new FormData()
    data.append('foo[]', 'bar')
    const req = createRequest(FORM_URL, 'POST', data)

    expect(await parseBody(req, { all: true })).toEqual({
      'foo[]': ['bar'],
    })
  })

  it('should return blank object if body is JSON', async () => {
    const payload = { message: 'hello hono' }

    const req = createRequest('http://localhost/json', 'POST', JSON.stringify(payload), {
      'Content-Type': 'application/json',
    })

    expect(await parseBody(req)).toEqual({})
  })

  describe('Return type', () => {