Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
80529 views
1
var test = require('tap').test;
2
var pack = require('../');
3
4
test('raw', function (t) {
5
t.plan(5);
6
7
var p = pack({ raw: true });
8
var src = '';
9
p.on('data', function (buf) { src += buf });
10
p.on('end', function () {
11
var r = Function(['T'], 'return ' + src)(t);
12
t.equal(r('xyz')(5), 555);
13
t.equal(r('xyz')(5), 555);
14
t.throws(function() {
15
r('zzz');
16
}, /Cannot find module 'zzz'/);
17
});
18
19
p.write({
20
id: 'abc',
21
source: 'T.equal(require("./xyz")(3), 333)',
22
entry: true,
23
deps: { './xyz': 'xyz' }
24
});
25
26
p.write({
27
id: 'xyz',
28
source: 'T.ok(true); module.exports=function(n){return n*111}'
29
});
30
31
p.end();
32
});
33
34