-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a810104
commit 1ecf7a4
Showing
2 changed files
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' } } | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = $() |