@@ -3,6 +3,7 @@ import { describe, it, expect, beforeEach, afterEach } from 'vitest';
33import { Entity , PrimaryKey , Property , MikroORM } from '@mikro-orm/core' ;
44import {
55 TransactionalEventEmitter ,
6+ TransactionalEventEmitterOperations ,
67 InboxOutboxEvent ,
78 IListener ,
89} from '@nestixis/nestjs-inbox-outbox' ;
@@ -95,7 +96,7 @@ describe('Integration Tests', () => {
9596
9697 const event = new UserCreatedEvent ( 1 , 'test@example.com' ) ;
9798
98- await emitter . emitAsync ( event , [ { operation : ' persist' as const , entity : user } ] ) ;
99+ await emitter . emitAsync ( event , [ { operation : TransactionalEventEmitterOperations . persist , entity : user } ] ) ;
99100
100101 const em = orm . em . fork ( ) ;
101102 const users = await em . find ( User , { } ) ;
@@ -129,7 +130,7 @@ describe('Integration Tests', () => {
129130
130131 const event = new UserCreatedEvent ( 2 , 'atomic@example.com' ) ;
131132
132- await emitter . emitAsync ( event , [ { operation : ' persist' as const , entity : user } ] ) ;
133+ await emitter . emitAsync ( event , [ { operation : TransactionalEventEmitterOperations . persist , entity : user } ] ) ;
133134
134135 const em = orm . em . fork ( ) ;
135136 const users = await em . find ( User , { email : 'atomic@example.com' } ) ;
@@ -153,8 +154,8 @@ describe('Integration Tests', () => {
153154 const event = new UserCreatedEvent ( 1 , 'user1@example.com' ) ;
154155
155156 await emitter . emit ( event , [
156- { operation : ' persist' as const , entity : user1 } ,
157- { operation : ' persist' as const , entity : user2 } ,
157+ { operation : TransactionalEventEmitterOperations . persist , entity : user1 } ,
158+ { operation : TransactionalEventEmitterOperations . persist , entity : user2 } ,
158159 ] ) ;
159160
160161 await new Promise ( resolve => setTimeout ( resolve , 100 ) ) ;
@@ -193,7 +194,7 @@ describe('Integration Tests', () => {
193194 const userToDelete = await checkEm . findOne ( User , { id : userId } ) ;
194195
195196 const event = new UserDeletedEvent ( userId ) ;
196- await emitter . emitAsync ( event , [ { operation : ' remove' as const , entity : userToDelete ! } ] ) ;
197+ await emitter . emitAsync ( event , [ { operation : TransactionalEventEmitterOperations . remove , entity : userToDelete ! } ] ) ;
197198
198199 const finalEm = orm . em . fork ( ) ;
199200 const deletedUser = await finalEm . findOne ( User , { id : userId } ) ;
@@ -232,7 +233,7 @@ describe('Integration Tests', () => {
232233
233234 const event = new UserCreatedEvent ( 1 , 'listener@example.com' ) ;
234235
235- await emitter . emitAsync ( event , [ { operation : ' persist' as const , entity : user } ] ) ;
236+ await emitter . emitAsync ( event , [ { operation : TransactionalEventEmitterOperations . persist , entity : user } ] ) ;
236237
237238 expect ( handledEvents ) . toHaveLength ( 1 ) ;
238239 expect ( handledEvents [ 0 ] . email ) . toBe ( 'listener@example.com' ) ;
@@ -303,7 +304,7 @@ describe('Integration Tests', () => {
303304
304305 const event = new UserCreatedEvent ( 1 , 'multi@example.com' ) ;
305306
306- await emitter . emitAsync ( event , [ { operation : ' persist' as const , entity : user } ] ) ;
307+ await emitter . emitAsync ( event , [ { operation : TransactionalEventEmitterOperations . persist , entity : user } ] ) ;
307308
308309 expect ( results ) . toContain ( 'listener1' ) ;
309310 expect ( results ) . toContain ( 'listener2' ) ;
@@ -374,7 +375,7 @@ describe('Integration Tests', () => {
374375 const beforeEmit = Date . now ( ) ;
375376 const event = new UserCreatedEvent ( 1 , 'retry@example.com' ) ;
376377
377- await emitter . emitAsync ( event , [ { operation : ' persist' as const , entity : user } ] ) ;
378+ await emitter . emitAsync ( event , [ { operation : TransactionalEventEmitterOperations . persist , entity : user } ] ) ;
378379
379380 const em = orm . em . fork ( ) ;
380381 const transportEvents = await em . find ( MikroOrmInboxOutboxTransportEvent , { eventName : 'UserCreated' } ) ;
@@ -402,7 +403,7 @@ describe('Integration Tests', () => {
402403 const beforeEmit = Date . now ( ) ;
403404 const event = new UserCreatedEvent ( 1 , 'expire@example.com' ) ;
404405
405- await emitter . emitAsync ( event , [ { operation : ' persist' as const , entity : user } ] ) ;
406+ await emitter . emitAsync ( event , [ { operation : TransactionalEventEmitterOperations . persist , entity : user } ] ) ;
406407
407408 const em = orm . em . fork ( ) ;
408409 const transportEvents = await em . find ( MikroOrmInboxOutboxTransportEvent , { eventName : 'UserCreated' } ) ;
0 commit comments