Skip to content

Commit

Permalink
Add failing test for #77
Browse files Browse the repository at this point in the history
  • Loading branch information
goto-bus-stop committed May 9, 2018
1 parent a810104 commit 1ecf7a4
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
37 changes: 37 additions & 0 deletions test/jquery.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
var test = require('tape');
var vm = require('vm');
var concat = require('concat-stream');

var path = require('path');
var insert = require('../');
var bpack = require('browser-pack');
var mdeps = require('module-deps');

test('$', function (t) {
t.plan(1);

var file = path.join(__dirname, 'jquery', 'main.js');
var deps = mdeps();
var pack = bpack({ raw: true });

deps.pipe(pack);

pack.pipe(concat(function (src) {
var c = {
window: { jQuery: function () { return 20 } }
};
vm.runInNewContext('require=' + src, c);
var x = c.require(file);
t.equal(x, 20);
}));

deps.write({ transform: inserter, global: true });
deps.end(file);
});

function inserter (file) {
return insert(file, {
basedir: __dirname + '/jquery',
vars: { $: function () { return 'window.jQuery' } }
});
}
1 change: 1 addition & 0 deletions test/jquery/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = $()

0 comments on commit 1ecf7a4

Please sign in to comment.