forked from TheAlgorithms/JavaScript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLetterCombination.test.js
48 lines (45 loc) · 994 Bytes
/
LetterCombination.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import { letterCombinations } from '../LetterCombination'
describe('Letter Combinations', () => {
it('should return empty array if provided string is not valid', () => {
const result = letterCombinations('')
expect(Array.isArray(result)).toBe(true)
expect(result.length).toBe(0)
})
it('should return empty array if provided string is empty', () => {
const result = letterCombinations(null)
expect(Array.isArray(result)).toBe(true)
expect(result.length).toBe(0)
})
it('should return letter combination of 234', () => {
const result = letterCombinations('234')
expect(result).toEqual([
'adg',
'adh',
'adi',
'aeg',
'aeh',
'aei',
'afg',
'afh',
'afi',
'bdg',
'bdh',
'bdi',
'beg',
'beh',
'bei',
'bfg',
'bfh',
'bfi',
'cdg',
'cdh',
'cdi',
'ceg',
'ceh',
'cei',
'cfg',
'cfh',
'cfi'
])
})
})