-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
61 lines (53 loc) · 1.55 KB
/
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
56
57
58
59
60
61
const assert = new require("assert");
const WordHash = new require("./index.js");
const wordHash = WordHash();
// Basic Variations
assert.equal(
wordHash.hash("0073baeb-c5dc-48a5-bcf7-b35f9d7a36fd"),
"video-sad-carolina-twenty"
);
assert.equal(
wordHash.hash("d13175d4-bee9-4e80-b24c-89c15c126cbf"),
"massachusetts-social-apart-robert"
);
assert.equal(
wordHash.hash("eeb33437-e61a-4cce-9c12-adf6ce4bf2d8"),
"fish-single-carolina-shade"
);
assert.equal(
wordHash.hash("6da4e640-e5de-4d0f-8423-df7ce323ef1c"),
"blossom-india-william-enemy"
);
// Varying the length
assert.equal(
WordHash({ length: 2 }).hash("0073baeb-c5dc-48a5-bcf7-b35f9d7a36fd"),
"video-sad"
);
assert.equal(
WordHash({ length: 3 }).hash("0073baeb-c5dc-48a5-bcf7-b35f9d7a36fd"),
"video-sad-carolina"
);
assert.equal(
WordHash({ length: 5 }).hash("0073baeb-c5dc-48a5-bcf7-b35f9d7a36fd"),
"video-sad-carolina-twenty-shade"
);
// Adding Salt
assert.equal(
WordHash({ salt: "saltySalt" }).hash("0073baeb-c5dc-48a5-bcf7-b35f9d7a36fd"),
"skylark-bakerloo-low-early"
);
assert.equal(
WordHash({ salt: "secret" }).hash("0073baeb-c5dc-48a5-bcf7-b35f9d7a36fd"),
"stream-burger-one-alanine"
);
// Changing Seperator
assert.equal(
WordHash({ separator: "~" }).hash("0073baeb-c5dc-48a5-bcf7-b35f9d7a36fd"),
"video~sad~carolina~twenty"
);
assert.deepEqual(
WordHash({ separator: null }).hash("0073baeb-c5dc-48a5-bcf7-b35f9d7a36fd"),
["video", "sad", "carolina", "twenty"]
);
// Can get number of permutations
assert.equal(WordHash().permutations, Math.pow(256, WordHash().length));