1 | var test = require('tape');
|
2 | var concat = require('concat-stream');
|
3 | var staticModule = require('../');
|
4 | var fs = require('fs');
|
5 | var path = require('path');
|
6 |
|
7 | test('nested object', function (t) {
|
8 | t.plan(3);
|
9 |
|
10 | var expected = [ 12, 555 ];
|
11 | var sm = staticModule({
|
12 | beep: {
|
13 | x: { y: { z: 4 } },
|
14 | f: { g: { h: function (n) { return n * 111 } } }
|
15 | }
|
16 | });
|
17 | readStream('source.js').pipe(sm).pipe(concat(function (body) {
|
18 | Function(['console'],body)({ log: log });
|
19 | t.equal(
|
20 | body.toString('utf8'),
|
21 | '\nconsole.log(4 * 3);\nconsole.log(555);\n'
|
22 | );
|
23 | function log (msg) { t.equal(msg, expected.shift()) }
|
24 | }));
|
25 | });
|
26 |
|
27 | function readStream (file) {
|
28 | return fs.createReadStream(path.join(__dirname, 'nested', file));
|
29 | }
|