Fixed auditlogs tests making waitinf for the emit

This commit is contained in:
Fernando Chavez 2022-12-13 10:46:11 +01:00
parent 6af468be37
commit fd0c592c0b
2 changed files with 4 additions and 5 deletions

View File

@ -4,7 +4,6 @@ const { features } = require('@strapi/strapi/lib/utils/ee');
const executeCEDestroy = require('../../server/destroy');
module.exports = async ({ strapi }) => {
console.log('destroy lifecycle');
if (features.isEnabled('audit-logs')) {
strapi.container.get('audit-logs').destroy();
}

View File

@ -84,10 +84,10 @@ describe('Audit logs auth', () => {
const eventName = 'test';
const eventPayload = { meta: 'test' };
strapi.eventHub.emit(eventName, eventPayload);
await strapi.eventHub.emit(eventName, eventPayload);
// TODO: Replace with a test to save to db
expect(logSpy).toHaveBeenCalledWith(
`Listened to event ${eventName} with args: ${JSON.stringify(eventPayload)}`
`Listened to event ${eventName} with args: [${JSON.stringify(eventPayload)}]`
);
});
@ -96,8 +96,8 @@ describe('Audit logs auth', () => {
auditLogsService.register();
expect(() => {
strapi.eventHub.emit('', { meta: 'test' });
}).toThrowError('Name is required');
return strapi.eventHub.emit('', { meta: 'test' });
}).rejects.toThrowError('Name is required');
});
});
});