From d9d96acfe5fbff42b9eaa0306bd11fafffc0615f Mon Sep 17 00:00:00 2001 From: Quentin Date: Mon, 23 Sep 2024 21:56:07 +0200 Subject: [PATCH] Clean tests --- .../primary/landscape/LandscapeComponent.spec.ts | 10 +++------- .../LandscapePresetConfigurationComponent.spec.ts | 2 +- .../modules-patch/ModulesPatchComponent.spec.ts | 6 +----- 3 files changed, 5 insertions(+), 13 deletions(-) diff --git a/src/test/webapp/unit/module/primary/landscape/LandscapeComponent.spec.ts b/src/test/webapp/unit/module/primary/landscape/LandscapeComponent.spec.ts index 18e35eb3aca..58397499c0d 100644 --- a/src/test/webapp/unit/module/primary/landscape/LandscapeComponent.spec.ts +++ b/src/test/webapp/unit/module/primary/landscape/LandscapeComponent.spec.ts @@ -10,7 +10,7 @@ import { defaultLandscape } from '../../domain/landscape/Landscape.fixture'; import { defaultPresets, ModulesRepositoryStub, projectHistoryWithInit, stubModulesRepository } from '../../domain/Modules.fixture'; import { ProjectFoldersRepositoryStub, stubProjectFoldersRepository } from '../../domain/ProjectFolders.fixture'; import { ModuleParametersRepositoryStub, stubModuleParametersRepository } from '../../domain/ModuleParameters.fixture'; -import { beforeAll, beforeEach, describe, expect, it, vi } from 'vitest'; +import { beforeEach, describe, expect, it, vi } from 'vitest'; import { BodyCursorUpdater } from '@/module/primary/landscape/BodyCursorUpdater'; import { LandscapeScroller } from '@/module/primary/landscape/LandscapeScroller'; import { ModuleParametersRepository } from '@/module/domain/ModuleParametersRepository'; @@ -136,10 +136,6 @@ const repositoryWithModuleParameters = (): ModuleParametersRepositoryStub => { }; describe('Landscape', () => { - beforeAll(() => { - vi.spyOn(console, 'error').mockImplementation(() => {}); - }); - describe('Loading', () => { it('should display loader when loading landscape', () => { const wrapper = wrap(); @@ -739,7 +735,7 @@ describe('Landscape', () => { const wrapper = wrap({ modules }); await flushPromises(); - const consoleErrors = vi.spyOn(console, 'error').mockImplementation(() => {}); + const consoleErrors = vi.spyOn(console, 'error'); await updatePath(wrapper); expect(console.error).toHaveBeenCalledTimes(0); @@ -981,7 +977,7 @@ describe('Landscape', () => { it('should call blur if input field has focus and click on a module', async () => { const wrapper = await componentWithLandscape(); - vi.spyOn(wrapper.find(wrappedElement('folder-path-field')).element as HTMLElement, 'blur').mockImplementation(() => {}); + vi.spyOn(wrapper.find(wrappedElement('folder-path-field')).element as HTMLElement, 'blur'); Object.defineProperty(document, 'activeElement', { value: wrapper.find(wrappedElement('folder-path-field')).element as HTMLElement, diff --git a/src/test/webapp/unit/module/primary/landscape/LandscapePresetConfigurationComponent.spec.ts b/src/test/webapp/unit/module/primary/landscape/LandscapePresetConfigurationComponent.spec.ts index c66c62a429d..d9b63f82c6a 100644 --- a/src/test/webapp/unit/module/primary/landscape/LandscapePresetConfigurationComponent.spec.ts +++ b/src/test/webapp/unit/module/primary/landscape/LandscapePresetConfigurationComponent.spec.ts @@ -44,7 +44,7 @@ describe('LandscapePresetConfigurationComponent', () => { }); it('should handle API error', async () => { - vi.spyOn(console, 'error').mockImplementation(() => {}); + vi.spyOn(console, 'error'); const error = new Error('API Error'); const modulesRepository = repositoryWithPresetError(error); const wrapper = wrap(modulesRepository); diff --git a/src/test/webapp/unit/module/primary/modules-patch/ModulesPatchComponent.spec.ts b/src/test/webapp/unit/module/primary/modules-patch/ModulesPatchComponent.spec.ts index f540953d19e..a0bf6e92e62 100644 --- a/src/test/webapp/unit/module/primary/modules-patch/ModulesPatchComponent.spec.ts +++ b/src/test/webapp/unit/module/primary/modules-patch/ModulesPatchComponent.spec.ts @@ -14,7 +14,7 @@ import { stubAlertBus } from '../../../shared/alert/domain/AlertBus.fixture'; import { ProjectFoldersRepository } from '@/module/domain/ProjectFoldersRepository'; import { ProjectFoldersRepositoryStub, stubProjectFoldersRepository } from '../../domain/ProjectFolders.fixture'; import { ModuleParametersRepositoryStub, stubModuleParametersRepository } from '../../domain/ModuleParameters.fixture'; -import { beforeAll, describe, expect, it, vi } from 'vitest'; +import { describe, expect, it } from 'vitest'; import { Modules } from '@/module/domain/Modules'; import { Module } from '@/module/domain/Module'; import { ModuleParametersRepository } from '@/module/domain/ModuleParametersRepository'; @@ -56,10 +56,6 @@ const makeTaggedModule = (tag: string): Module => ({ }); describe('Modules', () => { - beforeAll(() => { - vi.spyOn(console, 'error').mockImplementation(() => {}); - }); - describe('Loading', () => { it('should display loader when waiting for modules', () => { const wrapper = wrap();