Files
MatchLiveTv/native/ios/MatchLiveTvTests/ScoreActionDecodeTests.swift
Emiliano Frascaro 731b43ea88 Stabilizza diretta iOS e aggiunge test simulatore pre-release.
Corregge lifecycle RTMP/preview tra partite, reset tabellone, orientamento
con debounce, condivisione su iPad e script test_ios_simulator per CI locale.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-20 12:02:14 +02:00

69 lines
2.2 KiB
Swift

import XCTest
@testable import MatchLiveTv
final class ScoreActionDecodeTests: XCTestCase {
func testDecodesScoreActionResponse() throws {
let json = """
{
"id": "821ddb81-9dc2-466a-9ad5-2555e78f4653",
"match_id": "e887ce1d-10ee-4680-8323-79bb8f11e0aa",
"status": "live",
"platform": "matchlivetv",
"score": {
"type": "score_update",
"board_type": "volley",
"home_sets": 0,
"away_sets": 0,
"home_points": 1,
"away_points": 0,
"current_set": 1,
"set_partials": [],
"timeout_home": false,
"timeout_away": false,
"period": null,
"data": {}
},
"set_won": false,
"match_won": false,
"winner": null
}
""".data(using: .utf8)!
let dto = try ApiInstant.decoder.decode(StreamSessionDto.self, from: json)
let score = try XCTUnwrap(dto.score?.toDomain())
XCTAssertEqual(score.homePoints, 1)
XCTAssertEqual(score.boardType, "volley")
}
func testDecodesCloseSetResponseWithPartials() throws {
let json = """
{
"id": "821ddb81-9dc2-466a-9ad5-2555e78f4653",
"match_id": "e887ce1d-10ee-4680-8323-79bb8f11e0aa",
"status": "live",
"platform": "matchlivetv",
"score": {
"type": "score_update",
"board_type": "volley",
"home_sets": 1,
"away_sets": 0,
"home_points": 0,
"away_points": 0,
"current_set": 2,
"set_partials": [{ "set": 1, "home": 25, "away": 18 }],
"timeout_home": false,
"timeout_away": false
},
"set_won": true,
"match_won": false,
"winner": "home"
}
""".data(using: .utf8)!
let dto = try ApiInstant.decoder.decode(StreamSessionDto.self, from: json)
let score = try XCTUnwrap(dto.score?.toDomain())
XCTAssertEqual(score.currentSet, 2)
XCTAssertEqual(score.setPartials.count, 1)
XCTAssertEqual(score.setPartials[0].home, 25)
XCTAssertEqual(score.setPartials[0].away, 18)
}
}