-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Expand file tree
/
Copy pathMorseCode.test.js
More file actions
20 lines (17 loc) · 721 Bytes
/
MorseCode.test.js
File metadata and controls
20 lines (17 loc) · 721 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import { morse } from '../MorseCode'
describe('Testing morse function', () => {
it('should return an enciphered string with a given input string', () => {
expect(morse('Hello World!')).toBe(
'**** * *-** *-** --- *-- --- *-* *-** -** -*-*--'
)
expect(morse('1+1=2')).toBe('*---- *-*-* *---- -***- **---')
})
it('should leave symbols that does not have its corresponding morse representation', () => {
expect(morse('© 2023 GitHub, Inc.')).toBe(
'© **--- ----- **--- ***-- --* ** - **** **- -*** --**-- ** -* -*-* *-*-*-'
)
})
it('should be able to accept custom morse code symbols', () => {
expect(morse('Nodejs', '.', '|')).toBe('|. ||| |.. . .||| ...')
})
})