-
Notifications
You must be signed in to change notification settings - Fork 919
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
(cherry picked from commit 016f090) Signed-off-by: Joshua Li <[email protected]> Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
- Loading branch information
1 parent
5437239
commit 0d492c8
Showing
3 changed files
with
30 additions
and
2 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,28 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { handleFacetError } from './utils'; | ||
|
||
describe('handleFacetError', () => { | ||
const error = new Error('mock-error'); | ||
(error as any).body = { | ||
message: 'test error message', | ||
}; | ||
(error as any).status = '400'; | ||
it('should throw an error with message from response.data.body.message', () => { | ||
const response = { | ||
data: error, | ||
}; | ||
|
||
expect(() => handleFacetError(response)).toThrowError(); | ||
try { | ||
handleFacetError(response); | ||
} catch (err: any) { | ||
expect(err.message).toBe('test error message'); | ||
expect(err.name).toBe('400'); | ||
expect(err.status).toBe('400'); | ||
} | ||
}); | ||
}); |
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