full_paths.js
1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
var unpack = require('browser-unpack');
var browserify = require('../');
var test = require('tap').test;
var vm = require('vm');
var path = require('path');
var deps = [
path.join(__dirname, '/entry/main.js'),
path.join(__dirname, '/entry/one.js'),
path.join(__dirname, '/entry/two.js')
];
test('fullPaths enabled', function (t) {
t.plan(3);
var b = browserify({
entries: [ deps[0] ],
fullPaths: true
});
b.bundle(function (err, src) {
unpack(src).forEach(function(dep) {
t.notEqual(deps.indexOf(dep.id), -1, 'full path name for dep.id');
});
});
});
test('fullPaths disabled', function (t) {
t.plan(3);
var b = browserify({
entries: [ deps[0] ],
fullPaths: false
});
b.bundle(function (err, src) {
unpack(src).forEach(function(dep) {
t.equal(deps.indexOf(dep.id), -1, 'full path name no longer available');
});
});
});
test('fullPaths enabled, with custom exposed dependency name', function (t) {
t.plan(1);
var b = browserify({
entries: [__dirname + '/entry/needs_three.js'],
fullPaths: true
});
b.require(__dirname + '/entry/three.js', { expose: 'three' });
b.bundle(function (err, src) {
t.doesNotThrow(function () {
vm.runInNewContext(src, { console: console, t: t });
});
});
});