Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Ciphers/CaesarsCipher.js → Ciphers/CaesarCipher.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @param {number} rotation - the number of rotation, expect real number ( > 0)
* @return {string} - decrypted string
*/
const caesarsCipher = (str, rotation) => {
const caesarCipher = (str, rotation) => {
if (typeof str !== 'string' || !Number.isInteger(rotation) || rotation < 0) {
throw new TypeError('Arguments are invalid')
}
Expand All @@ -29,4 +29,4 @@ const caesarsCipher = (str, rotation) => {
})
}

export default caesarsCipher
export default caesarCipher
16 changes: 16 additions & 0 deletions Ciphers/test/CaesarCipher.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import caesarCipher from '../CaesarCipher'

describe('Testing the caesarsCipher function', () => {
it('Test - 1, Testing for invalid types', () => {
expect(() => caesarCipher(false, 3)).toThrow()
expect(() => caesarCipher('false', -1)).toThrow()
expect(() => caesarCipher('true', null)).toThrow()
})

it('Test - 2, Testing for valid string and rotation', () => {
expect(caesarCipher('middle-Outz', 2)).toBe('okffng-Qwvb')
expect(caesarCipher('abcdefghijklmnopqrstuvwxyz', 3)).toBe('defghijklmnopqrstuvwxyzabc')
expect(caesarCipher('Always-Look-on-the-Bright-Side-of-Life', 5)).toBe('Fqbfdx-Qttp-ts-ymj-Gwnlmy-Xnij-tk-Qnkj')
expect(caesarCipher('THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG', 23)).toBe('QEB NRFZH YOLTK CLU GRJMP LSBO QEB IXWV ALD')
})
})
16 changes: 0 additions & 16 deletions Ciphers/test/CaesarsCipher.test.js

This file was deleted.