980e9d4569
Mirror / push (push) Has been cancelled
Test / lint (pull_request) Successful in 22s
Test / test (18) (pull_request) Successful in 32s
Test / test (20) (pull_request) Successful in 29s
Test / test (22) (pull_request) Successful in 32s
Test / test (24) (pull_request) Successful in 29s
Test / test (26) (pull_request) Successful in 36s
18 lines
645 B
TypeScript
18 lines
645 B
TypeScript
import assert from 'node:assert/strict';
|
|
import test from 'node:test';
|
|
import { errorFrom } from '../src/result.ts';
|
|
|
|
test('carries an Error through and describes anything else, including what String() refuses', () => {
|
|
const original = new Error('the original');
|
|
const undescribable: unknown = Object.create(null);
|
|
|
|
assert.equal(errorFrom(original), original);
|
|
assert.equal(errorFrom('a string').message, 'a string');
|
|
assert.equal(errorFrom(null).message, 'null');
|
|
assert.equal(errorFrom(undefined).message, 'undefined');
|
|
assert.equal(
|
|
errorFrom(undescribable).message,
|
|
'A thrown value that cannot be converted to a string',
|
|
);
|
|
});
|