14
14
* limitations under the License.
15
15
*****************************************************************************/
16
16
import { processErrorResponse } from './common'
17
- import { LedgerError } from './consts'
17
+ import { LedgerCustomError , LedgerError } from './consts'
18
18
import { errorCodeToString } from './errors'
19
19
import { ResponseError } from './responseError'
20
20
@@ -25,6 +25,18 @@ describe('errorCodeToString', () => {
25
25
expect ( errorCodeToString ( knownErrorCode ) ) . toEqual ( expectedMessage )
26
26
} )
27
27
28
+ it ( 'should return the correct error message for a custom error code' , ( ) => {
29
+ const knownErrorCode : LedgerCustomError = 0xabcd
30
+ const expectedMessage = 'test custom error'
31
+ expect ( errorCodeToString ( knownErrorCode , { 0xabcd : expectedMessage } ) ) . toEqual ( expectedMessage )
32
+ } )
33
+
34
+ it ( 'should return the correct error message for a known error code, when a custom error list is passed' , ( ) => {
35
+ const knownErrorCode : LedgerError = 0x9000
36
+ const expectedMessage = 'No errors'
37
+ expect ( errorCodeToString ( knownErrorCode , { [ knownErrorCode ] : 'Custom no errors' } ) ) . toEqual ( expectedMessage )
38
+ } )
39
+
28
40
it ( 'should return "Unknown Return Code" for an unknown error code' , ( ) => {
29
41
const unknownErrorCode : LedgerError = 0x9999 as LedgerError
30
42
const expectedMessage = 'Unknown Return Code: 0x9999'
0 commit comments