-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.test.ts
More file actions
45 lines (36 loc) · 1.38 KB
/
index.test.ts
File metadata and controls
45 lines (36 loc) · 1.38 KB
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
import { expect, test } from "bun:test";
import { muddle } from ".";
function zero(a: Uint8Array): void {
for (const i of a) a[i] = 0
}
function increment(a: Uint8Array): void {
for (let i = 0; i < a.length; i++) a.set([i], i)
}
test("zero", () => {
expect(muddle("Fox 4", { getRandomValues: zero }))
.toBe('Aaa 0')
})
test("increment", () => {
expect(muddle("Fox 46 Run", { getRandomValues: increment }))
.toBe('Abc 34 Fgh')
})
test("Hex remains as hex", () => {
expect(muddle("aaaaaaaa-zzzzzzzz", { getRandomValues: increment }))
.toBe('abcdefab-ijklmnop')
})
test("increment, many letters, hex insensitive", () => {
expect(muddle("aaaaaaaAAAAAAaaaaaaaaaaaaaaaAAAAAAaaaaaaaaaaaaaaaaaaaaa", { getRandomValues: increment, hexLetters: 'insensitive' }))
.toBe('abcdefgHIJKLMnopqrstuvwxyzabCDEFGHijklmnopqrstuvwxyzabc')
})
test("boundaries", () => {
expect(muddle("az, AZ, 09", { getRandomValues: zero }))
.toBe('aa, AA, 00')
})
test("zero, case insensitive", () => {
expect(muddle("[Fox 4]", { getRandomValues: zero, letterCase: 'insensitive' }))
.toBe('[AAA 0]')
})
test("increment, case insensitive, hex insensitive", () => {
expect(muddle("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", { getRandomValues: increment, letterCase: 'insensitive', hexLetters: 'insensitive' }))
.toBe('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABC')
})