-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdpk.test.js
51 lines (35 loc) · 1.48 KB
/
dpk.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
const { deterministicPartitionKey } = require("./dpk");
describe("deterministicPartitionKey", () => {
it("Returns the literal '0' when given no input", () => {
const trivialKey = deterministicPartitionKey();
expect(trivialKey).toBe("0");
});
it("Returns always string type", () => {
let trivialKey = deterministicPartitionKey();
expect(typeof trivialKey).toBe('string')
trivialKey = deterministicPartitionKey(1234);
expect(typeof trivialKey).toBe('string')
trivialKey = deterministicPartitionKey({});
expect(typeof trivialKey).toBe('string')
trivialKey = deterministicPartitionKey(new Date());
expect(typeof trivialKey).toBe('string')
trivialKey = deterministicPartitionKey(undefined);
expect(typeof trivialKey).toBe('string')
});
it("Returns always string with leenth 128 exept no input given", () => {
let trivialKey = deterministicPartitionKey();
expect(trivialKey.length).toBe(1);
trivialKey = deterministicPartitionKey(1234);
expect(trivialKey.length).toBe(128);
trivialKey = deterministicPartitionKey({});
expect(trivialKey.length).toBe(128)
trivialKey = deterministicPartitionKey(new Date());
expect(trivialKey.length).toBe(128)
});
it("It should return same key for same input", () => {
const val = 'abc'
const trivialKey = deterministicPartitionKey(val);
const newTrivialKey = deterministicPartitionKey(val);
expect(trivialKey).toMatch(newTrivialKey);
});
});