Skip to content

Commit 907b86c

Browse files
authored
Rename to CaesarCipher (#1144)
1 parent d0e61e1 commit 907b86c

File tree

3 files changed

+18
-18
lines changed

3 files changed

+18
-18
lines changed

Ciphers/CaesarsCipher.js renamed to Ciphers/CaesarCipher.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* @param {number} rotation - the number of rotation, expect real number ( > 0)
77
* @return {string} - decrypted string
88
*/
9-
const caesarsCipher = (str, rotation) => {
9+
const caesarCipher = (str, rotation) => {
1010
if (typeof str !== 'string' || !Number.isInteger(rotation) || rotation < 0) {
1111
throw new TypeError('Arguments are invalid')
1212
}
@@ -29,4 +29,4 @@ const caesarsCipher = (str, rotation) => {
2929
})
3030
}
3131

32-
export default caesarsCipher
32+
export default caesarCipher

Ciphers/test/CaesarCipher.test.js

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

Ciphers/test/CaesarsCipher.test.js

-16
This file was deleted.

0 commit comments

Comments
 (0)