forked from jamesshore/lets_code_javascript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathraw.js
More file actions
32 lines (27 loc) · 752 Bytes
/
raw.js
File metadata and controls
32 lines (27 loc) · 752 Bytes
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
var test = require('tap').test;
var pack = require('../');
test('raw', function (t) {
t.plan(5);
var p = pack({ raw: true });
var src = '';
p.on('data', function (buf) { src += buf });
p.on('end', function () {
var r = Function(['T'], 'return ' + src)(t);
t.equal(r('xyz')(5), 555);
t.equal(r('xyz')(5), 555);
t.throws(function() {
r('zzz');
}, /Cannot find module 'zzz'/);
});
p.write({
id: 'abc',
source: 'T.equal(require("./xyz")(3), 333)',
entry: true,
deps: { './xyz': 'xyz' }
});
p.write({
id: 'xyz',
source: 'T.ok(true); module.exports=function(n){return n*111}'
});
p.end();
});