Skip to content

Commit 54a796d

Browse files
committed
refactor: simplify volume control tests by consolidating assertions and removing redundant checks
1 parent 72c625f commit 54a796d

2 files changed

Lines changed: 9 additions & 29 deletions

File tree

VolumeGrid/StatusBar/StatusBarController.swift

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -287,11 +287,6 @@ final class StatusBarController {
287287
}
288288
}
289289

290-
private func formattedVolumeText(for percentage: Int) -> String {
291-
isVolumeControlAvailable
292-
? VolumeFormatter.formattedVolumeString(for: percentage) : "Not Supported"
293-
}
294-
295290
private func showError(_ message: String) {
296291
let alert = NSAlert()
297292
alert.messageText = "Launch at Login"

VolumeGridTests/LaunchAtLoginControllerTests.swift

Lines changed: 9 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -42,39 +42,24 @@ final class LaunchAtLoginControllerTests: XCTestCase {
4242
}
4343

4444
func testIsEnabledReturnsSetValue() {
45-
mockController.isEnabledValue = true
46-
XCTAssertTrue(mockController.isEnabled())
47-
48-
mockController.isEnabledValue = false
49-
XCTAssertFalse(mockController.isEnabled())
45+
for expected in [true, false] {
46+
mockController.isEnabledValue = expected
47+
XCTAssertEqual(mockController.isEnabled(), expected)
48+
}
5049
}
5150

5251
// MARK: - setEnabled() Tests
5352

54-
func testSetEnabledToTrueCallsCompletion() {
55-
let expectation = XCTestExpectation(description: "Enable completion")
53+
func testSetEnabledCallsCompletion() {
54+
for enabled in [true, false] {
55+
let expectation = XCTestExpectation(description: "Completion for \(enabled)")
5656

57-
mockController.setEnabled(true) { result in
58-
switch result {
59-
case .success, .failure:
57+
mockController.setEnabled(enabled) { _ in
6058
expectation.fulfill()
6159
}
62-
}
63-
64-
wait(for: [expectation], timeout: 5.0)
65-
}
6660

67-
func testSetEnabledToFalseCallsCompletion() {
68-
let expectation = XCTestExpectation(description: "Disable completion")
69-
70-
mockController.setEnabled(false) { result in
71-
switch result {
72-
case .success, .failure:
73-
expectation.fulfill()
74-
}
61+
wait(for: [expectation], timeout: 5.0)
7562
}
76-
77-
wait(for: [expectation], timeout: 5.0)
7863
}
7964

8065
func testSetEnabledReturnsSuccess() {

0 commit comments

Comments
 (0)