Skip to content

Commit dd619c9

Browse files
committed
Migrate doctest for ReverseString.js
1 parent 3d48cbf commit dd619c9

File tree

2 files changed

+5
-18
lines changed

2 files changed

+5
-18
lines changed

String/ReverseWords.js

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,3 @@
1-
/*
2-
* Doctests
3-
*
4-
* > reverseWords('I Love JS')
5-
* 'JS Love I'
6-
* > reverseWords('Hello World')
7-
* 'World Hello'
8-
* > reverseWords('The Algorithms Javascript')
9-
* 'Javascript Algorithms The'
10-
* > reverseWords([])
11-
* ! TypeError
12-
* > reverseWords({})
13-
* ! TypeError
14-
* > reverseWords(null)
15-
* ! TypeError
16-
*/
171
const reverseWords = (str) => {
182
if (typeof str !== 'string') {
193
throw new TypeError('The given value is not a string')

String/test/ReverseWords.test.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,17 @@ import { reverseWords } from '../ReverseWords'
22

33
describe('reverseWords', () => {
44
it('expects to reverse words to return a joined word', () => {
5-
const SUT = reverseWords('I Love JS')
6-
expect(SUT).toBe('JS Love I')
5+
expect(reverseWords('I Love JS')).toBe('JS Love I')
6+
expect(reverseWords('Hello World')).toBe('World Hello')
7+
expect(reverseWords('The Algorithms Javascript')).toBe('Javascript Algorithms The')
78
})
9+
810
it.each`
911
input
1012
${123456}
1113
${[1, 2, 3, 4, 5, 6]}
1214
${{ test: 'test' }}
15+
${null}
1316
`(
1417
'expects to throw a type error given a value that is $input',
1518
({ input }) => {

0 commit comments

Comments
 (0)