Repositorio del curso CCOM4030 el semestre B91 del proyecto kilometro0

require.js 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. var tap = require('tap');
  2. var spawn = require('child_process').spawn;
  3. var concat = require('concat-stream');
  4. tap.test('requiring a single module', function (t) {
  5. t.plan(2);
  6. var tc = function (rows) {
  7. t.same(rows.toString('utf8'), [
  8. 'TAP version 13',
  9. '# module-a',
  10. 'ok 1 loaded module a',
  11. '# test-a',
  12. 'ok 2 module-a loaded in same context',
  13. 'ok 3 test ran after module-a was loaded',
  14. '',
  15. '1..3',
  16. '# tests 3',
  17. '# pass 3',
  18. '',
  19. '# ok'
  20. ].join('\n') + '\n\n');
  21. };
  22. var ps = tape('-r ./require/a require/test-a.js');
  23. ps.stdout.pipe(concat(tc));
  24. ps.on('exit', function (code) {
  25. t.equal(code, 0);
  26. });
  27. });
  28. tap.test('requiring multiple modules', function (t) {
  29. t.plan(2);
  30. var tc = function (rows) {
  31. t.same(rows.toString('utf8'), [
  32. 'TAP version 13',
  33. '# module-a',
  34. 'ok 1 loaded module a',
  35. '# module-b',
  36. 'ok 2 loaded module b',
  37. '# test-a',
  38. 'ok 3 module-a loaded in same context',
  39. 'ok 4 test ran after module-a was loaded',
  40. '# test-b',
  41. 'ok 5 module-b loaded in same context',
  42. 'ok 6 test ran after module-b was loaded',
  43. '',
  44. '1..6',
  45. '# tests 6',
  46. '# pass 6',
  47. '',
  48. '# ok'
  49. ].join('\n') + '\n\n');
  50. };
  51. var ps = tape('-r ./require/a -r ./require/b require/test-a.js require/test-b.js');
  52. ps.stdout.pipe(concat(tc));
  53. ps.on('exit', function (code) {
  54. t.equal(code, 0);
  55. });
  56. });
  57. function tape(args) {
  58. var proc = require('child_process');
  59. var bin = __dirname + '/../bin/tape';
  60. return proc.spawn('node', [bin].concat(args.split(' ')), { cwd: __dirname });
  61. }