Tests/OrgAppTests/WindowModelTests.swift
22 lines · 880 bytes
1import Foundation
2import OrgDocument
3import Testing
4@testable import OrgApp
5
6/// `WindowModel` lives in the app target; this is its contract over the session, checked with
7/// the session alone: a split is a new pane showing the focused buffer; closing a pane leaves
8/// its buffer open; the last pane stays.
9@MainActor
10struct WindowModelContractTests {
11 @Test func aSplitShowsTheSameBufferInANewPane() throws {
12 let notes = try Folder()
13 let a = try notes.write("a.org", "* A\n").path
14 let session = DocumentSession(recovery: FileRecoveryStore(directory: notes.url.appendingPathComponent(".r")))
15 session.open(a)
16 let pane = session.makePane()
17 session.open(a, in: pane)
18 #expect(pane.path == a && session.openPaths == [a])
19 session.closePane(pane)
20 #expect(session.panes.count == 1 && session.isOpen(a))
21 }
22}