Skip to content

Commit

Permalink
testing resolving and bundling shims with depends
Browse files Browse the repository at this point in the history
  • Loading branch information
thlorenz committed Dec 3, 2013
1 parent 5146fda commit f6ebd9e
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 4 deletions.
29 changes: 29 additions & 0 deletions test/bundle-deps.js
@@ -0,0 +1,29 @@
'use strict';
/*jshint asi: true */

var browserify = require('browserify')
, test = require('tap').test
, vm = require('vm')

function bundleNcheck(relPath, t) {
browserify( { ignoreGlobals: true })
.require(require.resolve(relPath))
.bundle(function (err, src) {
if (err) { t.fail(err); return t.end(); }

var ctx = { window: {}, console: console };
ctx.self = ctx.window;
var require_ = vm.runInNewContext(src, ctx);

var main = require_(require.resolve(relPath));

t.deepEqual(main(), { noncjs: { name: 'non-cjs', version: 1.1 } }, 'shims non-cjs, requireing non-cjs-dep ');
t.end()
});
}

test('\nshimming deps with external shim, with depends all exposed'
, bundleNcheck.bind(null, './deps/extshim/main'))

test('\nshimming nodeps with inlined shim, with depends all exposed'
, bundleNcheck.bind(null, './deps/inlineshim/main'))
1 change: 1 addition & 0 deletions test/deps/node_modules/browserify-shim

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 2 additions & 4 deletions test/resolve-shims.js
Expand Up @@ -43,7 +43,6 @@ test('\nno dependencies, inline shims, exposed as non-cjs', function (t) {
test('\nnon-cjs-dep depends on non-cjs, external shim file, all exposed', function (t) {
resolve(require.resolve('./deps/extshim/vendor/non-cjs-dep'), function (err, res) {
if (err) { t.fail(err); return t.end(); }
inspect(res);
t.deepEqual(res
, { exports: 'noncjsdep', depends: { 'non-cjs': 'noncjs' } }
, 'resolves noncjsdep shim correctly'
Expand All @@ -55,11 +54,10 @@ test('\nnon-cjs-dep depends on non-cjs, external shim file, all exposed', functi
test('\nnon-cjs-dep depends on non-cjs, inline shims, all exposed', function (t) {
resolve(require.resolve('./deps/inlineshim/vendor/non-cjs-dep'), function (err, res) {
if (err) { t.fail(err); return t.end(); }
inspect(res);
/*t.deepEqual(res
t.deepEqual(res
, { exports: 'noncjsdep', depends: { 'non-cjs': 'noncjs' } }
, 'resolves noncjsdep shim correctly'
)*/
)
t.end();
});
})

0 comments on commit f6ebd9e

Please sign in to comment.