Skip to content

Commit

Permalink
Merge pull request #10949 from qmonmert/addmissingtest2
Browse files Browse the repository at this point in the history
Generator: add missing test for WindowApplicationListener
  • Loading branch information
pascalgrimaud authored Oct 11, 2024
2 parents 44a9905 + f3beaec commit dda58ab
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -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);
});
});
1 change: 0 additions & 1 deletion vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit dda58ab

Please sign in to comment.