-
Notifications
You must be signed in to change notification settings - Fork 97
/
account.test.js
55 lines (50 loc) 路 1.85 KB
/
account.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import { expect } from 'chai';
import { extractPublicKey, extractAddress, getActiveTokenAccount } from './account';
describe('Utils: Account', () => {
describe('extractPublicKey', () => {
it('should return a Hex string from any given string', () => {
const passphrase = 'field organ country moon fancy glare pencil combine derive fringe security pave';
const publicKey = 'a89751689c446067cc2107ec2690f612eb47b5939d5570d0d54b81eafaf328de';
expect(extractPublicKey(passphrase)).to.be.equal(publicKey);
});
});
describe('extractAddress', () => {
it('should return the account address from given passphrase', () => {
const passphrase = 'field organ country moon fancy glare pencil combine derive fringe security pave';
const derivedAddress = '440670704090200331L';
expect(extractAddress(passphrase)).to.be.equal(derivedAddress);
});
it('should return the account address from given public key', () => {
const publicKey = 'a89751689c446067cc2107ec2690f612eb47b5939d5570d0d54b81eafaf328de';
const derivedAddress = '440670704090200331L';
expect(extractAddress(publicKey)).to.be.equal(derivedAddress);
});
it('should return false if no param passed to it', () => {
expect(extractAddress()).to.be.equal(false);
});
});
describe('getActiveTokenAccount', () => {
it('should get account with active token info on the top level', () => {
const activeToken = 'BTC';
const account = {
info: {
BTC: {
address: 'btc address dummy',
},
},
};
const state = {
account,
settings: {
token: {
active: activeToken,
},
},
};
expect(getActiveTokenAccount(state)).to.be.deep.equal({
...account,
...account.info[activeToken],
});
});
});
});