Skip to content
This repository has been archived by the owner on Apr 18, 2021. It is now read-only.

Commit

Permalink
fix: add specific test for string type index at getPrivateKey.js
Browse files Browse the repository at this point in the history
  • Loading branch information
JhChoy committed Jan 25, 2019
1 parent 247a087 commit 260aa2c
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions packages/vvisp-utils/test/getPrivateKey.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,18 @@ describe('# getPrivateKey test', function() {
});
});

it('should reject when index is not number or number string except undefined and null', function() {
expect(() => getPrivateKey(MNEMONIC, '123')).to.not.throw(TypeError);
it('should reject with invalid type: JSON or array', function() {
expect(() => getPrivateKey(MNEMONIC, { a: 1 })).to.throw(TypeError);
expect(() => getPrivateKey(MNEMONIC, ['hello', 'there'])).to.throw(
TypeError
);
});

it('should success getPrivateKey with number or number string', function() {
expect(() => getPrivateKey(MNEMONIC, '123')).to.not.throw();
expect(() => getPrivateKey(MNEMONIC, 123)).to.not.throw();
});

it('should set 0 when index is undefined or null', function() {
const nullIndex = getPrivateKey(MNEMONIC, null);
const undefinedIndex = getPrivateKey(MNEMONIC, undefined);
Expand Down Expand Up @@ -64,6 +68,12 @@ describe('# getPrivateKey test', function() {
const result1 = getPrivateKey(MNEMONIC, 1);
result0.should.not.equal(result1);
});

it('should be same with string index and number index', function() {
getPrivateKey(MNEMONIC, '123').should.be.equal(
getPrivateKey(MNEMONIC, 123)
);
});
});

describe('private key enable', function() {
Expand Down

0 comments on commit 260aa2c

Please sign in to comment.