From f4d0478b4b2000d144b632b74e0da3aa898356a5 Mon Sep 17 00:00:00 2001 From: Ferdinand Thiessen Date: Tue, 11 Mar 2025 13:22:12 +0100 Subject: [PATCH] test(files_trashbin): add test coverage also for utils like the logger Signed-off-by: Ferdinand Thiessen --- apps/files_trashbin/src/logger.spec.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 apps/files_trashbin/src/logger.spec.ts diff --git a/apps/files_trashbin/src/logger.spec.ts b/apps/files_trashbin/src/logger.spec.ts new file mode 100644 index 00000000000..5558419ba9d --- /dev/null +++ b/apps/files_trashbin/src/logger.spec.ts @@ -0,0 +1,20 @@ +/** + * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ + +import { describe, expect, it, vi } from 'vitest' +import { logger } from './logger.ts' + +describe('files_trashbin: logger', () => { + // Rest of the logger is not under our responsibility but nextcloud-logger + it('has correct app name set up', () => { + const consoleSpy = vi.spyOn(globalThis.console, 'error').mockImplementationOnce(() => {}) + + logger.error('') + expect(consoleSpy).toBeCalledTimes(1) + expect(consoleSpy.mock.calls[0][0]).toContain('') + expect(consoleSpy.mock.calls[0][0]).toContain('files_trashbin') + expect(consoleSpy.mock.calls[0][1].app).toBe('files_trashbin') + }) +})