MyCrypto/spec/libs/validators.spec.js

36 lines
1.1 KiB
JavaScript
Raw Normal View History

2017-07-02 05:49:06 +00:00
import {
isValidBTCAddress,
isValidETHAddress,
isValidPath
2017-07-02 05:49:06 +00:00
} from '../../common/libs/validators';
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', () => {
expect(isValidBTCAddress(VALID_BTC_ADDRESS)).toBeTruthy();
2017-07-02 05:49:06 +00:00
});
it('should validate incorrect BTC address as false', () => {
expect(
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', () => {
expect(isValidETHAddress(VALID_ETH_ADDRESS)).toBeTruthy();
2017-07-02 05:49:06 +00:00
});
it('should validate incorrect ETH address as false', () => {
expect(
isValidETHAddress('nonsense' + VALID_ETH_ADDRESS + 'nonsense')
2017-07-02 05:49:06 +00:00
).toBeFalsy();
});
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
});