mirror of
https://github.com/TheAlgorithms/JavaScript.git
synced 2025-07-19 01:55:51 +08:00
Added tests for Strings algorithms (#390)
* test: added tests for check anagram function
This commit is contained in:
21
String/ReverseWords.test.js
Normal file
21
String/ReverseWords.test.js
Normal file
@ -0,0 +1,21 @@
|
||||
import { reverseWords } from './ReverseWords'
|
||||
|
||||
describe('reverseWords', () => {
|
||||
it('expects to reverse words to return a joined word', () => {
|
||||
const SUT = reverseWords('I Love JS')
|
||||
expect(SUT).toBe('JS Love I')
|
||||
})
|
||||
it.each`
|
||||
input
|
||||
${123456}
|
||||
${[1, 2, 3, 4, 5, 6]}
|
||||
${{ test: 'test' }}
|
||||
`(
|
||||
'expects to throw a type error given a value that is $input',
|
||||
({ input }) => {
|
||||
expect(() => {
|
||||
reverseWords(input)
|
||||
}).toThrow('The given value is not a string')
|
||||
}
|
||||
)
|
||||
})
|
Reference in New Issue
Block a user