File tree Expand file tree Collapse file tree 2 files changed +5
-18
lines changed Expand file tree Collapse file tree 2 files changed +5
-18
lines changed Original file line number Diff line number Diff line change 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
- */
17
1
const reverseWords = ( str ) => {
18
2
if ( typeof str !== 'string' ) {
19
3
throw new TypeError ( 'The given value is not a string' )
Original file line number Diff line number Diff line change @@ -2,14 +2,17 @@ import { reverseWords } from '../ReverseWords'
2
2
3
3
describe ( 'reverseWords' , ( ) => {
4
4
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' )
7
8
} )
9
+
8
10
it . each `
9
11
input
10
12
${ 123456 }
11
13
${ [ 1 , 2 , 3 , 4 , 5 , 6 ] }
12
14
${ { test : 'test' } }
15
+ ${ null }
13
16
` (
14
17
'expects to throw a type error given a value that is $input' ,
15
18
( { input } ) => {
You can’t perform that action at this time.
0 commit comments