Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 3e827c0

Browse files
Merge branch 'TheAlgorithms:master' into master
2 parents cde547a + 907b86c commit 3e827c0

File tree

3 files changed

+18
-18
lines changed

3 files changed

+18
-18
lines changed

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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 16 additions & 0 deletions
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

Lines changed: 0 additions & 16 deletions
This file was deleted.

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /