Repositorio del curso CCOM4030 el semestre B91 del proyecto Artesanías con el Instituto de Cultura

comment.js 4.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. var concat = require('concat-stream');
  2. var tap = require('tap');
  3. var tape = require('../');
  4. // Exploratory test to ascertain proper output when no t.comment() call
  5. // is made.
  6. tap.test('no comment', function (assert) {
  7. assert.plan(1);
  8. var verify = function (output) {
  9. assert.equal(output.toString('utf8'), [
  10. 'TAP version 13',
  11. '# no comment',
  12. '',
  13. '1..0',
  14. '# tests 0',
  15. '# pass 0',
  16. '',
  17. '# ok',
  18. ''
  19. ].join('\n'));
  20. };
  21. var test = tape.createHarness();
  22. test.createStream().pipe(concat(verify));
  23. test('no comment', function (t) {
  24. t.end();
  25. });
  26. });
  27. // Exploratory test, can we call t.comment() passing nothing?
  28. tap.test('missing argument', function (assert) {
  29. assert.plan(1);
  30. var test = tape.createHarness();
  31. test.createStream();
  32. test('missing argument', function (t) {
  33. try {
  34. t.comment();
  35. t.end();
  36. } catch (err) {
  37. assert.equal(err.constructor, TypeError);
  38. } finally {
  39. assert.end();
  40. }
  41. });
  42. });
  43. // Exploratory test, can we call t.comment() passing nothing?
  44. tap.test('null argument', function (assert) {
  45. assert.plan(1);
  46. var test = tape.createHarness();
  47. test.createStream();
  48. test('null argument', function (t) {
  49. try {
  50. t.comment(null);
  51. t.end();
  52. } catch (err) {
  53. assert.equal(err.constructor, TypeError);
  54. } finally {
  55. assert.end();
  56. }
  57. });
  58. });
  59. // Exploratory test, how is whitespace treated?
  60. tap.test('whitespace', function (assert) {
  61. assert.plan(1);
  62. var verify = function (output) {
  63. assert.equal(output.toString('utf8'), [
  64. 'TAP version 13',
  65. '# whitespace',
  66. '# ',
  67. '# a',
  68. '# a',
  69. '# a',
  70. '',
  71. '1..0',
  72. '# tests 0',
  73. '# pass 0',
  74. '',
  75. '# ok',
  76. ''
  77. ].join('\n'));
  78. };
  79. var test = tape.createHarness();
  80. test.createStream().pipe(concat(verify));
  81. test('whitespace', function (t) {
  82. t.comment(' ');
  83. t.comment(' a');
  84. t.comment('a ');
  85. t.comment(' a ');
  86. t.end();
  87. });
  88. });
  89. // Exploratory test, how about passing types other than strings?
  90. tap.test('non-string types', function (assert) {
  91. assert.plan(1);
  92. var verify = function (output) {
  93. assert.equal(output.toString('utf8'), [
  94. 'TAP version 13',
  95. '# non-string types',
  96. '# true',
  97. '# false',
  98. '# 42',
  99. '# 6.66',
  100. '# [object Object]',
  101. '# [object Object]',
  102. '# [object Object]',
  103. '# function ConstructorFunction() {}',
  104. '',
  105. '1..0',
  106. '# tests 0',
  107. '# pass 0',
  108. '',
  109. '# ok',
  110. ''
  111. ].join('\n'));
  112. };
  113. var test = tape.createHarness();
  114. test.createStream().pipe(concat(verify));
  115. test('non-string types', function (t) {
  116. t.comment(true);
  117. t.comment(false);
  118. t.comment(42);
  119. t.comment(6.66);
  120. t.comment({});
  121. t.comment({"answer": 42});
  122. function ConstructorFunction() {}
  123. t.comment(new ConstructorFunction());
  124. t.comment(ConstructorFunction);
  125. t.end();
  126. });
  127. });
  128. tap.test('multiline string', function (assert) {
  129. assert.plan(1);
  130. var verify = function (output) {
  131. assert.equal(output.toString('utf8'), [
  132. 'TAP version 13',
  133. '# multiline strings',
  134. '# a',
  135. '# b',
  136. '# c',
  137. '# d',
  138. '',
  139. '1..0',
  140. '# tests 0',
  141. '# pass 0',
  142. '',
  143. '# ok',
  144. ''
  145. ].join('\n'));
  146. };
  147. var test = tape.createHarness();
  148. test.createStream().pipe(concat(verify));
  149. test('multiline strings', function (t) {
  150. t.comment([
  151. 'a',
  152. 'b',
  153. ].join('\n'));
  154. t.comment([
  155. 'c',
  156. 'd',
  157. ].join('\r\n'));
  158. t.end();
  159. });
  160. });