// The video in its sleeve: the sleeve prints the year and the running time; // the sticker says watched and the day over the stars, or the state still // to watch with no stars; a plain sleeve sets the title in capitals; the // parts tagged; the face lies on the claret baize and is stepped by a cut. @testable import CottonFaces import CottonPaper import CottonValues import SwiftUI import XCTest /// The parts a drawn face tagged. private final class VideoPartsTagged { var parts: Set = [] } @MainActor final class FilmVHSTests: XCTestCase { private typealias Catalogue = FilmVHSFaceCatalogue /// RULE: The sleeve prints the year and the running time as the cards join words. func testTheSleevePrintsTheYear() { XCTAssertEqual(FilmVHSSetting.year(Catalogue.seen), "1974 ยท 1:52:00") XCTAssertNil(FilmVHSSetting.year(Catalogue.film(["title": .text("No year")]))) } /// RULE: A watched film's sticker says the core's word for it and the day without its weekday, in capitals; still to watch, its state alone, with no day and no stars. func testTheStickerSaysWatchedOrToWatch() { let seen = FilmVHSSetting.sticker(Catalogue.seen) XCTAssertEqual(seen?.word, "WATCHED") XCTAssertEqual(seen?.day, "18 OCT") XCTAssertEqual(Catalogue.seen.rating, 4) let toSee = FilmVHSSetting.sticker(Catalogue.toSee) XCTAssertEqual(toSee?.word, "TO WATCH") XCTAssertNil(toSee?.day, "the core's \"Add date\" is no day") XCTAssertNil(Catalogue.toSee.rating) } /// RULE: A plain sleeve sets the title in capitals in lines ending on whole words. func testAPlainSleeveSetsTheTitle() { let lines = FilmVHSSetting.plainTitle(Catalogue.noPoster, sleeve: CGSize(width: 190, height: 324)) XCTAssertEqual(lines.joined(separator: " "), "INVENTED HARBOUR") XCTAssertNil(Catalogue.face.specimens.first { $0.name == "no-poster" }?.picture) } /// RULE: The video tags its poster (or a plain sleeve's title) and the spine label's title, the year's line, the sticker's word and, once watched, its day. func testTheVideoTagsItsParts() { let poster = FixturePictures.image("poster-ferry") XCTAssertNotNil(poster) func parts(_ face: Drawn) -> Set { let tagged = VideoPartsTagged() let drawn = face .frame(width: 340, height: 451) .backgroundPreferenceValue(FacePartsKey.self) { regions in let _ = tagged.parts.formUnion(regions.map(\.part)) Color.clear } XCTAssertNotNil(ImageRenderer(content: drawn).cgImage) return tagged.parts } XCTAssertEqual(parts(FilmVHSFace(card: Catalogue.seen, poster: poster)), [.picture, .title, .subtitle, .state, .when]) XCTAssertEqual(parts(FilmVHSFace(card: Catalogue.toSee, poster: poster)), [.picture, .title, .subtitle, .state]) XCTAssertEqual(parts(FilmVHSFace(card: Catalogue.noPoster)), [.title, .subtitle, .state, .when]) } /// RULE: The video lies bare on the films' dark claret baize, laid with its painted tile, and is stepped by a cut. func testTheVideoLiesOnTheClaretAndCuts() { XCTAssertEqual(FaceRegistry.ground("film.vhs"), .claret) XCTAssertEqual(FaceRegistry.stock("film.vhs"), .own) XCTAssertEqual(Catalogue.face.steps, .cut) XCTAssertEqual(Catalogue.face.specimens.map(\.name), ["seen", "to-see", "no-poster"]) for name in ["vhs-sleeve-grain", "vhs-sleeve-wear", "vhs-sleeve-shadow", "vhs-cassette", "vhs-cassette-shadow", "vhs-sticker", "vhs-spine", "films-baize"] { XCTAssertNotNil(CottonMedia.image(name, scale: 3), "\(name) is not in the catalogue") } } }