-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathmapFailureAsync.spec.ts
More file actions
32 lines (25 loc) · 851 Bytes
/
Copy pathmapFailureAsync.spec.ts
File metadata and controls
32 lines (25 loc) · 851 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import { Result } from '@/src/result';
describe('Result', () => {
describe('mapFailureAsync', () => {
test('will not execute the projection with a successful Result', async () => {
const sut = Result.success(1);
const innerResult = await sut
.mapFailureAsync((_error) => Promise.resolve(2))
.toPromise();
expect(innerResult).toSucceedWith(1);
});
test('will execute the projection with a failed Result', async () => {
const error = 'error';
let wasCalled = false;
const sut = Result.failure<number>(error);
const innerResult = await sut
.mapFailureAsync((_error) => {
wasCalled = true;
return Promise.resolve(2);
})
.toPromise();
expect(innerResult).toSucceedWith(2);
expect(wasCalled).toBe(true);
});
});
});