You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.spec.js 1.1KB

12345678910111213141516171819202122232425
  1. "use strict";
  2. var test = require('blue-tape');
  3. var makeErrorCause = require('./index');
  4. test('make error cause', function (t) {
  5. var TestError = makeErrorCause('TestError');
  6. var SubTestError = makeErrorCause('SubTestError', TestError);
  7. t.test('render the cause', function (t) {
  8. var cause = new Error('boom!');
  9. var error = new TestError('something bad', cause);
  10. var again = new SubTestError('more bad', error);
  11. t.equal(error.cause, cause);
  12. t.equal(error.toString(), 'TestError: something bad\nCaused by: Error: boom!');
  13. t.ok(error instanceof Error);
  14. t.ok(error instanceof makeErrorCause.BaseError);
  15. t.ok(error instanceof TestError);
  16. t.equal(again.cause, error);
  17. t.equal(again.toString(), 'SubTestError: more bad\nCaused by: TestError: something bad\nCaused by: Error: boom!');
  18. t.ok(again instanceof Error);
  19. t.ok(again instanceof makeErrorCause.BaseError);
  20. t.ok(again instanceof TestError);
  21. t.ok(again instanceof SubTestError);
  22. t.end();
  23. });
  24. });
  25. //# sourceMappingURL=index.spec.js.map