2017-07-02 05:49:06 +00:00
|
|
|
import {
|
|
|
|
isValidBTCAddress,
|
2017-08-28 17:43:57 +00:00
|
|
|
isValidETHAddress,
|
|
|
|
isValidPath
|
2017-07-02 05:49:06 +00:00
|
|
|
} from '../../common/libs/validators';
|
2017-08-11 21:54:10 +00:00
|
|
|
|
|
|
|
const VALID_BTC_ADDRESS = '1MEWT2SGbqtz6mPCgFcnea8XmWV5Z4Wc6';
|
|
|
|
const VALID_ETH_ADDRESS = '0x7cB57B5A97eAbe94205C07890BE4c1aD31E486A8';
|
2017-06-26 23:38:45 +00:00
|
|
|
|
|
|
|
describe('Validator', () => {
|
2017-07-02 05:49:06 +00:00
|
|
|
it('should validate correct BTC address as true', () => {
|
2017-08-11 21:54:10 +00:00
|
|
|
expect(isValidBTCAddress(VALID_BTC_ADDRESS)).toBeTruthy();
|
2017-07-02 05:49:06 +00:00
|
|
|
});
|
|
|
|
it('should validate incorrect BTC address as false', () => {
|
|
|
|
expect(
|
2017-08-11 21:54:10 +00:00
|
|
|
isValidBTCAddress('nonsense' + VALID_BTC_ADDRESS + 'nonsense')
|
2017-07-02 05:49:06 +00:00
|
|
|
).toBeFalsy();
|
|
|
|
});
|
2017-06-26 23:38:45 +00:00
|
|
|
|
2017-07-02 05:49:06 +00:00
|
|
|
it('should validate correct ETH address as true', () => {
|
2017-08-11 21:54:10 +00:00
|
|
|
expect(isValidETHAddress(VALID_ETH_ADDRESS)).toBeTruthy();
|
2017-07-02 05:49:06 +00:00
|
|
|
});
|
|
|
|
it('should validate incorrect ETH address as false', () => {
|
|
|
|
expect(
|
2017-08-11 21:54:10 +00:00
|
|
|
isValidETHAddress('nonsense' + VALID_ETH_ADDRESS + 'nonsense')
|
2017-07-02 05:49:06 +00:00
|
|
|
).toBeFalsy();
|
|
|
|
});
|
2017-08-28 17:43:57 +00:00
|
|
|
|
|
|
|
it('should validate a correct DPath as true', () => {
|
|
|
|
expect(isValidPath('m/44\'/60\'/0\'/0')).toBeTruthy();
|
|
|
|
});
|
|
|
|
it('should validate an incorrect DPath as false', () => {
|
|
|
|
expect(isValidPath('m/44/60/0/0')).toBeFalsy();
|
|
|
|
});
|
2017-06-26 23:38:45 +00:00
|
|
|
});
|