order.js 763 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. var test = require('tap').test;
  2. var pack = require('../');
  3. test('raw', function (t) {
  4. t.plan(1);
  5. var p = pack({ raw: true });
  6. var src = '';
  7. p.on('data', function (buf) { src += buf });
  8. p.on('end', function () {
  9. var order = [];
  10. var r = Function(['order'], 'return ' + src)(order);
  11. t.same(order, [ 'abc', 'def', 'hij' ]);
  12. });
  13. p.write({
  14. id: 'def',
  15. order: 1,
  16. entry: true,
  17. source: 'order.push("def")'
  18. });
  19. p.write({
  20. id: 'hij',
  21. entry: true,
  22. order: 2,
  23. source: 'order.push("hij")'
  24. });
  25. p.write({
  26. id: 'abc',
  27. entry: true,
  28. order: 0,
  29. source: 'order.push("abc")'
  30. });
  31. p.end();
  32. });