mirror of
https://github.com/TheAlgorithms/JavaScript.git
synced 2025-07-05 00:01:37 +08:00
49 lines
994 B
JavaScript
49 lines
994 B
JavaScript
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'
|
|
])
|
|
})
|
|
})
|