diff options
| author | Tommaso Negri <me@tommasongr.com> | 2026-10-14 22:30:19 +0200 |
|---|---|---|
| committer | Tommaso Negri <me@tommasongr.com> | 2026-10-14 22:30:19 +0200 |
| commit | 498ac51307412adc29d6d4a6240ae7b98d55621e (patch) | |
| tree | 084d983c850673b60b0bfae48d0a4852737f06af /Tests | |
| parent | 4942df3a59c0dd7c95b82727f8b03ddf80657973 (diff) | |
| download | bar-498ac51307412adc29d6d4a6240ae7b98d55621e.tar.gz bar-498ac51307412adc29d6d4a6240ae7b98d55621e.zip | |
improve performances
Diffstat (limited to 'Tests')
| -rw-r--r-- | Tests/barTests/BlockRefreshTests.swift | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/Tests/barTests/BlockRefreshTests.swift b/Tests/barTests/BlockRefreshTests.swift new file mode 100644 index 0000000..495bcac --- /dev/null +++ b/Tests/barTests/BlockRefreshTests.swift @@ -0,0 +1,29 @@ +import Combine +import Testing +@testable import bar + +@Test @MainActor func unchangedOutputDoesNotPublish() { + let block = Block(name: "test", placement: .left, command: "") + var publications = 0 + let subscription = block.$cells.dropFirst().sink { _ in publications += 1 } + defer { subscription.cancel() } + + block.apply(["same", "same"]) + block.apply(["same", "same"]) + #expect(publications == 1) + #expect(block.cells.map(\.rawValue) == ["same", "same"]) + + // A highlight-only change must still publish, even with identical text. + block.apply(["&!1 same", "same"]) + #expect(publications == 2) + #expect(block.cells[0].id == " same:1") + block.apply([]) + block.apply([]) + #expect(publications == 3) + #expect(block.cells.isEmpty) +} + +@Test func runnerPreservesOutputAcrossPoolDrain() { + #expect(Runner.run("printf 'first\\n\\nlast\\n'") == ["first", "", "last"]) + #expect(Runner.run("exit 1") == ["ERROR"]) +} |
