Cotton code
23 lines · 1.3 KB · SwiftRaw
import XCTest@testable import CottonUIfinal class BoardDefinitionTests: XCTestCase {    private var root: URL {        ProcessInfo.processInfo.environment["COTTON_TEST_REPO_ROOT"].map { URL(fileURLWithPath: $0) } ?? SourceSweep.repoRoot    }    /// RULE: A stored board decodes as its parts' kinds and settings, in order: what a part draws is the core's answer (`parts.board`), so the app reads no setting of a stored part.    func testAStoredBoardKeepsItsPartsInOrder() throws {        let data = try Data(contentsOf: root.appendingPathComponent("crates/cotton-core/tests/fixtures/board-parity/every-part.json"))        let board = try XCTUnwrap(BoardDefinition.decode(data))        XCTAssertEqual(board.parts.map(\.kind), ["head", "tools", "asked", "done", "notices", "list", "figure", "facts", "about", "recent", "search", "today", "sync", "device"])        XCTAssertEqual(board.parts[0].settings.keys.sorted(), ["tags"], "a part's settings stay as stored")    }    /// RULE: Every board the core hands over names at least one part, so a screen that reads its answer has something to ask for.    func testEveryBoardTheCoreHandsOverNamesItsParts() throws {        let boards = DefinitionCatalogue.shippedBoards        XCTAssertFalse(boards.isEmpty)        for (id, board) in boards { XCTAssertFalse(board.parts.isEmpty, id) }    }}