mirror of
https://github.com/TheAlgorithms/JavaScript.git
synced 2025-07-06 09:28:26 +08:00

* chore: Switch to Node 20 + Vitest * chore: migrate to vitest mock functions * chore: code style (switch to prettier) * test: re-enable long-running test Seems the switch to Node 20 and Vitest has vastly improved the code's and / or the test's runtime! see #1193 * chore: code style * chore: fix failing tests * Updated Documentation in README.md * Update contribution guidelines to state usage of Prettier * fix: set prettier printWidth back to 80 * chore: apply updated code style automatically * fix: set prettier line endings to lf again * chore: apply updated code style automatically --------- Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> Co-authored-by: Lars Müller <34514239+appgurueu@users.noreply.github.com>
23 lines
826 B
JavaScript
23 lines
826 B
JavaScript
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')
|
|
})
|
|
})
|