Skip to content

Commit 573fb2f

Browse files
committed
feat(models): ERR_INCOMPATIBLE_OPTION_PAIR
Signed-off-by: Lexus Drumgold <[email protected]>
1 parent 2f6dfec commit 573fb2f

File tree

3 files changed

+74
-0
lines changed

3 files changed

+74
-0
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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+
})
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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

src/models/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ export { default as ERR_ILLEGAL_CONSTRUCTOR } from './err-illegal-constructor'
1111
export { default as ERR_IMPORT_ASSERTION_TYPE_FAILED } from './err-import-assertion-type-failed'
1212
export { default as ERR_IMPORT_ASSERTION_TYPE_MISSING } from './err-import-assertion-type-missing'
1313
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'

0 commit comments

Comments
 (0)