Skip to content
This repository has been archived by the owner on Jun 7, 2019. It is now read-only.

Commit

Permalink
📚 Fix test wording
Browse files Browse the repository at this point in the history
  • Loading branch information
mitsujutsu committed Nov 13, 2018
1 parent 8deff7b commit ca16f90
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 32 deletions.
6 changes: 4 additions & 2 deletions packages/lisk-transactions/src/utils/validation/validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export const validateKeysgroup = (keysgroup: ReadonlyArray<string>) => {
const MIN_ADDRESS_LENGTH = 2;
const MAX_ADDRESS_LENGTH = 22;
const BASE_TEN = 10;
export const validateAddress = (address: string) => {
export const validateAddress = (address: string): boolean => {
if (
address.length < MIN_ADDRESS_LENGTH ||
address.length > MAX_ADDRESS_LENGTH
Expand Down Expand Up @@ -100,7 +100,9 @@ export const validateAddress = (address: string) => {
}

if (addressString !== addressNumber.toString(BASE_TEN)) {
throw new Error('Address number does not have natural representation.');
throw new Error(
"Address string format does not match it's number representation.",
);
}

return true;
Expand Down
55 changes: 25 additions & 30 deletions packages/lisk-transactions/test/utils/validation/validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ describe('validation', () => {
'922fbfdd596fa78269bbcadc67ec2a1cc15fc929a19c462169568d7a3df1a1aa',
'922fbfdd596fa78269bbcadc67ec2a1cc15fc929a19c462169568d7a3df1a1aa',
];
it('should throw', () => {
it('should throw an error', () => {
return expect(
checkPublicKeysForDuplicates.bind(null, publicKeys),
).to.throw(
Expand All @@ -210,60 +210,55 @@ describe('validation', () => {

describe('Given an address that is too short', () => {
const address = 'L';
const error =
'Address length does not match requirements. Expected between 2 and 22 characters.';

it('should throw', () => {
return expect(validateAddress.bind(null, address)).to.throw(error);
it('should throw an error', () => {
return expect(validateAddress.bind(null, address)).to.throw(
'Address length does not match requirements. Expected between 2 and 22 characters.',
);
});
});

describe('Given an address that is too long', () => {
const address = '12345678901234567890123L';
const error =
'Address length does not match requirements. Expected between 2 and 22 characters.';

it('should throw', () => {
return expect(validateAddress.bind(null, address)).to.throw(error);
it('should throw an error', () => {
return expect(validateAddress.bind(null, address)).to.throw(
'Address length does not match requirements. Expected between 2 and 22 characters.',
);
});
});

describe('Given an address without L at the end', () => {
const address = '1234567890';
const error =
'Address format does not match requirements. Expected "L" at the end.';

it('should throw', () => {
return expect(validateAddress.bind(null, address)).to.throw(error);
it('should throw an error', () => {
return expect(validateAddress.bind(null, address)).to.throw(
'Address format does not match requirements. Expected "L" at the end.',
);
});
});

describe('Given an address that includes `.`', () => {
const address = '14.15133512790761431L';
const error =
'Address format does not match requirements. Address includes invalid character: `.`.';

it('should throw', () => {
return expect(validateAddress.bind(null, address)).to.throw(error);
it('should throw an error', () => {
return expect(validateAddress.bind(null, address)).to.throw(
'Address format does not match requirements. Address includes invalid character: `.`.',
);
});
});

describe('Given an address that is out of range', () => {
const address = '18446744073709551616L';
const error =
'Address format does not match requirements. Address out of maximum range.';

it('should throw', () => {
return expect(validateAddress.bind(null, address)).to.throw(error);
it('should throw an error', () => {
return expect(validateAddress.bind(null, address)).to.throw(
'Address format does not match requirements. Address out of maximum range.',
);
});
});

describe('Given an address that has leading zeros', () => {
const address = '00015133512790761431L';
const error = 'Address number does not have natural representation.';

it('should throw', () => {
return expect(validateAddress.bind(null, address)).to.throw(error);
it('should throw an error', () => {
return expect(validateAddress.bind(null, address)).to.throw(
"Address string format does not match it's number representation.",
);
});
});
});
Expand Down

0 comments on commit ca16f90

Please sign in to comment.