diff --git a/app/main.js b/app/main.js index 6c2dee263..ebf513d20 100644 --- a/app/main.js +++ b/app/main.js @@ -274,7 +274,7 @@ async function initialize (isAppStart = true) { app }) - displayManager = new DisplayManager(settings, log) + displayManager = new DisplayManager(settings) startI18next() startProcessWin() diff --git a/app/utils/displayManager.js b/app/utils/displayManager.js index 52105b5a6..842586dd0 100644 --- a/app/utils/displayManager.js +++ b/app/utils/displayManager.js @@ -1,9 +1,9 @@ import { screen } from 'electron' +import log from 'electron-log/main.js' class DisplayManager { - constructor (settings, log) { + constructor (settings) { this.settings = settings - this.log = log } getDisplayCount () { @@ -34,7 +34,7 @@ class DisplayManager { if (displayID === -1) { targetScreen = screen.getDisplayNearestPoint(screen.getCursorScreenPoint()) } else if (displayID >= this.getDisplayCount() || displayID < 0) { - this.log.warn(`Stretchly: invalid displayID ${displayID}, falling back to cursor display`) + log.warn(`Stretchly: invalid displayID ${displayID}, falling back to cursor display`) targetScreen = screen.getDisplayNearestPoint(screen.getCursorScreenPoint()) } else { const screens = screen.getAllDisplays() diff --git a/test/displayManager.js b/test/displayManager.js index 08e9b3bca..98d5c091d 100644 --- a/test/displayManager.js +++ b/test/displayManager.js @@ -19,16 +19,12 @@ vi.mock('electron', () => { describe('DisplayManager', function () { let displayManager let mockSettings - let mockLog beforeEach(function () { vi.clearAllMocks() mockSettings = { get: vi.fn() } - mockLog = { - warn: vi.fn() - } }) describe('Mathematical Calculations', function () { @@ -37,7 +33,7 @@ describe('DisplayManager', function () { if (key === 'allScreens') return true return null }) - displayManager = new DisplayManager(mockSettings, mockLog) + displayManager = new DisplayManager(mockSettings) }) it('centers window horizontally correctly', function () { @@ -94,7 +90,7 @@ describe('DisplayManager', function () { if (key === 'allScreens') return true return null }) - displayManager = new DisplayManager(mockSettings, mockLog) + displayManager = new DisplayManager(mockSettings) }) it('getWindowPosition returns consistent windowed positioning', function () { @@ -163,7 +159,7 @@ describe('DisplayManager', function () { describe('Settings Integration', function () { beforeEach(function () { - displayManager = new DisplayManager(mockSettings, mockLog) + displayManager = new DisplayManager(mockSettings) }) it('uses cursor position when allScreens is true', function () { @@ -213,12 +209,11 @@ describe('DisplayManager', function () { if (key === 'allScreens') return true return null }) - displayManager = new DisplayManager(mockSettings, mockLog) + displayManager = new DisplayManager(mockSettings) }) - it('handles invalid displayID by falling back and logging a warning', () => { + it('handles invalid displayID by falling back to cursor display', () => { const target = displayManager.getTargetDisplay(5) - expect(mockLog.warn).toHaveBeenCalledWith('Stretchly: invalid displayID 5, falling back to cursor display') expect(screen.getDisplayNearestPoint).toHaveBeenCalled() target.id.should.equal(0) })