import { {{ className }}, Consumer } from '@/application/events' import { ServerError } from '@/application/errors' import { v4 as uuidv4 } from 'uuid' describe('{{ className }}', () => { let sut: {{ className }} let sutCoreDestroyTenantData: jest.Mock let mockInput: { name: 'a' } beforeAll(() => { mockInput = { tenantId: uuidv4().toString() } sutCoreDestroyTenantData = jest.fn() sutCoreDestroyTenantData.mockResolvedValue({ success: true }) }) beforeEach(() => { sut = new {{ className }}(sutCoreDestroyTenantData) }) it('should extend Consumer', async () => { expect(sut).toBeInstanceOf(Consumer) }) it('should build Validators correctly', async () => { const validators = sut.buildValidators() expect(validators).toEqual([ ]) }) it('should call with correct input', async () => { await sut.handle(mockInput) expect(sutCoreDestroyTenantData).toHaveBeenCalledWith() expect(sutCoreDestroyTenantData).toHaveBeenCalledTimes(1) }) it('should return 200 if authentication succeeds', async () => { const httpResponse = await sut.handle(mockInput) expect(httpResponse).toEqual({ data: { success: true } }) }) it('should return 500 on infra error', async () => { const error = new Error('infra_error') sutCoreDestroyTenantData.mockRejectedValueOnce(error) const httpResponse = await sut.handle(mockInput) expect(httpResponse).toEqual({ data: new ServerError(error) }) }) })