cleanup tests
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
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"
|
||||
|
||||
[[block]]
|
||||
command = "printf 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")
|
||||
}
|
||||
Reference in New Issue
Block a user