From d6f2ae8dd2babe8ac463a6d26118db33fd34cbcc 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..6a88c0a732c --- /dev/null +++ b/src/test/webapp/unit/module/secondary/RestManagementRepository.spec.ts @@ -0,0 +1,34 @@ +import { ManagementInfo } from '@/module/domain/ManagementInfo'; +import { RestManagementRepository } from '@/module/secondary/RestManagementRepository'; +import { describe, expect, it } from 'vitest'; +import { dataBackendResponse, stubAxiosHttp } from '../../http/AxiosHttpStub'; + +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 8cbf4ba1f59..39412430bf5 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -45,7 +45,6 @@ export default defineConfig({ 'src/main/webapp/app/main.ts', 'src/main/webapp/app/router/index.ts', 'src/main/webapp/app/**/application/*Provider.ts', - 'src/main/webapp/app/module/secondary/RestManagementRepository.ts', 'src/main/webapp/app/injections.ts', '**/*.d.ts', 'src/test/**/*',