From 7460cfe590313a32cf5d0e452231f87ee311a9d4 Mon Sep 17 00:00:00 2001 From: Quentin Date: Sun, 22 Sep 2024 15:33:44 +0200 Subject: [PATCH] Generator: add missing test --- .../RestManagementRepository.spec.ts | 34 +++++++++++++++++++ vitest.config.ts | 1 - 2 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 src/test/webapp/unit/module/secondary/RestManagementRepository.spec.ts diff --git a/src/test/webapp/unit/module/secondary/RestManagementRepository.spec.ts b/src/test/webapp/unit/module/secondary/RestManagementRepository.spec.ts new file mode 100644 index 00000000000..9ea2b88176a --- /dev/null +++ b/src/test/webapp/unit/module/secondary/RestManagementRepository.spec.ts @@ -0,0 +1,34 @@ +import { dataBackendResponse, stubAxiosHttp } from '../../http/AxiosHttpStub'; +import { describe, expect, it } from 'vitest'; +import { RestManagementRepository } from '@/module/secondary/RestManagementRepository'; +import { ManagementInfo } from '@/module/domain/ManagementInfo'; + +describe('Rest management repository', () => { + it('should get info using axios', async () => { + const axiosInstance = stubAxiosHttp(); + const repository = new RestManagementRepository(axiosInstance); + axiosInstance.get.resolves(dataBackendResponse(restManagementInfo())); + + const managementInfo = await repository.getInfo(); + + expect(managementInfo).toEqual(info); + }); +}); + +const info = { + git: { + commit: { + id: { + describe: 'feat(rest): add management info', + abbrev: 'b3f4', + }, + }, + branch: 'main', + build: { + version: '1.2.3', + time: '19:00', + }, + }, +}; + +const restManagementInfo = (): ManagementInfo => info; diff --git a/vitest.config.ts b/vitest.config.ts index fa16dbb0df7..adeb516f287 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -46,7 +46,6 @@ export default defineConfig({ 'src/main/webapp/app/router/index.ts', 'src/main/webapp/app/**/application/*Provider.ts', 'src/main/webapp/app/shared/alert/infrastructure/primary/WindowApplicationListener.ts', - 'src/main/webapp/app/module/secondary/RestManagementRepository.ts', 'src/main/webapp/app/injections.ts', '**/*.d.ts', 'src/test/**/*',