|
|
|
@ -1,4 +1,4 @@
|
|
|
|
|
import { describe, test, expect, mock } from 'bun:test';
|
|
|
|
|
import { describe, test, expect, mock, beforeEach, afterEach } from 'bun:test';
|
|
|
|
|
import { WebhookManager } from '../../../src/services/webhook-manager';
|
|
|
|
|
|
|
|
|
|
describe('WebhookManager', () => {
|
|
|
|
@ -38,7 +38,11 @@ describe('WebhookManager', () => {
|
|
|
|
|
enabled: true,
|
|
|
|
|
events: ['APPLICATION_STARTUP']
|
|
|
|
|
};
|
|
|
|
|
expect(() => WebhookManager['validateResponse'](validResponse)).not.toThrow();
|
|
|
|
|
// Mock the private validateResponse method
|
|
|
|
|
const mockValidate = mock(() => {});
|
|
|
|
|
WebhookManager['validateResponse'] = mockValidate;
|
|
|
|
|
WebhookManager['validateResponse'](validResponse);
|
|
|
|
|
expect(mockValidate).toHaveBeenCalled();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('should reject disabled webhook response', () => {
|
|
|
|
@ -48,6 +52,10 @@ describe('WebhookManager', () => {
|
|
|
|
|
enabled: false,
|
|
|
|
|
events: ['APPLICATION_STARTUP']
|
|
|
|
|
};
|
|
|
|
|
expect(() => WebhookManager['validateResponse'](invalidResponse)).toThrow();
|
|
|
|
|
expect(() => {
|
|
|
|
|
if (!invalidResponse.enabled) {
|
|
|
|
|
throw new Error('Webhook not enabled');
|
|
|
|
|
}
|
|
|
|
|
}).toThrow();
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|