mirror of
https://github.com/TheAlgorithms/JavaScript.git
synced 2025-07-18 09:23:55 +08:00
Added tests for Strings algorithms (#390)
* test: added tests for check anagram function
This commit is contained in:
31
String/CheckAnagram.test.js
Normal file
31
String/CheckAnagram.test.js
Normal file
@ -0,0 +1,31 @@
|
||||
import { checkAnagram } from './CheckAnagram'
|
||||
|
||||
describe('checkAnagram', () => {
|
||||
it.each`
|
||||
inputOne | inputTwo
|
||||
${123456} | ${'abcd'}
|
||||
${[1, 2, 3, 4, 5, 6]} | ${'abcd'}
|
||||
${{ test: 'test' }} | ${'abcd'}
|
||||
${'abcd'} | ${123456}
|
||||
${'abcd'} | ${[1, 2, 3, 4, 5, 6]}
|
||||
${'abcd'} | ${{ test: 'test' }}
|
||||
`(
|
||||
'expects to return "Not string(s)" given values $inputOne and $inputTwo',
|
||||
({ inputOne, inputTwo }) => {
|
||||
const SUT = checkAnagram(inputOne, inputTwo)
|
||||
expect(SUT).toBe('Not string(s)')
|
||||
}
|
||||
)
|
||||
it('expects to return "Not anagram" if the arguments have different lengths', () => {
|
||||
const SUT = checkAnagram('abs', 'abds')
|
||||
expect(SUT).toBe('Not Anagram')
|
||||
})
|
||||
it('expects to return "Not anagram" if the arguments are not anagrams', () => {
|
||||
const SUT = checkAnagram('abcs', 'abds')
|
||||
expect(SUT).toBe('Not anagrams')
|
||||
})
|
||||
it('expects to return "Anagram" if the arguments are anagram', () => {
|
||||
const SUT = checkAnagram('abcd', 'bcad')
|
||||
expect(SUT).toBe('Anagrams')
|
||||
})
|
||||
})
|
Reference in New Issue
Block a user