@@ -124,6 +124,7 @@ describe('Task', () => {
124124 ) ;
125125
126126 } ) ;
127+
127128 it ( 'Should work with rejected promises' , ( cb ) => {
128129 // GIVEN: A task created from a rejected promise
129130 const resolved = Task . fromPromise ( Promise . reject ( 'buu' ) ) ;
@@ -134,6 +135,32 @@ describe('Task', () => {
134135 jestAssertNever ( cb )
135136 ) ;
136137 } ) ;
138+
139+ it ( 'Should mantain any error when changed' , ( cb ) => {
140+ // GIVEN: A task created from a rejected promise
141+ const task = Task . fromPromise ( Promise . reject ( 'buu' ) ) ;
142+
143+ // WHEN: we chain it with some value
144+ const result = task . chain ( _ => Task . resolve ( 0 ) ) ;
145+ // THEN: the task type should be Task<number, any> (check manually?)
146+
147+ // and the error should be the same
148+ result . fork (
149+ assertFork ( cb , x => expect ( x ) . toBe ( 'buu' ) ) ,
150+ jestAssertUntypedNeverCalled ( cb )
151+ ) ;
152+ } ) ;
153+
154+ it ( 'Should be able to set rejected type' , ( cb ) => {
155+ // GIVEN: A task created from a rejected promise
156+ const resolved = Task . fromPromise < never , string > ( Promise . reject ( 'buu' ) ) ;
157+
158+ // WHEN: we fork, THEN: it should call the error function with the rejected value
159+ resolved . fork (
160+ assertFork ( cb , x => expect ( x ) . toBe ( 'buu' ) ) ,
161+ jestAssertNever ( cb )
162+ ) ;
163+ } ) ;
137164 } ) ;
138165 describe ( 'chain' , ( ) => {
139166 it ( 'Should handle functions that succeed' , ( cb ) => {
0 commit comments