1+ import { ucFirst } from '@/strings'
2+
3+ describe ( 'ucFirst' , ( ) => {
4+
5+ it ( 'returns the given string with first uppercase letter' , ( ) => {
6+
7+ expect ( ucFirst ( 'some string' ) )
8+ . toBe ( 'Some string' )
9+
10+ } )
11+
12+
13+ it ( 'throws a TypeError when a non-stirng value is provided' , ( ) => {
14+
15+ // @ts -expect-error negative testing
16+ expect ( ( ) => ucFirst ( ) )
17+ . toThrow ( 'Cannot read properties of undefined (reading \'charAt\')' )
18+
19+ // @ts -expect-error negative testing
20+ expect ( ( ) => ucFirst ( undefined ) )
21+ . toThrow ( 'Cannot read properties of undefined (reading \'charAt\')' )
22+
23+ // @ts -expect-error negative testing
24+ expect ( ( ) => ucFirst ( null ) )
25+ . toThrow ( 'Cannot read properties of null (reading \'charAt\')' )
26+
27+ // @ts -expect-error negative testing
28+ expect ( ( ) => ucFirst ( false ) )
29+ . toThrow ( 'string.charAt is not a function' )
30+
31+ // @ts -expect-error negative testing
32+ expect ( ( ) => ucFirst ( true ) )
33+ . toThrow ( 'string.charAt is not a function' )
34+
35+ // @ts -expect-error negative testing
36+ expect ( ( ) => ucFirst ( 1 ) )
37+ . toThrow ( 'string.charAt is not a function' )
38+
39+ // @ts -expect-error negative testing
40+ expect ( ( ) => ucFirst ( { } ) )
41+ . toThrow ( 'string.charAt is not a function' )
42+
43+ // @ts -expect-error negative testing
44+ expect ( ( ) => ucFirst ( ( ) => { } ) )
45+ . toThrow ( 'string.charAt is not a function' )
46+
47+ // @ts -expect-error negative testing
48+ expect ( ( ) => ucFirst ( [ ] ) )
49+ . toThrow ( 'string.charAt is not a function' )
50+
51+ } )
52+
53+ } )
0 commit comments