browser_field_resolve.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. var browserify = require('../');
  2. var vm = require('vm');
  3. var test = require('tap').test;
  4. test('browser field resolve (a)', function (t) {
  5. t.plan(2);
  6. var b = browserify(__dirname + '/browser_field_resolve/a/main.js');
  7. b.bundle(function (err, src) {
  8. t.ifError(err);
  9. vm.runInNewContext(src, { console: { log: log } });
  10. function log (x) { t.equal(x, 555) }
  11. });
  12. });
  13. test('browser field resolve (b)', function (t) {
  14. t.plan(2);
  15. var b = browserify(__dirname + '/browser_field_resolve/b/main.js');
  16. b.bundle(function (err, src) {
  17. t.ifError(err);
  18. vm.runInNewContext(src, { console: { log: log } });
  19. function log (x) { t.equal(x, 444) }
  20. });
  21. });
  22. test('browser field resolve (c)', function (t) {
  23. t.plan(2);
  24. var b = browserify(__dirname + '/browser_field_resolve/c/main.js');
  25. b.bundle(function (err, src) {
  26. t.ifError(err);
  27. vm.runInNewContext(src, { console: { log: log } });
  28. function log (x) { t.equal(x, 333) }
  29. });
  30. });
  31. test('browser field resolve (d)', function (t) {
  32. t.plan(2);
  33. var b = browserify(__dirname + '/browser_field_resolve/d/main.js');
  34. b.bundle(function (err, src) {
  35. t.ifError(err);
  36. vm.runInNewContext(src, { console: { log: log } });
  37. function log (x) { t.equal(x, 222) }
  38. });
  39. });
  40. test('browser field resolve (e)', function (t) {
  41. t.plan(2);
  42. var b = browserify(__dirname + '/browser_field_resolve/e/main.js');
  43. b.bundle(function (err, src) {
  44. t.ifError(err);
  45. vm.runInNewContext(src, { console: { log: log } });
  46. function log (x) { t.equal(x, 111) }
  47. });
  48. });
  49. test('browser field resolve (f)', function (t) {
  50. t.plan(2);
  51. var b = browserify(__dirname + '/browser_field_resolve/f/main.js');
  52. b.bundle(function (err, src) {
  53. t.ifError(err);
  54. vm.runInNewContext(src, { console: { log: log } });
  55. function log (x) { t.equal(x, 999) }
  56. });
  57. });
  58. test('browser field resolve (g)', function (t) {
  59. t.plan(2);
  60. var b = browserify(__dirname + '/browser_field_resolve/g/main.js');
  61. b.bundle(function (err, src) {
  62. t.ifError(err);
  63. vm.runInNewContext(src, { console: { log: log } });
  64. function log (x) { t.deepEqual(x, {}) }
  65. });
  66. });
  67. test('browser field resolve (h)', function (t) {
  68. t.plan(2);
  69. var b = browserify(__dirname + '/browser_field_resolve/h/main.js');
  70. b.bundle(function (err, src) {
  71. t.ifError(err);
  72. vm.runInNewContext(src, { console: { log: log } });
  73. function log (x) { t.deepEqual(x, {}) }
  74. });
  75. });
  76. test('browser field resolve (i)', function (t) {
  77. t.plan(2);
  78. var b = browserify(__dirname + '/browser_field_resolve/i/main.js');
  79. b.bundle(function (err, src) {
  80. t.ifError(err);
  81. vm.runInNewContext(src, { console: { log: log } });
  82. function log (x) { t.deepEqual(x, 5000) }
  83. });
  84. });
  85. test('browser field resolve (j)', function (t) {
  86. t.plan(2);
  87. var b = browserify(__dirname + '/browser_field_resolve/j/main.js');
  88. b.bundle(function (err, src) {
  89. t.ifError(err);
  90. vm.runInNewContext(src, { console: { log: log } });
  91. function log (x) { t.deepEqual(x, 5000) }
  92. });
  93. });
  94. test('browser field resolve (k)', function (t) {
  95. t.plan(2);
  96. var b = browserify(__dirname + '/browser_field_resolve/k/main.js');
  97. b.bundle(function (err, src) {
  98. t.ifError(err);
  99. vm.runInNewContext(src, { console: { log: log } });
  100. function log (x) { t.deepEqual(x, 3000) }
  101. });
  102. });
  103. test('browser field resolve (l)', function (t) {
  104. t.plan(2);
  105. var b = browserify(__dirname + '/browser_field_resolve/l/main.js');
  106. b.bundle(function (err, src) {
  107. t.ifError(err);
  108. vm.runInNewContext(src, { console: { log: log } });
  109. function log (x) { t.deepEqual(x, 3000) }
  110. });
  111. });