mirror of
https://github.com/TheAlgorithms/JavaScript.git
synced 2026-03-13 15:21:15 +08:00
merge: Improved ROT13 function (#964)
* feat: improved memoize function
used Map instead of object & used the JSON.stringfy method for generate a valid string as a key
* docs: modified documentation
* style: format with standard
* docs: modified stringify doc
* refactor: remove two repetition implementation
* feat: added validation, test codes
* chore: remove useless words
* feat: added types for jest
* chore: added link box
* feat: added new validation test casses & methods
* style: formated with standard
* feat: added parse method & test cases
* docs: added js docs
* chore: added default import export
* feat: imporved algorithm via replace method
* test: added two test cases
* feat: added jest type for suggestions
* feat: added `reduceRight` & `trim` method
* chore: added helper variable
* feat: added new rotation option
* Revert "chore: added helper variable"
This reverts commit 489544da0a.
* remove: yarn lock
* chore: fix grammer
* feat: remove revert
* chore: added new line
This commit is contained in:
18
Ciphers/test/ROT13.test.js
Normal file
18
Ciphers/test/ROT13.test.js
Normal file
@@ -0,0 +1,18 @@
|
||||
import ROT13 from '../ROT13'
|
||||
|
||||
describe('Testing ROT13 function', () => {
|
||||
it('Test - 1, passing a non-string as an argument', () => {
|
||||
expect(() => ROT13(0x345)).toThrow()
|
||||
expect(() => ROT13(123)).toThrow()
|
||||
expect(() => ROT13(123n)).toThrow()
|
||||
expect(() => ROT13(false)).toThrow()
|
||||
expect(() => ROT13({})).toThrow()
|
||||
expect(() => ROT13([])).toThrow()
|
||||
})
|
||||
|
||||
it('Test - 2, passing a string as an argument', () => {
|
||||
expect(ROT13('Uryyb Jbeyq')).toBe('Hello World')
|
||||
expect(ROT13('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz')).toBe('NOPQRSTUVWXYZABCDEFGHIJKLMnopqrstuvwxyzabcdefghijklm')
|
||||
expect(ROT13('The quick brown fox jumps over the lazy dog')).toBe('Gur dhvpx oebja sbk whzcf bire gur ynml qbt')
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user