mirror of
https://github.com/TheAlgorithms/JavaScript.git
synced 2025-07-05 16:26:47 +08:00
Merge pull request #601 from thivagar-manickam/master
Added test script for CreatePermutations and file name change
This commit is contained in:
@ -33,5 +33,4 @@ const createPermutations = (str) => {
|
||||
}
|
||||
return perms
|
||||
}
|
||||
|
||||
console.log(createPermutations('abc')) // should print ["abc", "acb", "bac", "bca", "cab", "cba"]
|
||||
export { createPermutations }
|
14
String/test/CreatePermutations.test.js
Normal file
14
String/test/CreatePermutations.test.js
Normal 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'])
|
||||
})
|
||||
})
|
Reference in New Issue
Block a user