blob: fa5808611335b95da1648ad1696fd849c127e7af (
plain)
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
|
/* eslint no-tabs:"off" */
function run_test() {
_("Normalize passphrase recognizes hyphens.");
const pp = "26ect2thczm599m2ffqarbicjq";
const hyphenated = "2-6ect2-thczm-599m2-ffqar-bicjq";
Assert.equal(Utils.normalizePassphrase(hyphenated), pp);
_("Skip whitespace.");
Assert.equal(
"aaaaaaaaaaaaaaaaaaaaaaaaaa",
Utils.normalizePassphrase("aaaaaaaaaaaaaaaaaaaaaaaaaa ")
);
Assert.equal(
"aaaaaaaaaaaaaaaaaaaaaaaaaa",
Utils.normalizePassphrase(" aaaaaaaaaaaaaaaaaaaaaaaaaa")
);
Assert.equal(
"aaaaaaaaaaaaaaaaaaaaaaaaaa",
Utils.normalizePassphrase(" aaaaaaaaaaaaaaaaaaaaaaaaaa ")
);
Assert.equal(
"aaaaaaaaaaaaaaaaaaaaaaaaaa",
Utils.normalizePassphrase(" a-aaaaa-aaaaa-aaaaa-aaaaa-aaaaa ")
);
Assert.ok(Utils.isPassphrase("aaaaaaaaaaaaaaaaaaaaaaaaaa "));
Assert.ok(Utils.isPassphrase(" aaaaaaaaaaaaaaaaaaaaaaaaaa"));
Assert.ok(Utils.isPassphrase(" aaaaaaaaaaaaaaaaaaaaaaaaaa "));
Assert.ok(Utils.isPassphrase(" a-aaaaa-aaaaa-aaaaa-aaaaa-aaaaa "));
Assert.ok(!Utils.isPassphrase(" -aaaaa-aaaaa-aaaaa-aaaaa-aaaaa "));
_("Normalizing 20-char passphrases.");
Assert.equal(
Utils.normalizePassphrase("abcde-abcde-abcde-abcde"),
"abcdeabcdeabcdeabcde"
);
Assert.equal(
Utils.normalizePassphrase("a-bcde-abcde-abcde-abcde"),
"a-bcde-abcde-abcde-abcde"
);
Assert.equal(
Utils.normalizePassphrase(" abcde-abcde-abcde-abcde "),
"abcdeabcdeabcdeabcde"
);
}
|