HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //home/arjun/projects/buyercall/node_modules/browser-pack/test/this.js
/**
 * In node.js `this` on the module root is the same as `exports`. Browser-pack
 * should act like it too.
 **/
var test = require('tap').test;
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"'
    }]));

});