mirror of
https://github.com/PR0M3TH3AN/TORCH.git
synced 2026-10-27 16:01:54 +00:00
- Added `test/errors.test.mjs` with comprehensive tests for the `ExitError` class. - Updated `src/errors.mjs` to set `this.name = 'ExitError'` in the constructor for better error reporting. - Verified that all new tests pass and no regressions were introduced to the existing test suite. Co-authored-by: PR0M3TH3AN <[email protected]>
32 lines
897 B
JavaScript
32 lines
897 B
JavaScript
import { describe, it } from 'node:test';
|
|
import assert from 'node:assert';
|
|
import { ExitError } from '../src/errors.mjs';
|
|
|
|
describe('ExitError', () => {
|
|
it('should capture the code and message correctly', () => {
|
|
const code = 1;
|
|
const message = 'Test error message';
|
|
const error = new ExitError(code, message);
|
|
|
|
assert.strictEqual(error.code, code);
|
|
assert.strictEqual(error.message, message);
|
|
});
|
|
|
|
it('should be an instance of Error and ExitError', () => {
|
|
const error = new ExitError(1, 'message');
|
|
|
|
assert.ok(error instanceof Error);
|
|
assert.ok(error instanceof ExitError);
|
|
});
|
|
|
|
it('should have a stack trace', () => {
|
|
const error = new ExitError(1, 'message');
|
|
assert.ok(error.stack);
|
|
});
|
|
|
|
it('should have the correct name', () => {
|
|
const error = new ExitError(1, 'message');
|
|
assert.strictEqual(error.name, 'ExitError');
|
|
});
|
|
});
|