-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tests for all components. Fixes for authorisation. Address checksum validatin refactoring
- Loading branch information
Showing
11 changed files
with
223 additions
and
75 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
This file was deleted.
Oops, something went wrong.
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,40 @@ | ||
import BaseService from '../src/services/BaseService' | ||
/** | ||
* BaseService test | ||
*/ | ||
describe('LoanRequest test', () => { | ||
const service = new BaseService('86C019FF04C4') | ||
|
||
it('LoanRequest is instantiable', () => { | ||
expect(service).toBeInstanceOf(BaseService) | ||
}) | ||
|
||
it('should check valid eth addresses without errors', () => { | ||
expect(BaseService['checkAddressChecksum']('0x71f4CF5Cfb74a9D3c9060aC4c25070F989cFC39C')).toBeUndefined() | ||
}) | ||
|
||
it('should throw error on checking invalid eth address', () => { | ||
expect(() => BaseService['checkAddressChecksum']('0x71f4CF5Cfb74a9D3c9060aC4c25070F989cFC39c')).toThrow() | ||
}) | ||
const axiosErrorMock = (status: number) => ({ | ||
message: '', | ||
name: '', | ||
config: {}, | ||
response: { status, data: null, headers: null, statusText: '', config: {} } | ||
}) | ||
it('should return correct error codes', () => { | ||
for (const status of [401, 404, 500, 504]) { | ||
expect(BaseService['errorHandler'](axiosErrorMock(status), 'type').code).toBe(status) | ||
} | ||
}) | ||
|
||
it('should return 500 code on unknown status', () => { | ||
expect(BaseService['errorHandler'](axiosErrorMock(343), 'type').code).toBe(500) | ||
}) | ||
|
||
it('should return 504 code if no response', () => { | ||
expect(BaseService['errorHandler']({ message: '', name: '', config: {}, response: undefined }, 'type').code).toBe( | ||
504 | ||
) | ||
}) | ||
}) |
Oops, something went wrong.