UNPKG

759 BJavaScriptView Raw
1var test = require('tap').test;
2var browserify = require('browserify');
3var path = require('path');
4
5test('scope', function (t) {
6 t.plan(4);
7
8 var b = browserify({ node: true });
9 b.add(__dirname + '/files/scope');
10 b.transform(path.dirname(__dirname));
11
12 b.bundle(function (err, src) {
13 if (err) t.fail(err);
14 t.pass('build success');
15 src = src.toString();
16 t.ok(src.indexOf("require('fs')") !== -1, 'kept the require call');
17 var sentinel = new Buffer('SCOPE_SENTINEL\n', 'utf8').toString('base64')
18 var i = src.indexOf(sentinel);
19 t.ok(i !== -1, 'read the file');
20 i = src.indexOf(sentinel, i + 10);
21 t.ok(i !== -1, 'did the require("fs").readFileSync');
22 });
23
24});