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

not-deep-equal-failure.js 6.4KB

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. + '# not deep equal\n'
  19. + 'not ok 1 should not be equivalent\n'
  20. + ' ---\n'
  21. + ' operator: notDeepEqual\n'
  22. + ' expected: |-\n'
  23. + ' { b: 2 }\n'
  24. + ' actual: |-\n'
  25. + ' { b: 2 }\n'
  26. + ' at: Test.<anonymous> ($TEST/not-deep-equal-failure.js:$LINE:$COL)\n'
  27. + ' stack: |-\n'
  28. + ' Error: should not be equivalent\n'
  29. + ' [... stack stripped ...]\n'
  30. + ' at Test.<anonymous> ($TEST/not-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: 'notDeepEqual',
  41. expected: '{ b: 2 }',
  42. actual: '{ b: 2 }'
  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 not be equivalent',
  52. diag: {
  53. operator: 'notDeepEqual',
  54. expected: '{ b: 2 }',
  55. actual: '{ b: 2 }'
  56. }
  57. });
  58. });
  59. test("not deep equal", function (t) {
  60. t.plan(1);
  61. t.notDeepEqual({b: 2}, {b: 2});
  62. });
  63. });
  64. tap.test('not 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. + '# not deep equal\n'
  75. + 'not ok 1 should not be equivalent\n'
  76. + ' ---\n'
  77. + ' operator: notDeepEqual\n'
  78. + ' expected: |-\n'
  79. + ' { a: { a1: { a2: { a3: { a4: { a5: 1 } } } } } }\n'
  80. + ' actual: |-\n'
  81. + ' { a: { a1: { a2: { a3: { a4: { a5: 1 } } } } } }\n'
  82. + ' at: Test.<anonymous> ($TEST/not-deep-equal-failure.js:$LINE:$COL)\n'
  83. + ' stack: |-\n'
  84. + ' Error: should not be equivalent\n'
  85. + ' [... stack stripped ...]\n'
  86. + ' at Test.<anonymous> ($TEST/not-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: 'notDeepEqual',
  97. expected: '{ a: { a1: { a2: { a3: { a4: { a5: 1 } } } } } }',
  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 not be equivalent',
  108. diag: {
  109. operator: 'notDeepEqual',
  110. expected: '{ a: { a1: { a2: { a3: { a4: { a5: 1 } } } } } }',
  111. actual: '{ a: { a1: { a2: { a3: { a4: { a5: 1 } } } } } }'
  112. }
  113. });
  114. });
  115. test("not deep equal", {objectPrintDepth: 6}, function (t) {
  116. t.plan(1);
  117. t.notDeepEqual({ a: { a1: { a2: { a3: { a4: { a5: 1 } } } } } }, { a: { a1: { a2: { a3: { a4: { a5: 1 } } } } } });
  118. });
  119. });
  120. tap.test('not 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. + '# not deep equal\n'
  131. + 'not ok 1 should not be equivalent\n'
  132. + ' ---\n'
  133. + ' operator: notDeepEqual\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/not-deep-equal-failure.js:$LINE:$COL)\n'
  139. + ' stack: |-\n'
  140. + ' Error: should not be equivalent\n'
  141. + ' [... stack stripped ...]\n'
  142. + ' at Test.<anonymous> ($TEST/not-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: 'notDeepEqual',
  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 not be equivalent',
  164. diag: {
  165. operator: 'notDeepEqual',
  166. expected: '{ a: { a1: { a2: { a3: { a4: [Object] } } } } }',
  167. actual: '{ a: { a1: { a2: { a3: { a4: [Object] } } } } }'
  168. }
  169. });
  170. });
  171. test("not deep equal", function (t) {
  172. t.plan(1);
  173. t.notDeepEqual({ a: { a1: { a2: { a3: { a4: { a5: 1 } } } } } }, { a: { a1: { a2: { a3: { a4: { a5: 1 } } } } } });
  174. });
  175. });