Merge pull request #601 from thivagar-manickam/master

Added test script for CreatePermutations and file name change
This commit is contained in:
Tapajyoti Bose
2021-05-07 09:01:43 +05:30
committed by GitHub
2 changed files with 15 additions and 2 deletions

View File

@ -33,5 +33,4 @@ const createPermutations = (str) => {
}
return perms
}
console.log(createPermutations('abc')) // should print ["abc", "acb", "bac", "bca", "cab", "cba"]
export { createPermutations }

View File

@ -0,0 +1,14 @@
import { createPermutations } from '../CreatePermutations'
describe('createPermutations', () => {
it('expects to generate 6 different combinations', () => {
const text = 'abc'
const SUT = createPermutations(text)
expect(SUT).toStrictEqual(['abc', 'acb', 'bac', 'bca', 'cab', 'cba'])
})
it('expects to generate 2 different combinations', () => {
const text = '12'
const SUT = createPermutations(text)
expect(SUT).toStrictEqual(['12', '21'])
})
})