nested-sync-noplan-noend.js 848 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. 'use strict';
  2. var tape = require('../');
  3. var tap = require('tap');
  4. var concat = require('concat-stream');
  5. tap.test('nested sync test without plan or end', function (tt) {
  6. tt.plan(1);
  7. var test = tape.createHarness();
  8. var tc = function (rows) {
  9. tt.same(rows.toString('utf8'), [
  10. 'TAP version 13',
  11. '# nested without plan or end',
  12. '# first',
  13. 'ok 1 should be truthy',
  14. '# second',
  15. 'ok 2 should be truthy',
  16. '',
  17. '1..2',
  18. '# tests 2',
  19. '# pass 2',
  20. '',
  21. '# ok'
  22. ].join('\n') + '\n');
  23. };
  24. test.createStream().pipe(concat(tc));
  25. test('nested without plan or end', function (t) {
  26. t.test('first', function (q) {
  27. setTimeout(function first() {
  28. q.ok(true);
  29. q.end();
  30. }, 10);
  31. });
  32. t.test('second', function (q) {
  33. setTimeout(function second() {
  34. q.ok(true);
  35. q.end();
  36. }, 10);
  37. });
  38. });
  39. });