merge: Improved CaesarsCipher Algorithm (#963)

* chore: added helper variable

* feat: added new rotation option

* Revert "chore: added helper variable"

This reverts commit 489544da0a3d479910fbea020d3be3d0d10681bf.
This commit is contained in:
Fahim Faisaal
2022-03-29 12:35:58 +06:00
committed by GitHub
parent 7d57f7f1a7
commit cdfa264b33
2 changed files with 43 additions and 30 deletions

View File

@ -0,0 +1,16 @@
import caesarsCipher from '../CaesarsCipher'
describe('Testing the caesarsCipher function', () => {
it('Test - 1, Testing for invalid types', () => {
expect(() => caesarsCipher(false, 3)).toThrow()
expect(() => caesarsCipher('false', -1)).toThrow()
expect(() => caesarsCipher('true', null)).toThrow()
})
it('Test - 2, Testing for valid string and rotation', () => {
expect(caesarsCipher('middle-Outz', 2)).toBe('okffng-Qwvb')
expect(caesarsCipher('abcdefghijklmnopqrstuvwxyz', 3)).toBe('defghijklmnopqrstuvwxyzabc')
expect(caesarsCipher('Always-Look-on-the-Bright-Side-of-Life', 5)).toBe('Fqbfdx-Qttp-ts-ymj-Gwnlmy-Xnij-tk-Qnkj')
expect(caesarsCipher('THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG', 23)).toBe('QEB NRFZH YOLTK CLU GRJMP LSBO QEB IXWV ALD')
})
})