Cotton code
27 lines · 1.5 KB · SwiftRaw
// A cold launch opens Home at its top, in one fixed order (coordinator// 6 Oct, mini RJ11 sev 3): Home's place was kept in UserDefaults across// launches and chased onto a page still filling, so it landed on the// tile grid.import XCTest@testable import CottonUIfinal class HomeColdLaunchTests: XCTestCase {    // RULE: Home's place is kept for the run only and forgotten when the window turns to a database: a switch and a cold launch both open it at its top; no place is written to UserDefaults for Home.    func testHomesPlaceLivesOnlyForTheRun() throws {        let model = SourceSweep.withoutComments(            try SourceSweep.mustRead("apps/cotton/Sources/CottonUI/Surfaces/Databases/DatabasesModel.swift", ownedBy: "home"))        XCTAssertFalse(model.contains("PagePlaces(defaults:"), "Home's place is written across launches")        let places = PagePlaces()        places.keep(640, for: "personal")        places.keep(320, for: "personal/garden")        places.keep(100, for: "allotment")        XCTAssertEqual(places.place(of: "personal"), 640, "while it is shown, the page keeps its place")        places.forget(database: "personal")        XCTAssertNil(places.place(of: "personal"), "turned to again, it opens at its top")        XCTAssertNil(places.place(of: "personal/garden"), "and so do its projects' pages")        XCTAssertEqual(places.place(of: "allotment"), 100, "another database's place is its own")        XCTAssertNil(PagePlaces().place(of: "personal"), "a new run starts at the top")    }}