| 1 |
var concat = require('concat-stream'); |
| 2 |
var from = require('from2-string'); |
| 3 |
var staticModule = require('../'); |
| 4 |
var test = require('tape'); |
| 5 |
|
| 6 |
test('limit parsing to files including a target module', function (t) { |
| 7 |
var passInput = 'THIS WILL NOT PARSE'; |
| 8 |
var failInput = passInput + '; require("fs")'; |
| 9 |
|
| 10 |
t.plan(2); |
| 11 |
|
| 12 |
from(passInput) |
| 13 |
.pipe(staticModule({ fs: require('fs') })) |
| 14 |
.pipe(concat(function (passOutput) { |
| 15 |
t.equal(passInput, String(passOutput), 'does not parse'); |
| 16 |
})); |
| 17 |
|
| 18 |
from(failInput) |
| 19 |
.pipe(staticModule({ fs: require('fs') })) |
| 20 |
.once('error', function () { |
| 21 |
t.pass('parses if module is included'); |
| 22 |
}); |
| 23 |
}); |