mirror of
https://github.com/TheAlgorithms/JavaScript.git
synced 2025-07-05 00:01:37 +08:00
algorithm: letter combinations (#1209)
This commit is contained in:
48
Recursive/test/LetterCombination.test.js
Normal file
48
Recursive/test/LetterCombination.test.js
Normal file
@ -0,0 +1,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'
|
||||
])
|
||||
})
|
||||
})
|
Reference in New Issue
Block a user