Skip to content

Commit 4b5d5b8

Browse files
author
michael kappes
committed
added test for IV length to short/long
1 parent 4cad120 commit 4b5d5b8

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

lib/decrypt.function.spec.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,16 @@ describe("secret", () => {
77
const input = "LAe8iDYgcIu/TUFaRSeJibKRE7L0gV2Bd8QC976qRqgSQ+cvPoXG/dU+6aS5+tXC";
88
const expected = "Can you keep a secret?";
99

10-
// WHEN
11-
const output = await decrypt(input, key);
10+
// THEN
11+
expect(decrypt(input, key)).resolves.toBe(expected);
12+
});
13+
14+
it("should throw an error when IV size is invalid", async () => {
15+
// GIVEN
16+
const key = "C9HikSYQW/K+ZvRphxEuSw==";
17+
const input = "Zm9vCg==";
1218

1319
// THEN
14-
expect(output).toBe(expected);
20+
expect(decrypt(input, key)).rejects.toThrowError("Invalid IV size. Size of 16 byte required.");
1521
});
1622
});

0 commit comments

Comments
 (0)