dep.js 655 B

12345678910111213141516171819202122232425
  1. var browserify = require('../');
  2. var vm = require('vm');
  3. var test = require('tap').test;
  4. test('dependency events', function (t) {
  5. t.plan(4);
  6. var b = browserify(__dirname + '/entry/main.js');
  7. var deps = [];
  8. b.on('dep', function (row) {
  9. deps.push({ id: row.id, deps: row.deps });
  10. t.equal(typeof row.source, 'string');
  11. });
  12. b.bundle(function (err, src) {
  13. t.deepEqual(deps.sort(cmp), [
  14. { id: 1, deps: { './one': 2, './two': 3 } },
  15. { id: 2, deps: {} },
  16. { id: 3, deps: {} }
  17. ]);
  18. });
  19. function cmp (a, b) {
  20. return a.id < b.id ? -1 : 1;
  21. }
  22. });