"use strict";
var import_vitest = require("vitest");
var import_child_process = require("child_process");
var import_soundNotification = require("./soundNotification.js");
import_vitest.vi.mock("child_process", async (importOriginal) => {
  const actual = await importOriginal();
  return {
    ...actual,
    execFile: import_vitest.vi.fn((_file, _args, _options, callback) => {
      const cb = typeof _options === "function" ? _options : callback;
      if (cb) cb(null, "", "");
    })
  };
});
const mockedExecFile = import_vitest.vi.mocked(import_child_process.execFile);
const TEST_CONFIG = {
  enabled: true,
  onStartup: false,
  onApprovalRequired: true,
  onTaskComplete: true
};
(0, import_vitest.describe)("SoundNotificationService", () => {
  let originalStdoutWrite;
  let writeSpy;
  (0, import_vitest.beforeEach)(() => {
    originalStdoutWrite = process.stdout.write;
    writeSpy = import_vitest.vi.fn();
    process.stdout.write = writeSpy;
  });
  (0, import_vitest.afterEach)(() => {
    process.stdout.write = originalStdoutWrite;
  });
  (0, import_vitest.describe)("constructor", () => {
    (0, import_vitest.it)("should accept full config", () => {
      const service = new import_soundNotification.SoundNotificationService(TEST_CONFIG);
      (0, import_vitest.expect)(service.getConfig()).toEqual(TEST_CONFIG);
    });
    (0, import_vitest.it)("should allow disabling specific sounds", () => {
      const config = {
        enabled: true,
        onStartup: false,
        onApprovalRequired: false,
        onTaskComplete: true
      };
      const service = new import_soundNotification.SoundNotificationService(config);
      (0, import_vitest.expect)(service.getConfig()).toEqual(config);
    });
  });
  (0, import_vitest.describe)("setConfig", () => {
    (0, import_vitest.it)("should update config", () => {
      const service = new import_soundNotification.SoundNotificationService({ ...TEST_CONFIG, enabled: false });
      service.setConfig({ enabled: true });
      (0, import_vitest.expect)(service.getConfig().enabled).toBe(true);
    });
  });
  (0, import_vitest.describe)("playApprovalSound", () => {
    (0, import_vitest.it)("should not play when sounds disabled", () => {
      const service = new import_soundNotification.SoundNotificationService({ ...TEST_CONFIG, enabled: false });
      service.playApprovalSound();
      (0, import_vitest.expect)(writeSpy).not.toHaveBeenCalled();
    });
    (0, import_vitest.it)("should not play when approval sounds disabled", () => {
      const service = new import_soundNotification.SoundNotificationService({
        ...TEST_CONFIG,
        onApprovalRequired: false
      });
      service.playApprovalSound();
      (0, import_vitest.expect)(writeSpy).not.toHaveBeenCalled();
    });
    (0, import_vitest.it)("should attempt to play sound when enabled", () => {
      const service = new import_soundNotification.SoundNotificationService(TEST_CONFIG);
      mockedExecFile.mockClear();
      writeSpy.mockClear();
      service.playApprovalSound();
      const soundAttempted = mockedExecFile.mock.calls.length > 0 || writeSpy.mock.calls.length > 0;
      (0, import_vitest.expect)(soundAttempted).toBe(true);
    });
  });
  (0, import_vitest.describe)("playStartupSound", () => {
    (0, import_vitest.it)("should not play when startup sounds disabled", () => {
      const service = new import_soundNotification.SoundNotificationService({
        ...TEST_CONFIG,
        onStartup: false
      });
      mockedExecFile.mockClear();
      writeSpy.mockClear();
      service.playStartupSound();
      (0, import_vitest.expect)(writeSpy).not.toHaveBeenCalled();
      (0, import_vitest.expect)(mockedExecFile).not.toHaveBeenCalled();
    });
    (0, import_vitest.it)("should attempt to play sound when enabled", () => {
      const service = new import_soundNotification.SoundNotificationService({
        ...TEST_CONFIG,
        onStartup: true
      });
      mockedExecFile.mockClear();
      writeSpy.mockClear();
      service.playStartupSound();
      const soundAttempted = mockedExecFile.mock.calls.length > 0 || writeSpy.mock.calls.length > 0;
      (0, import_vitest.expect)(soundAttempted).toBe(true);
    });
  });
  (0, import_vitest.describe)("playCompleteSound", () => {
    (0, import_vitest.it)("should not play when sounds disabled", () => {
      const service = new import_soundNotification.SoundNotificationService({ ...TEST_CONFIG, enabled: false });
      service.playCompleteSound();
      (0, import_vitest.expect)(writeSpy).not.toHaveBeenCalled();
    });
    (0, import_vitest.it)("should not play when complete sounds disabled", () => {
      const service = new import_soundNotification.SoundNotificationService({
        ...TEST_CONFIG,
        onTaskComplete: false
      });
      service.playCompleteSound();
      (0, import_vitest.expect)(writeSpy).not.toHaveBeenCalled();
    });
    (0, import_vitest.it)("should attempt to play sound when enabled", () => {
      const service = new import_soundNotification.SoundNotificationService(TEST_CONFIG);
      mockedExecFile.mockClear();
      writeSpy.mockClear();
      service.playCompleteSound();
      const soundAttempted = mockedExecFile.mock.calls.length > 0 || writeSpy.mock.calls.length > 0;
      (0, import_vitest.expect)(soundAttempted).toBe(true);
    });
  });
});
