Files
clipbored/tests/clipboredtests/OnboardingWindowControllerTests.swift
Akshay Kolli d86d392c3a
Some checks failed
CI / Test And Build (push) Has been cancelled
UI fixes
2026-07-08 01:13:02 -04:00

76 lines
2.2 KiB
Swift

import AppKit
import XCTest
@testable import ClipBored
final class OnboardingWindowControllerTests: XCTestCase {
func testPasteStyleShortcutUsesShiftCommandV() {
let shortcut = OnboardingWindowController.pasteStyleOpenShortcut
XCTAssertEqual(shortcut.key, "v")
XCTAssertTrue(shortcut.has(.command))
XCTAssertTrue(shortcut.has(.shift))
XCTAssertFalse(shortcut.has(.option))
XCTAssertFalse(shortcut.has(.control))
}
func testFreshDefaultShortcutStartsWithPasteStyleChoice() {
let choice = OnboardingWindowController.initialShortcutChoice(
for: AppConfiguration.defaultOpenShortcut,
onboardingCompleted: false
)
XCTAssertEqual(choice, .pasteStyle)
}
func testCompletedDefaultShortcutKeepsClipBoredDefaultChoice() {
let choice = OnboardingWindowController.initialShortcutChoice(
for: AppConfiguration.defaultOpenShortcut,
onboardingCompleted: true
)
XCTAssertEqual(choice, .clipBoredDefault)
}
func testPresentationChoiceKeepsAVisibleEntryPoint() {
let presentation = OnboardingWindowController.normalizedPresentation(
showMenuBarIcon: false,
showDockIcon: false
)
XCTAssertTrue(presentation.showMenuBarIcon)
XCTAssertFalse(presentation.showDockIcon)
}
func testPresentationChoicePreservesExplicitDockOnlySetup() {
let presentation = OnboardingWindowController.normalizedPresentation(
showMenuBarIcon: false,
showDockIcon: true
)
XCTAssertFalse(presentation.showMenuBarIcon)
XCTAssertTrue(presentation.showDockIcon)
}
func testDisplayedEntryPointSelectionIsNormalizedOnRefresh() {
let settings = makeSettings()
settings.showMenuBarIcon = false
settings.showDockIcon = false
let controller = OnboardingWindowController(
settings: settings,
onOpenAccessibility: {},
onFinish: {}
)
XCTAssertTrue(controller.debugShowMenuBarIconIsEnabled)
XCTAssertFalse(controller.debugShowDockIconIsEnabled)
}
private func makeSettings() -> SettingsModel {
let suiteName = "com.clipbored.onboarding.\(UUID().uuidString)"
let defaults = UserDefaults(suiteName: suiteName)!
defaults.removePersistentDomain(forName: suiteName)
return SettingsModel(defaults: defaults)
}
}