import AppKit import Foundation import Testing @testable import phbar // MARK: - Refresh command @Test func refreshCommandConfigurationIsCorrect() async throws { let config = PHBar.Refresh.configuration #expect(config.commandName == "refresh") #expect(config.abstract == "Refresh the running status bar.") } // MARK: - BarController refresh @MainActor @Test func controllerRefreshUpdatesAllBlocks() async throws { let screen = try #require(NSScreen.main) let blocks = try PHBlock.load(from: """ [[block]] command = "printf a" name = "a" [[block]] command = "printf b" name = "b" """) let config = try PHConfig.load() let theme = try PHTheme.load("voltage") let controller = BarController(config: config, screen: screen, theme: theme, blocks: blocks, debug: false) controller.refresh() // Allow the per-block update tasks to run. try await Task.sleep(for: .milliseconds(100)) #expect(blocks[0].label == "a") #expect(blocks[1].label == "b") }