From f3beaec082cddcf5ec538c363a36a04622863a0e Mon Sep 17 00:00:00 2001 From: Quentin Date: Sun, 22 Sep 2024 16:30:21 +0200 Subject: [PATCH] Generator: add missing test --- .../primary/WindowApplicationListener.spec.ts | 24 +++++++++++++++++++ vitest.config.ts | 1 - 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 src/test/webapp/unit/shared/alert/infrastructure/primary/WindowApplicationListener.spec.ts diff --git a/src/test/webapp/unit/shared/alert/infrastructure/primary/WindowApplicationListener.spec.ts b/src/test/webapp/unit/shared/alert/infrastructure/primary/WindowApplicationListener.spec.ts new file mode 100644 index 00000000000..0e9d44bff3b --- /dev/null +++ b/src/test/webapp/unit/shared/alert/infrastructure/primary/WindowApplicationListener.spec.ts @@ -0,0 +1,24 @@ +import { WindowApplicationListener } from '@/shared/alert/infrastructure/primary/WindowApplicationListener'; +import { describe, it, expect, vi } from 'vitest'; + +describe('WindowApplicationListener', () => { + it('should add event listener on window', () => { + vi.spyOn(window, 'addEventListener').mockImplementation(() => {}); + + const windowApplicationListener = new WindowApplicationListener(window); + + windowApplicationListener.addEventListener('success', () => {}); + + expect(window.addEventListener).toHaveBeenCalledTimes(1); + }); + + it('should remove event listener on window', () => { + vi.spyOn(window, 'removeEventListener').mockImplementation(() => {}); + + const windowApplicationListener = new WindowApplicationListener(window); + + windowApplicationListener.removeEventListener('success', () => {}); + + expect(window.removeEventListener).toHaveBeenCalledTimes(1); + }); +}); diff --git a/vitest.config.ts b/vitest.config.ts index fa16dbb0df7..5711a1c1e1a 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/shared/alert/infrastructure/primary/WindowApplicationListener.ts', 'src/main/webapp/app/module/secondary/RestManagementRepository.ts', 'src/main/webapp/app/injections.ts', '**/*.d.ts',