1 | var stream = require('../stream')
|
2 | var through = require('through2')
|
3 |
|
4 | var test = require('tape')
|
5 |
|
6 | var expected = [
|
7 | 'css-sel3',
|
8 | 'background-img-opts'
|
9 | ]
|
10 |
|
11 | var expectedWithIgnore = [
|
12 | 'background-img-opts'
|
13 | ]
|
14 |
|
15 | test('streaming works', function (t) {
|
16 | var s = stream({ browsers: 'IE >= 8' })
|
17 | s.pipe(through.obj(function (usage, enc, next) {
|
18 | t.equal(usage.feature, expected.shift())
|
19 | next()
|
20 | }, function (next) {
|
21 | next()
|
22 | t.equal(expected.length, 0)
|
23 | t.end()
|
24 | }))
|
25 |
|
26 | s.end('div:nth-child(2n-1) { background-size: cover; }')
|
27 | })
|
28 |
|
29 | test('streaming works with ignore option', function (t) {
|
30 | var s = stream({ browsers: 'IE >= 8', ignore: ['css-sel3'] })
|
31 | s.pipe(through.obj(function (usage, enc, next) {
|
32 | t.equal(usage.feature, expectedWithIgnore.shift())
|
33 | next()
|
34 | }, function (next) {
|
35 | next()
|
36 | t.equal(expectedWithIgnore.length, 0)
|
37 | t.end()
|
38 | }))
|
39 |
|
40 | s.end('div:nth-child(2n-1) { background-size: cover; }')
|
41 | })
|
42 |
|
43 | test('gracefully emit error on bad browsers list', function (t) {
|
44 | t.plan(1)
|
45 | stream({ browsers: 'Blargh!' })
|
46 | .on('error', function (e) {
|
47 | t.ok(e)
|
48 | })
|
49 | })
|