tv-anarchy/Tests/TVAnarchyCoreTests/DecoderTests.swift
Natalie 92b38b1bae refactor(tv-anarchy): rename PlumTV→TVAnarchy and land session work
Renames Sources/PlumTV→TVAnarchy and PlumTVCore→TVAnarchyCore (the rename
the auto-commit service couldn't stage — it git-add'd the old, now-gone
paths and aborted every cycle), and commits the accumulated work:

- Library: black-built index fast path (LibraryIndex + scanFromIndex) with
  NFS-walk fallback; incremental --add on download-complete; mtime staleness
  gate; loose-file series-collapse fix; determinate scan/index progress.
- Cover art: keyless TVmaze cartoon-vs-live-action disambiguation (type/year).
- Player: sleep timer (timed + end-of-episode); visibility-gated polling.
- Home: Continue Watching cover art + live refresh; Recently Added; adult gate.
- Logs: multi-line selection + copy; truncated giant tx-list errors.
- Hover previews (opt-in) via black ffmpeg + scp.

Also gitignores foreign project trees (governor/mcp/fleet/recommender) that
sit in this directory but belong to their own repos.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-08 22:04:22 -07:00

21 lines
1,008 B
Swift

import XCTest
@testable import TVAnarchyCore
final class DecoderTests: XCTestCase {
func testIdleStatusConstant() {
XCTAssertFalse(PlaybackStatus.idle.playing)
}
func testStatusCacheRoundTrips() throws {
let s = PlaybackStatus(playing: true, paused: false, title: "Psych S01E13",
volume: 79, position: 1410, duration: 2590,
playlistPos: 2, playlistCount: 110)
let map = ["black": PlayerStatusCache.Entry(status: s, capturedAt: Date(timeIntervalSince1970: 1000))]
let enc = JSONEncoder(); enc.dateEncodingStrategy = .iso8601
let dec = JSONDecoder(); dec.dateDecodingStrategy = .iso8601
let back = try dec.decode([String: PlayerStatusCache.Entry].self, from: enc.encode(map))
XCTAssertEqual(back["black"]?.status, s)
XCTAssertEqual(back["black"]?.status.title, "Psych S01E13")
XCTAssertEqual(back["black"]?.capturedAt, Date(timeIntervalSince1970: 1000))
}
}