full_paths.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. var unpack = require('browser-unpack');
  2. var browserify = require('../');
  3. var test = require('tap').test;
  4. var vm = require('vm');
  5. var path = require('path');
  6. var deps = [
  7. path.join(__dirname, '/entry/main.js'),
  8. path.join(__dirname, '/entry/one.js'),
  9. path.join(__dirname, '/entry/two.js')
  10. ];
  11. test('fullPaths enabled', function (t) {
  12. t.plan(3);
  13. var b = browserify({
  14. entries: [ deps[0] ],
  15. fullPaths: true
  16. });
  17. b.bundle(function (err, src) {
  18. unpack(src).forEach(function(dep) {
  19. t.notEqual(deps.indexOf(dep.id), -1, 'full path name for dep.id');
  20. });
  21. });
  22. });
  23. test('fullPaths disabled', function (t) {
  24. t.plan(3);
  25. var b = browserify({
  26. entries: [ deps[0] ],
  27. fullPaths: false
  28. });
  29. b.bundle(function (err, src) {
  30. unpack(src).forEach(function(dep) {
  31. t.equal(deps.indexOf(dep.id), -1, 'full path name no longer available');
  32. });
  33. });
  34. });
  35. test('fullPaths enabled, with custom exposed dependency name', function (t) {
  36. t.plan(1);
  37. var b = browserify({
  38. entries: [__dirname + '/entry/needs_three.js'],
  39. fullPaths: true
  40. });
  41. b.require(__dirname + '/entry/three.js', { expose: 'three' });
  42. b.bundle(function (err, src) {
  43. t.doesNotThrow(function () {
  44. vm.runInNewContext(src, { console: console, t: t });
  45. });
  46. });
  47. });