import { AxiosError} from 'axios'; import { expect } from 'chai'; import CODE_MESSAGES from '../src/constants/codeMessages'; import HTTP_STATUS_CODE from '../src/constants/httpStatusCode'; import AuthError from '../src/exceptions/authError'; import BusinessError from '../src/exceptions/businessError'; describe('Tests suite - Errors classes.', () => { it('SUCCESS: Create BusinessError.', async () => { const business_exception = new BusinessError(CODE_MESSAGES.ERROR_REQUEST); expect(business_exception.message).to.equal(CODE_MESSAGES.ERROR_REQUEST.message); }); it('SUCCESS: Create BusinessError name.', async () => { const business_exception = new BusinessError(CODE_MESSAGES.SUCCESS_REQUEST); expect(business_exception.name).to.equal('BusinessError'); }); it('SUCCESS: Create BusinessError code.', async () => { const business_exception = new BusinessError(CODE_MESSAGES.ERROR_REQUEST); expect(business_exception.code).to.equal('4000'); }); it('SUCCESS: Create AuthError.', async () => { const auth_exception = new AuthError({ response: { status: HTTP_STATUS_CODE.BAD_REQUEST } } as unknown as AxiosError); expect(auth_exception.message).to.equal('internal server error'); }); });