1
1
import {
2
+ assertEqual ,
3
+ assertFails ,
2
4
assertMatches ,
5
+ assertOk ,
3
6
getInMemoryEventStore ,
4
7
type EventStore ,
5
8
} from '@event-driven-io/emmett' ;
6
9
import { type FastifyInstance } from 'fastify' ;
7
- import assert from 'node:assert/strict' ;
8
10
import { randomUUID } from 'node:crypto' ;
9
11
import { beforeEach , describe , it } from 'node:test' ;
10
12
import { getApplication } from '../..' ;
@@ -34,9 +36,9 @@ void describe('Application logic with optimistic concurrency using Fastify', ()
34
36
35
37
const current = createResponse . json < { id : string } > ( ) ;
36
38
if ( ! current ?. id ) {
37
- assert . fail ( ) ;
39
+ assertFails ( ) ;
38
40
}
39
- assert . ok ( current . id ) ;
41
+ assertOk ( current . id ) ;
40
42
41
43
const shoppingCartId = current . id ;
42
44
///////////////////////////////////////////////////
@@ -51,7 +53,7 @@ void describe('Application logic with optimistic concurrency using Fastify', ()
51
53
url : `/clients/${ clientId } /shopping-carts/${ shoppingCartId } /product-items` ,
52
54
body : twoPairsOfShoes ,
53
55
} ) ;
54
- assert . equal ( response . statusCode , 204 ) ;
56
+ assertEqual ( response . statusCode , 204 ) ;
55
57
56
58
///////////////////////////////////////////////////
57
59
// 3. Add T-Shirt
@@ -67,7 +69,7 @@ void describe('Application logic with optimistic concurrency using Fastify', ()
67
69
body : tShirt ,
68
70
} ) ;
69
71
70
- assert . equal ( response . statusCode , 204 ) ;
72
+ assertEqual ( response . statusCode , 204 ) ;
71
73
72
74
///////////////////////////////////////////////////
73
75
// 4. Remove pair of shoes
@@ -82,7 +84,7 @@ void describe('Application logic with optimistic concurrency using Fastify', ()
82
84
method : 'DELETE' ,
83
85
url : `/clients/${ clientId } /shopping-carts/${ shoppingCartId } /product-items?productId=${ pairOfShoes . productId } &quantity=${ pairOfShoes . quantity } &unitPrice=${ pairOfShoes . unitPrice } ` ,
84
86
} ) ;
85
- assert . equal ( response . statusCode , 204 ) ;
87
+ assertEqual ( response . statusCode , 204 ) ;
86
88
87
89
///////////////////////////////////////////////////
88
90
// 5. Confirm cart
@@ -93,7 +95,7 @@ void describe('Application logic with optimistic concurrency using Fastify', ()
93
95
url : `/clients/${ clientId } /shopping-carts/${ shoppingCartId } /confirm` ,
94
96
} ) ;
95
97
96
- assert . equal ( response . statusCode , 204 ) ;
98
+ assertEqual ( response . statusCode , 204 ) ;
97
99
98
100
///////////////////////////////////////////////////
99
101
// 6. Try Cancel Cart
@@ -103,15 +105,15 @@ void describe('Application logic with optimistic concurrency using Fastify', ()
103
105
url : `/clients/${ clientId } /shopping-carts/${ shoppingCartId } ` ,
104
106
} ) ;
105
107
106
- assert . equal ( response . statusCode , 403 ) ;
108
+ assertEqual ( response . statusCode , 403 ) ;
107
109
assertMatches ( response . json ( ) , {
108
110
detail : ShoppingCartErrors . CART_IS_ALREADY_CLOSED ,
109
111
} ) ;
110
112
const result =
111
113
await eventStore . readStream < ShoppingCartEvent > ( shoppingCartId ) ;
112
114
113
- assert . ok ( result ) ;
114
- assert . equal ( result . events . length , Number ( 5 ) ) ;
115
+ assertOk ( result ) ;
116
+ assertEqual ( result . events . length , Number ( 5 ) ) ;
115
117
116
118
assertMatches ( result ?. events , [
117
119
{
0 commit comments