File tree Expand file tree Collapse file tree 3 files changed +74
-0
lines changed Expand file tree Collapse file tree 3 files changed +74
-0
lines changed Original file line number Diff line number Diff line change
1
+ /**
2
+ * @file Unit Tests - ERR_INCOMPATIBLE_OPTION_PAIR
3
+ * @module errnode/models/tests/unit/ERR_INCOMPATIBLE_OPTION_PAIR
4
+ */
5
+
6
+ import { ErrorCode } from '#src/enums'
7
+ import type { NodeError } from '#src/types'
8
+ import TestSubject from '../err-incompatible-option-pair'
9
+
10
+ describe ( 'unit:models/ERR_INCOMPATIBLE_OPTION_PAIR' , ( ) => {
11
+ let option1 : string
12
+ let option2 : string
13
+ let result : NodeError < TypeError >
14
+
15
+ beforeEach ( ( ) => {
16
+ option1 = 'options.inspectOptions.color'
17
+ option2 = 'colorMode'
18
+ result = new TestSubject ( option1 , option2 )
19
+ } )
20
+
21
+ it ( 'should return TypeError instance' , ( ) => {
22
+ expect ( result ) . to . have . property ( 'name' ) . equal ( 'TypeError' )
23
+ expect ( result ) . to . be . instanceof ( TypeError )
24
+ } )
25
+
26
+ it ( 'should set error code' , ( ) => {
27
+ expect ( result )
28
+ . to . have . property ( 'code' )
29
+ . equal ( ErrorCode . ERR_INCOMPATIBLE_OPTION_PAIR )
30
+ } )
31
+
32
+ it ( 'should set error message' , ( ) => {
33
+ // Arrange
34
+ const expected : string = `Option '${ option1 } ' cannot be used in combination with option '${ option2 } '`
35
+
36
+ // Expect
37
+ expect ( result ) . to . have . property ( 'message' ) . equal ( expected )
38
+ } )
39
+ } )
Original file line number Diff line number Diff line change
1
+ /**
2
+ * @file Error Models - ERR_INCOMPATIBLE_OPTION_PAIR
3
+ * @module errnode/models/ERR_INCOMPATIBLE_OPTION_PAIR
4
+ * @see https://github.com/nodejs/node/blob/v19.3.0/lib/internal/errors.js#L1170-L1171
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_INCOMPATIBLE_OPTION_PAIR` model.
13
+ *
14
+ * Thrown when an option pair is incompatible with each other and cannot be used
15
+ * at the same time.
16
+ *
17
+ * @see https://nodejs.org/api/errors.html#err_incompatible_option_pair
18
+ *
19
+ * @class
20
+ *
21
+ * @param {string } option1 - Option that cannot be ued
22
+ * @param {string } option2 - Option that is incompatible
23
+ * @return {NodeError<TypeError> } `TypeError` instance
24
+ */
25
+ const ERR_INCOMPATIBLE_OPTION_PAIR : NodeErrorConstructor <
26
+ TypeErrorConstructor ,
27
+ [ string , string ]
28
+ > = createNodeError (
29
+ ErrorCode . ERR_INCOMPATIBLE_OPTION_PAIR ,
30
+ TypeError ,
31
+ "Option '%s' cannot be used in combination with option '%s'"
32
+ )
33
+
34
+ export default ERR_INCOMPATIBLE_OPTION_PAIR
Original file line number Diff line number Diff line change @@ -11,3 +11,4 @@ export { default as ERR_ILLEGAL_CONSTRUCTOR } from './err-illegal-constructor'
11
11
export { default as ERR_IMPORT_ASSERTION_TYPE_FAILED } from './err-import-assertion-type-failed'
12
12
export { default as ERR_IMPORT_ASSERTION_TYPE_MISSING } from './err-import-assertion-type-missing'
13
13
export { default as ERR_IMPORT_ASSERTION_TYPE_UNSUPPORTED } from './err-import-assertion-type-unsupported'
14
+ export { default as ERR_INCOMPATIBLE_OPTION_PAIR } from './err-incompatible-option-pair'
You can’t perform that action at this time.
0 commit comments