MyCrypto/spec/libs/validators.spec.ts

36 lines
1.1 KiB
TypeScript
Raw Normal View History

2017-07-01 22:49:06 -07:00
import {
isValidBTCAddress,
isValidETHAddress,
isValidPath
2017-07-01 22:49:06 -07:00
} from '../../common/libs/validators';
const VALID_BTC_ADDRESS = '1MEWT2SGbqtz6mPCgFcnea8XmWV5Z4Wc6';
const VALID_ETH_ADDRESS = '0x7cB57B5A97eAbe94205C07890BE4c1aD31E486A8';
2017-06-26 16:38:45 -07:00
describe('Validator', () => {
2017-07-01 22:49:06 -07:00
it('should validate correct BTC address as true', () => {
expect(isValidBTCAddress(VALID_BTC_ADDRESS)).toBeTruthy();
2017-07-01 22:49:06 -07:00
});
it('should validate incorrect BTC address as false', () => {
expect(
isValidBTCAddress('nonsense' + VALID_BTC_ADDRESS + 'nonsense')
2017-07-01 22:49:06 -07:00
).toBeFalsy();
});
2017-06-26 16:38:45 -07:00
2017-07-01 22:49:06 -07:00
it('should validate correct ETH address as true', () => {
expect(isValidETHAddress(VALID_ETH_ADDRESS)).toBeTruthy();
2017-07-01 22:49:06 -07:00
});
it('should validate incorrect ETH address as false', () => {
expect(
isValidETHAddress('nonsense' + VALID_ETH_ADDRESS + 'nonsense')
2017-07-01 22:49:06 -07: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 16:38:45 -07:00
});