11const sinon = require ( 'sinon' ) ;
22const { expect } = require ( 'chai' ) ;
33const log = require ( 'loglevel' ) ;
4-
54const queue = require ( 'treetracker-wallet-app/packages/queue' ) ;
5+ const knex = require ( '../infra/database/knex' ) ;
6+ const QueueService = require ( './QueueService' ) ;
67
78describe ( 'QueueService' , ( ) => {
89 let publishStub ;
@@ -17,9 +18,6 @@ describe('QueueService', () => {
1718 sinon . restore ( ) ;
1819 } ) ;
1920
20- const queueService = require ( './QueueService' ) ;
21- const knex = require ( '../infra/database/knex' ) ;
22-
2321 describe ( 'sendWalletCreationNotification' , ( ) => {
2422 it ( 'should publish a wallet creation message to the queue' , async ( ) => {
2523 const wallet = {
@@ -28,7 +26,7 @@ describe('QueueService', () => {
2826 createdAt : '2025-04-29T00:00:00Z' ,
2927 } ;
3028
31- await queueService . sendWalletCreationNotification ( wallet ) ;
29+ await QueueService . sendWalletCreationNotification ( wallet ) ;
3230
3331 expect ( publishStub . calledOnce ) . to . be . true ;
3432 expect ( publishStub . firstCall . args [ 0 ] ) . to . deep . equal ( {
@@ -42,7 +40,7 @@ describe('QueueService', () => {
4240 } ) ;
4341 } ) ;
4442
45- it ( 'should not throw error if publish fails' , ( ) => {
43+ it ( 'should not throw error if publish fails' , async ( ) => {
4644 publishStub . throws ( new Error ( 'publish failed' ) ) ;
4745
4846 const wallet = {
@@ -53,7 +51,7 @@ describe('QueueService', () => {
5351
5452 let errorCaught = false ;
5553 try {
56- queueService . sendWalletCreationNotification ( wallet ) ;
54+ await QueueService . sendWalletCreationNotification ( wallet ) ;
5755 } catch ( err ) {
5856 errorCaught = true ;
5957 }
0 commit comments