File tree Expand file tree Collapse file tree 3 files changed +68
-0
lines changed Expand file tree Collapse file tree 3 files changed +68
-0
lines changed Original file line number Diff line number Diff line change
1
+ /**
2
+ * @file Unit Tests - ERR_UNKNOWN_ENCODING
3
+ * @module errnode/models/tests/unit/ERR_UNKNOWN_ENCODING
4
+ */
5
+
6
+ import { ErrorCode } from '#src/enums'
7
+ import type { NodeError } from '#src/types'
8
+ import TestSubject from '../err-unknown-encoding'
9
+
10
+ describe ( 'unit:models/ERR_UNKNOWN_ENCODING' , ( ) => {
11
+ let encoding : string
12
+ let result : NodeError < TypeError >
13
+
14
+ beforeEach ( ( ) => {
15
+ encoding = 'buffer'
16
+ result = new TestSubject ( encoding )
17
+ } )
18
+
19
+ it ( 'should return TypeError instance' , ( ) => {
20
+ expect ( result ) . to . have . property ( 'name' ) . equal ( 'TypeError' )
21
+ expect ( result ) . to . be . instanceof ( TypeError )
22
+ } )
23
+
24
+ it ( 'should set error code' , ( ) => {
25
+ expect ( result )
26
+ . to . have . property ( 'code' )
27
+ . equal ( ErrorCode . ERR_UNKNOWN_ENCODING )
28
+ } )
29
+
30
+ it ( 'should set error message' , ( ) => {
31
+ expect ( result )
32
+ . to . have . property ( 'message' )
33
+ . equal ( `Unknown encoding: ${ encoding } ` )
34
+ } )
35
+ } )
Original file line number Diff line number Diff line change
1
+ /**
2
+ * @file Error Models - ERR_UNKNOWN_ENCODING
3
+ * @module errnode/models/ERR_UNKNOWN_ENCODING
4
+ * @see https://github.com/nodejs/node/blob/v19.3.0/lib/internal/errors.js#L1685
5
+ */
6
+
7
+ import { ErrorCode } from '#src/enums'
8
+ import type { NodeError , NodeErrorConstructor } from '#src/types'
9
+ import { createNodeError } from '#src/utils'
10
+
11
+ /**
12
+ * `ERR_UNKNOWN_ENCODING` model.
13
+ *
14
+ * Thrown when an invalid or unknown encoding option is passed to an API.
15
+ *
16
+ * @see https://nodejs.org/api/errors.html#err_unknown_encoding
17
+ *
18
+ * @class
19
+ *
20
+ * @param {string } encoding - Invalid or unknown encoding
21
+ * @return {NodeError<TypeError> } `TypeError` instance
22
+ */
23
+ const ERR_UNKNOWN_ENCODING : NodeErrorConstructor <
24
+ TypeErrorConstructor ,
25
+ [ string ]
26
+ > = createNodeError (
27
+ ErrorCode . ERR_UNKNOWN_ENCODING ,
28
+ TypeError ,
29
+ 'Unknown encoding: %s'
30
+ )
31
+
32
+ export default ERR_UNKNOWN_ENCODING
Original file line number Diff line number Diff line change @@ -16,3 +16,4 @@ export { default as ERR_METHOD_NOT_IMPLEMENTED } from './err-method-not-implemen
16
16
export { default as ERR_MISSING_OPTION } from './err-missing-option'
17
17
export { default as ERR_NETWORK_IMPORT_DISALLOWED } from './err-network-import-disallowed'
18
18
export { default as ERR_OPERATION_FAILED } from './err-operation-failed'
19
+ export { default as ERR_UNKNOWN_ENCODING } from './err-unknown-encoding'
You can’t perform that action at this time.
0 commit comments