mirror of
https://github.com/TheAlgorithms/JavaScript.git
synced 2025-07-06 09:28:26 +08:00
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:
16
Ciphers/test/CaesarsCipher.test.js
Normal file
16
Ciphers/test/CaesarsCipher.test.js
Normal 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')
|
||||
})
|
||||
})
|
Reference in New Issue
Block a user