1
0
mirror of https://github.com/thangisme/notes.git synced 2024-11-01 03:27:29 -04:00
notes/node_modules/doiuse/test/stream.js

50 lines
1.1 KiB
JavaScript
Raw Normal View History

2017-03-09 13:16:08 -05:00
var stream = require('../stream')
var through = require('through2')
var test = require('tape')
var expected = [
'css-sel3',
'background-img-opts'
]
var expectedWithIgnore = [
'background-img-opts'
]
test('streaming works', function (t) {
var s = stream({ browsers: 'IE >= 8' })
s.pipe(through.obj(function (usage, enc, next) {
t.equal(usage.feature, expected.shift())
next()
}, function (next) {
next()
t.equal(expected.length, 0)
t.end()
}))
s.end('div:nth-child(2n-1) { background-size: cover; }')
})
test('streaming works with ignore option', function (t) {
var s = stream({ browsers: 'IE >= 8', ignore: ['css-sel3'] })
s.pipe(through.obj(function (usage, enc, next) {
t.equal(usage.feature, expectedWithIgnore.shift())
next()
}, function (next) {
next()
t.equal(expectedWithIgnore.length, 0)
t.end()
}))
s.end('div:nth-child(2n-1) { background-size: cover; }')
})
test('gracefully emit error on bad browsers list', function (t) {
t.plan(1)
stream({ browsers: 'Blargh!' })
.on('error', function (e) {
t.ok(e)
})
})