You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
typesetting/pitfall/pdfkit/node_modules/browser-pack/test/this.js

25 lines
535 B
JavaScript

/**
* In node.js `this` on the module root is the same as `exports`. Browser-pack
* should act like it too.
**/
var test = require('tape');
var pack = require('../');
test('this', function (t) {
t.plan(1);
var p = pack();
var src = '';
p.on('data', function (buf) { src += buf; });
p.on('end', function () {
var r = Function([], 'return ' + src)();
t.deepEqual(r("abc"), { foo: "bar" });
});
p.end(JSON.stringify([{
id: 'abc',
source: 'this.foo = "bar"'
}]));
});