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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. var tape = require('../');
  2. var tap = require('tap');
  3. var concat = require('concat-stream');
  4. var tapParser = require('tap-parser');
  5. var common = require('./common');
  6. var getDiag = common.getDiag;
  7. var stripFullStack = common.stripFullStack;
  8. tap.test('deep equal failure', function (assert) {
  9. var test = tape.createHarness({ exit : false });
  10. var stream = test.createStream();
  11. var parser = tapParser();
  12. assert.plan(3);
  13. stream.pipe(parser);
  14. stream.pipe(concat(function (body) {
  15. assert.equal(
  16. stripFullStack(body.toString('utf8')),
  17. 'TAP version 13\n'
  18. + '# deep equal\n'
  19. + 'not ok 1 should be equal\n'
  20. + ' ---\n'
  21. + ' operator: equal\n'
  22. + ' expected: |-\n'
  23. + ' { b: 2 }\n'
  24. + ' actual: |-\n'
  25. + ' { a: 1 }\n'
  26. + ' at: Test.<anonymous> ($TEST/deep-equal-failure.js:$LINE:$COL)\n'
  27. + ' stack: |-\n'
  28. + ' Error: should be equal\n'
  29. + ' [... stack stripped ...]\n'
  30. + ' at Test.<anonymous> ($TEST/deep-equal-failure.js:$LINE:$COL)\n'
  31. + ' [... stack stripped ...]\n'
  32. + ' ...\n'
  33. + '\n'
  34. + '1..1\n'
  35. + '# tests 1\n'
  36. + '# pass 0\n'
  37. + '# fail 1\n'
  38. );
  39. assert.deepEqual(getDiag(body), {
  40. operator: 'equal',
  41. expected: '{ b: 2 }',
  42. actual: '{ a: 1 }'
  43. });
  44. }));
  45. parser.once('assert', function (data) {
  46. delete data.diag.stack;
  47. delete data.diag.at;
  48. assert.deepEqual(data, {
  49. ok: false,
  50. id: 1,
  51. name: 'should be equal',
  52. diag: {
  53. operator: 'equal',
  54. expected: '{ b: 2 }',
  55. actual: '{ a: 1 }'
  56. }
  57. });
  58. });
  59. test("deep equal", function (t) {
  60. t.plan(1);
  61. t.equal({a: 1}, {b: 2});
  62. });
  63. });
  64. tap.test('deep equal failure, depth 6, with option', function (assert) {
  65. var test = tape.createHarness({ exit : false });
  66. var stream = test.createStream();
  67. var parser = tapParser();
  68. assert.plan(3);
  69. stream.pipe(parser);
  70. stream.pipe(concat(function (body) {
  71. assert.equal(
  72. stripFullStack(body.toString('utf8')),
  73. 'TAP version 13\n'
  74. + '# deep equal\n'
  75. + 'not ok 1 should be equal\n'
  76. + ' ---\n'
  77. + ' operator: equal\n'
  78. + ' expected: |-\n'
  79. + ' { a: { a1: { a2: { a3: { a4: { a5: 2 } } } } } }\n'
  80. + ' actual: |-\n'
  81. + ' { a: { a1: { a2: { a3: { a4: { a5: 1 } } } } } }\n'
  82. + ' at: Test.<anonymous> ($TEST/deep-equal-failure.js:$LINE:$COL)\n'
  83. + ' stack: |-\n'
  84. + ' Error: should be equal\n'
  85. + ' [... stack stripped ...]\n'
  86. + ' at Test.<anonymous> ($TEST/deep-equal-failure.js:$LINE:$COL)\n'
  87. + ' [... stack stripped ...]\n'
  88. + ' ...\n'
  89. + '\n'
  90. + '1..1\n'
  91. + '# tests 1\n'
  92. + '# pass 0\n'
  93. + '# fail 1\n'
  94. );
  95. assert.deepEqual(getDiag(body), {
  96. operator: 'equal',
  97. expected: '{ a: { a1: { a2: { a3: { a4: { a5: 2 } } } } } }',
  98. actual: '{ a: { a1: { a2: { a3: { a4: { a5: 1 } } } } } }'
  99. });
  100. }));
  101. parser.once('assert', function (data) {
  102. delete data.diag.stack;
  103. delete data.diag.at;
  104. assert.deepEqual(data, {
  105. ok: false,
  106. id: 1,
  107. name: 'should be equal',
  108. diag: {
  109. operator: 'equal',
  110. expected: '{ a: { a1: { a2: { a3: { a4: { a5: 2 } } } } } }',
  111. actual: '{ a: { a1: { a2: { a3: { a4: { a5: 1 } } } } } }'
  112. }
  113. });
  114. });
  115. test("deep equal", {objectPrintDepth: 6}, function (t) {
  116. t.plan(1);
  117. t.equal({ a: { a1: { a2: { a3: { a4: { a5: 1 } } } } } }, { a: { a1: { a2: { a3: { a4: { a5: 2 } } } } } });
  118. });
  119. });
  120. tap.test('deep equal failure, depth 6, without option', function (assert) {
  121. var test = tape.createHarness({ exit : false });
  122. var stream = test.createStream();
  123. var parser = tapParser();
  124. assert.plan(3);
  125. stream.pipe(parser);
  126. stream.pipe(concat(function (body) {
  127. assert.equal(
  128. stripFullStack(body.toString('utf8')),
  129. 'TAP version 13\n'
  130. + '# deep equal\n'
  131. + 'not ok 1 should be equal\n'
  132. + ' ---\n'
  133. + ' operator: equal\n'
  134. + ' expected: |-\n'
  135. + ' { a: { a1: { a2: { a3: { a4: [Object] } } } } }\n'
  136. + ' actual: |-\n'
  137. + ' { a: { a1: { a2: { a3: { a4: [Object] } } } } }\n'
  138. + ' at: Test.<anonymous> ($TEST/deep-equal-failure.js:$LINE:$COL)\n'
  139. + ' stack: |-\n'
  140. + ' Error: should be equal\n'
  141. + ' [... stack stripped ...]\n'
  142. + ' at Test.<anonymous> ($TEST/deep-equal-failure.js:$LINE:$COL)\n'
  143. + ' [... stack stripped ...]\n'
  144. + ' ...\n'
  145. + '\n'
  146. + '1..1\n'
  147. + '# tests 1\n'
  148. + '# pass 0\n'
  149. + '# fail 1\n'
  150. );
  151. assert.deepEqual(getDiag(body), {
  152. operator: 'equal',
  153. expected: '{ a: { a1: { a2: { a3: { a4: [Object] } } } } }',
  154. actual: '{ a: { a1: { a2: { a3: { a4: [Object] } } } } }'
  155. });
  156. }));
  157. parser.once('assert', function (data) {
  158. delete data.diag.stack;
  159. delete data.diag.at;
  160. assert.deepEqual(data, {
  161. ok: false,
  162. id: 1,
  163. name: 'should be equal',
  164. diag: {
  165. operator: 'equal',
  166. expected: '{ a: { a1: { a2: { a3: { a4: [Object] } } } } }',
  167. actual: '{ a: { a1: { a2: { a3: { a4: [Object] } } } } }'
  168. }
  169. });
  170. });
  171. test("deep equal", function (t) {
  172. t.plan(1);
  173. t.equal({ a: { a1: { a2: { a3: { a4: { a5: 1 } } } } } }, { a: { a1: { a2: { a3: { a4: { a5: 2 } } } } } });
  174. });
  175. });