@@ -119,4 +119,67 @@ describe(either.name, () => {
119119
120120 expect ( mapped ) . toEqual ( 3 )
121121 } )
122+
123+ it ( 'should tap left' , ( ) => {
124+ expect . assertions ( 6 )
125+
126+ const input1 = 123
127+ const input2 : number | undefined = undefined
128+
129+ const eitherThing = either ( input1 , input2 )
130+
131+ const mapped1 = eitherThing
132+ . tap ( {
133+ right : _rightSideEffect => fail ( ) ,
134+ left : leftSideEffect => {
135+ expect ( leftSideEffect ) . toEqual ( 123 )
136+ }
137+ } )
138+
139+ const mapped2 = eitherThing
140+ . tap ( {
141+ left : leftSideEffect => expect ( leftSideEffect ) . toEqual ( 123 )
142+ } )
143+ const mapped3 = eitherThing
144+ . tap ( {
145+ right : _rightSideEffect => fail ( )
146+ } )
147+
148+ const mapped4 = eitherThing . tap ( { } )
149+
150+ expect ( mapped1 ) . toEqual ( undefined )
151+ expect ( mapped2 ) . toEqual ( undefined )
152+ expect ( mapped3 ) . toEqual ( undefined )
153+ expect ( mapped4 ) . toEqual ( undefined )
154+ } )
155+
156+ it ( 'should tap right' , ( ) => {
157+ expect . assertions ( 6 )
158+
159+ const input1 = undefined
160+ const input2 : number | undefined = 123
161+
162+ const eitherThing = either ( input1 , input2 )
163+
164+ const mapped1 = eitherThing
165+ . tap ( {
166+ left : _leftSideEffect => fail ( ) ,
167+ right : rightSideEffect => expect ( rightSideEffect ) . toEqual ( 123 )
168+ } )
169+
170+ const mapped2 = eitherThing
171+ . tap ( {
172+ left : _leftSideEffect => fail ( )
173+ } )
174+ const mapped3 = eitherThing
175+ . tap ( {
176+ right : rightSideEffect => expect ( rightSideEffect ) . toEqual ( 123 )
177+ } )
178+ const mapped4 = eitherThing . tap ( { } )
179+
180+ expect ( mapped1 ) . toEqual ( undefined )
181+ expect ( mapped2 ) . toEqual ( undefined )
182+ expect ( mapped3 ) . toEqual ( undefined )
183+ expect ( mapped4 ) . toEqual ( undefined )
184+ } )
122185} )
0 commit comments