summaryrefslogtreecommitdiffstats
path: root/test/readable.test.js
blob: 3f4f7939f94b240bad72a5e4f405172d152a2a23 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
'use strict'

const { test } = require('tap')
const Readable = require('../lib/api/readable')

test('avoid body reordering', async function (t) {
  function resume () {
  }
  function abort () {
  }
  const r = new Readable({ resume, abort })

  r.push(Buffer.from('hello'))

  process.nextTick(() => {
    r.push(Buffer.from('world'))
    r.push(null)
  })

  const text = await r.text()

  t.equal(text, 'helloworld')
})