-
-
Notifications
You must be signed in to change notification settings - Fork 297
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updating Gitbeaker Error typings (#3513)
- Loading branch information
1 parent
7eec49b
commit bfe40a5
Showing
4 changed files
with
109 additions
and
14 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
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
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,66 @@ | ||
import { | ||
GitbeakerRequestError, | ||
GitbeakerRetryError, | ||
GitbeakerTimeoutError, | ||
} from '../../src/GitbeakerError'; | ||
|
||
describe('GitbeakerRequestError', () => { | ||
it('should create a custom error with the name "GitbeakerRequestError"', () => { | ||
const error = new GitbeakerRequestError('my message'); | ||
|
||
expect(error.name).toBe('GitbeakerRequestError'); | ||
expect(error).toBeInstanceOf(GitbeakerRequestError); | ||
}); | ||
|
||
it('should accept a message and a cause option', () => { | ||
const error = new GitbeakerRequestError('my message', { | ||
cause: { | ||
description: 'test', | ||
request: new Request('http://test.url'), | ||
response: new Response(), | ||
}, | ||
}); | ||
|
||
expect(error.message).toBe('my message'); | ||
expect(error?.cause?.description).toBe('test'); | ||
expect(error.cause?.request).toBeInstanceOf(Request); | ||
expect(error.cause?.response).toBeInstanceOf(Response); | ||
}); | ||
|
||
it('should accept a message without a cause option', () => { | ||
const error = new GitbeakerRequestError('my message'); | ||
|
||
expect(error.message).toBe('my message'); | ||
expect(error?.cause).toBeUndefined(); | ||
}); | ||
}); | ||
|
||
describe('GitbeakerRetryError', () => { | ||
it('should create a custom error with the name "GitbeakerRetryError"', () => { | ||
const error = new GitbeakerRetryError('my message'); | ||
|
||
expect(error.name).toBe('GitbeakerRetryError'); | ||
expect(error).toBeInstanceOf(GitbeakerRetryError); | ||
}); | ||
|
||
it('should accept error options', () => { | ||
const error = new GitbeakerRetryError('my message', { cause: 'reason' }); | ||
|
||
expect(error.cause).toBe('reason'); | ||
}); | ||
}); | ||
|
||
describe('GitbeakerTimeoutError', () => { | ||
it('should create a custom error with the name "GitbeakerTimeoutError"', () => { | ||
const error = new GitbeakerTimeoutError('my message'); | ||
|
||
expect(error.name).toBe('GitbeakerTimeoutError'); | ||
expect(error).toBeInstanceOf(GitbeakerTimeoutError); | ||
}); | ||
|
||
it('should accept error options', () => { | ||
const error = new GitbeakerTimeoutError('my message', { cause: 'reason' }); | ||
|
||
expect(error.cause).toBe('reason'); | ||
}); | ||
}); |
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