@@ -3,35 +3,35 @@ import { maybe } from "../../src"
33describe ( 'Maybe' , ( ) => {
44 describe ( 'when returning a value by default' , ( ) => {
55 it ( 'should handle "none" case' , ( ) => {
6- const sut : string | undefined = undefined
6+ const sut = undefined as string | undefined
77 const maybeAString = maybe ( sut ) . valueOr ( 'default output' )
88
99 expect ( maybeAString ) . toEqual ( 'default output' )
1010 } )
1111
1212 it ( 'should handle "some" case' , ( ) => {
13- const sut : string | undefined = 'actual input'
13+ const sut = 'actual input' as string | undefined
1414 const maybeAString = maybe ( sut ) . valueOr ( 'default output' )
1515
1616 expect ( maybeAString ) . toEqual ( 'actual input' )
1717 } )
1818
1919 it ( 'should handle "some" case when input is null' , ( ) => {
20- const sut : string | undefined | null = null
20+ const sut = null as string | undefined | null
2121 const maybeAString = maybe ( sut ) . valueOr ( 'default output' )
2222
2323 expect ( maybeAString ) . toEqual ( 'default output' )
2424 } )
2525
2626 it ( 'should handle "some" case when input is ""' , ( ) => {
27- const sut : string | undefined | null = ''
27+ const sut = '' as string | undefined | null
2828 const maybeAString = maybe ( sut ) . valueOr ( 'fallback' )
2929
3030 expect ( maybeAString ) . toEqual ( '' )
3131 } )
3232
3333 it ( 'should handle "some" case when input is 0' , ( ) => {
34- const sut : number | undefined | null = 0
34+ const sut = 0 as number | undefined | null
3535 const maybeAString = maybe ( sut ) . valueOr ( 10 )
3636
3737 expect ( maybeAString ) . toEqual ( 0 )
@@ -40,7 +40,7 @@ describe('Maybe', () => {
4040
4141 describe ( 'when returning a value by computation' , ( ) => {
4242 it ( 'should handle "none" case' , ( ) => {
43- const sut : string | undefined = undefined
43+ const sut = undefined as string | undefined
4444 const maybeAString = maybe ( sut ) . valueOrCompute ( ( ) => 'default output' )
4545
4646 expect ( maybeAString ) . toEqual ( 'default output' )
@@ -54,21 +54,21 @@ describe('Maybe', () => {
5454 } )
5555
5656 it ( 'should handle "some" case when input is null' , ( ) => {
57- const sut : string | undefined = null
57+ const sut = null as string | null
5858 const maybeAString = maybe ( sut ) . valueOrCompute ( ( ) => 'fallback' )
5959
6060 expect ( maybeAString ) . toEqual ( 'fallback' )
6161 } )
6262
6363 it ( 'should handle "some" case when input is ""' , ( ) => {
64- const sut : string | undefined = ''
64+ const sut = '' as string | undefined
6565 const maybeAString = maybe ( sut ) . valueOrCompute ( ( ) => 'fallback' )
6666
6767 expect ( maybeAString ) . toEqual ( '' )
6868 } )
6969
7070 it ( 'should handle "some" case when input is 0' , ( ) => {
71- const sut : number | undefined = 0
71+ const sut = 0 as number | undefined
7272 const maybeAString = maybe ( sut ) . valueOrCompute ( ( ) => 10 )
7373
7474 expect ( maybeAString ) . toEqual ( 0 )
@@ -77,7 +77,7 @@ describe('Maybe', () => {
7777
7878 describe ( 'when returning from a match operation' , ( ) => {
7979 it ( 'should handle "none" case' , ( ) => {
80- const sut : string | undefined = undefined
80+ const sut = undefined as string | undefined
8181 const maybeAMappedString = maybe ( sut )
8282 . match ( {
8383 none : ( ) => 'fallback' ,
@@ -88,7 +88,7 @@ describe('Maybe', () => {
8888 } )
8989
9090 it ( 'should handle "some" case' , ( ) => {
91- const sut : string | undefined = 'existing value'
91+ const sut = 'existing value' as string | undefined
9292 const maybeAMappedString = maybe ( sut )
9393 . match ( {
9494 none : ( ) => 'fallback' ,
@@ -102,8 +102,8 @@ describe('Maybe', () => {
102102 describe ( 'when performing side-effect operations' , ( ) => {
103103 it ( 'should handle "none" case' , ( ) => {
104104 // tslint:disable-next-line:no-let
105- let sideEffectStore : string
106- const sut : string | undefined = undefined
105+ let sideEffectStore = ''
106+ const sut = undefined as string | undefined
107107
108108 maybe ( sut )
109109 . tap ( {
@@ -118,8 +118,8 @@ describe('Maybe', () => {
118118
119119 it ( 'should handle "some" case' , ( ) => {
120120 // tslint:disable-next-line:no-let
121- let sideEffectStore : string
122- const sut : string | undefined = 'existing value'
121+ let sideEffectStore = ''
122+ const sut = 'existing value' as string | undefined
123123
124124 maybe ( sut )
125125 . tap ( {
@@ -139,7 +139,7 @@ describe('Maybe', () => {
139139 }
140140
141141 it ( 'should handle valid input' , ( ) => {
142- const sut : string | undefined = 'initial input'
142+ const sut = 'initial input' as string | undefined
143143
144144 const maybeSomeString = maybe ( sut )
145145 . map ( _str => getUserService < string > ( 'initial input mapped' ) )
@@ -163,7 +163,7 @@ describe('Maybe', () => {
163163 } )
164164
165165 it ( 'should handle undefined input' , ( ) => {
166- const sut : string | undefined = undefined
166+ const sut = undefined as string | undefined
167167
168168 const maybeSomeString = maybe ( sut )
169169 . map ( _str => getUserService < string > ( 'initial input mapped' ) )
@@ -187,7 +187,7 @@ describe('Maybe', () => {
187187 } )
188188
189189 it ( 'should handle input of 0' , ( ) => {
190- const sut : number | undefined = 0
190+ const sut = 0 as number | undefined
191191
192192 const maybeSomeString = maybe ( sut )
193193 . map ( _str => getUserService < string > ( 'initial input mapped' ) )
@@ -211,7 +211,7 @@ describe('Maybe', () => {
211211 } )
212212
213213 it ( 'should handle input of ""' , ( ) => {
214- const sut : string | undefined = ''
214+ const sut = '' as string | undefined
215215
216216 const maybeSomeString = maybe ( sut )
217217 . map ( _str => getUserService < string > ( 'initial input mapped' ) )
@@ -237,8 +237,8 @@ describe('Maybe', () => {
237237
238238 describe ( 'when flatMapping' , ( ) => {
239239 it ( 'should handle "none" case' , ( ) => {
240- const sut : string | undefined = undefined
241- const nsut : number | undefined = undefined
240+ const sut = undefined as string | undefined
241+ const nsut = undefined as number | undefined
242242
243243 const maybeSomeNumber = maybe ( sut )
244244 . flatMap ( ( ) => maybe ( nsut ) )
@@ -248,8 +248,8 @@ describe('Maybe', () => {
248248 } )
249249
250250 it ( 'should handle "some" case' , ( ) => {
251- const sut : string | undefined = 'initial'
252- const nsut : number | undefined = 20
251+ const sut = 'initial' as string | undefined
252+ const nsut = 20 as number | undefined
253253
254254 const maybeSomeNumber = maybe ( sut )
255255 . flatMap ( ( ) => maybe ( nsut ) )
@@ -261,7 +261,7 @@ describe('Maybe', () => {
261261
262262 describe ( 'when getting monadic unit' , ( ) => {
263263 it ( 'should get value' , ( ) => {
264- const sut : string | undefined = undefined
264+ const sut = undefined as string | undefined
265265
266266 const maybeSomeNumber = maybe ( sut )
267267 . of ( 'ok' )
@@ -273,7 +273,7 @@ describe('Maybe', () => {
273273
274274 describe ( 'when tapSome' , ( ) => {
275275 it ( 'should work' , ( ) => {
276- const sut : string | undefined = 'abc'
276+ const sut = 'abc' as string | undefined
277277
278278 expect . assertions ( 1 )
279279 maybe ( sut ) . tapSome ( a => expect ( a ) . toEqual ( 'abc' ) )
@@ -283,7 +283,7 @@ describe('Maybe', () => {
283283
284284 describe ( 'when tapNone' , ( ) => {
285285 it ( 'should work' , ( ) => {
286- const sut : string | undefined = undefined
286+ const sut = undefined as string | undefined
287287
288288 expect . assertions ( 1 )
289289 maybe ( sut ) . tapNone ( ( ) => expect ( 1 ) . toEqual ( 1 ) )
0 commit comments