summaryrefslogtreecommitdiff
path: root/deps/npm/node_modules/npm-registry-client/node_modules/concat-stream/test/infer.js
blob: 91ab933f458098f6f815e31bea874146ac4dd4c8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
var concat = require('../')
var test = require('tape')

test('type inference works as expected', function(t) {
  var stream = concat()
  t.equal(stream.inferEncoding(['hello']), 'array', 'array')
  t.equal(stream.inferEncoding(new Buffer('hello')), 'buffer', 'buffer')
  t.equal(stream.inferEncoding(undefined), 'buffer', 'buffer')
  t.equal(stream.inferEncoding(new Uint8Array(1)), 'uint8array', 'uint8array')
  t.equal(stream.inferEncoding('hello'), 'string', 'string')
  t.equal(stream.inferEncoding(''), 'string', 'string')
  t.equal(stream.inferEncoding({hello: "world"}), 'object', 'object')
  t.equal(stream.inferEncoding(1), 'buffer', 'buffer')
  t.end()
})