-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(models):
ERR_ILLEGAL_CONSTRUCTOR
Signed-off-by: Lexus Drumgold <unicornware@flexdevelopment.llc>
- Loading branch information
1 parent
567b160
commit 94d0441
Showing
3 changed files
with
62 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/** | ||
* @file Unit Tests - ERR_ILLEGAL_CONSTRUCTOR | ||
* @module errnode/models/tests/unit/ERR_ILLEGAL_CONSTRUCTOR | ||
*/ | ||
|
||
import { ErrorCode } from '#src/enums' | ||
import type { NodeError } from '#src/types' | ||
import TestSubject from '../err-illegal-constructor' | ||
|
||
describe('unit:models/ERR_ILLEGAL_CONSTRUCTOR', () => { | ||
let result: NodeError<TypeError> | ||
|
||
beforeEach(() => { | ||
result = new TestSubject() | ||
}) | ||
|
||
it('should return TypeError instance', () => { | ||
expect(result).to.have.property('name').equal('TypeError') | ||
expect(result).to.be.instanceof(TypeError) | ||
}) | ||
|
||
it('should set error code', () => { | ||
expect(result) | ||
.to.have.property('code') | ||
.equal(ErrorCode.ERR_ILLEGAL_CONSTRUCTOR) | ||
}) | ||
|
||
it('should set error message', () => { | ||
expect(result).to.have.property('message').equal('Illegal constructor') | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/** | ||
* @file Error Models - ERR_ILLEGAL_CONSTRUCTOR | ||
* @module errnode/models/ERR_ILLEGAL_CONSTRUCTOR | ||
* @see https://github.com/nodejs/node/blob/v19.3.0/lib/internal/errors.js#L1163 | ||
*/ | ||
|
||
import { ErrorCode } from '#src/enums' | ||
import type { NodeError, NodeErrorConstructor } from '#src/types' | ||
import { createNodeError } from '#src/utils' | ||
|
||
/** | ||
* `ERR_ILLEGAL_CONSTRUCTOR` model. | ||
* | ||
* Thrown when an attempt is made to construct an object using a non-public | ||
* constructor. | ||
* | ||
* @see https://nodejs.org/api/errors.html#err_illegal_constructor | ||
* | ||
* @class | ||
* | ||
* @return {NodeError<TypeError>} `TypeError` instance | ||
*/ | ||
const ERR_ILLEGAL_CONSTRUCTOR: NodeErrorConstructor<TypeErrorConstructor, []> = | ||
createNodeError( | ||
ErrorCode.ERR_ILLEGAL_CONSTRUCTOR, | ||
TypeError, | ||
'Illegal constructor' | ||
) | ||
|
||
export default ERR_ILLEGAL_CONSTRUCTOR |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters