Skip to content

Commit

Permalink
Merge pull request #12 from Dunkelhaiser/dev
Browse files Browse the repository at this point in the history
Added tests for numeric strings
  • Loading branch information
Dunkelhaiser authored Jan 27, 2024
2 parents 67e9789 + 7f27546 commit c7e6660
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/cipher.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,19 @@ describe("caesar cipher", () => {
});
});

describe("numeric support", () => {
const decryptedText = "12345";
const encryptedText = "67890";
it("does not shift numbers if they are not provided in alphabet", () => {
const result = CaesarCipher.encrypt(decryptedText, 5);
expect(result).toBe(decryptedText);
});
it("does shift numbers if they are provided in alphabet", () => {
const result = CaesarCipher.encrypt(decryptedText, 5, "0123456789");
expect(result).toBe(encryptedText);
});
});

it("if provided shift is negative convert it to positive", () => {
const text = "Hello My Beautiful World!";
const result = CaesarCipher.encrypt(text, -7);
Expand Down

0 comments on commit c7e6660

Please sign in to comment.