Added test script for CreatePermutations and file name change

This commit is contained in:
Thivagar Manickam
2021-05-06 21:08:47 +05:30
parent 3e5489d8ef
commit 9f24341b5b
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'])
})
})