-
Notifications
You must be signed in to change notification settings - Fork 96
/
recoveryPhrase.test.js
41 lines (32 loc) · 1.3 KB
/
recoveryPhrase.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
// @flow
import { makeSortedPhrase } from './recoveryPhrase';
describe('makeSortedPhrase()', () => {
test('sort recovery phrase with unique words', () => {
const phraseWithUniqueWords = ['w_3', 'w_2', 'w_1'];
const sorted = makeSortedPhrase(phraseWithUniqueWords);
const [first, second, third] = sorted;
expect(first.id).toBe(0);
expect(first.word).toBe('w_1');
expect(first.originalIdx).toBe(2);
expect(second.id).toBe(1);
expect(second.word).toBe('w_2');
expect(second.originalIdx).toBe(1);
expect(third.id).toBe(2);
expect(third.word).toBe('w_3');
expect(third.originalIdx).toBe(0);
});
test('sort recovery phrase with duplicates', () => {
const recoveryPhraseWithDuplicates = ['abandon', 'address', 'abandon'];
const sorted = makeSortedPhrase(recoveryPhraseWithDuplicates);
const [first, second, third] = sorted;
expect(first.id).toBe(0);
expect(first.word).toBe('abandon');
expect(first.originalIdx).toBe(0);
expect(second.id).toBe(1);
expect(second.word).toBe('abandon');
expect(second.originalIdx).toBe(2);
expect(third.id).toBe(2);
expect(third.word).toBe('address');
expect(third.originalIdx).toBe(1);
})
});