Stabilize unit and UI tests for SportsTime
This commit is contained in:
@@ -53,7 +53,7 @@ struct HistoricalGameQueryTests {
|
||||
/// - Expected Behavior: Returns date in yyyy-MM-dd format (Eastern time)
|
||||
@Test("normalizedDateString: formats as yyyy-MM-dd")
|
||||
func normalizedDateString_format() {
|
||||
var calendar = Calendar.current
|
||||
var calendar = TestClock.calendar
|
||||
calendar.timeZone = TimeZone(identifier: "America/New_York")!
|
||||
let date = calendar.date(from: DateComponents(year: 2026, month: 6, day: 15))!
|
||||
|
||||
@@ -64,7 +64,7 @@ struct HistoricalGameQueryTests {
|
||||
|
||||
@Test("normalizedDateString: pads single-digit months")
|
||||
func normalizedDateString_padMonth() {
|
||||
var calendar = Calendar.current
|
||||
var calendar = TestClock.calendar
|
||||
calendar.timeZone = TimeZone(identifier: "America/New_York")!
|
||||
let date = calendar.date(from: DateComponents(year: 2026, month: 3, day: 5))!
|
||||
|
||||
@@ -77,7 +77,7 @@ struct HistoricalGameQueryTests {
|
||||
|
||||
@Test("init: stores sport correctly")
|
||||
func init_storesSport() {
|
||||
let query = HistoricalGameQuery(sport: .nba, date: Date())
|
||||
let query = HistoricalGameQuery(sport: .nba, date: TestClock.now)
|
||||
#expect(query.sport == .nba)
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ struct HistoricalGameQueryTests {
|
||||
func init_storesTeams() {
|
||||
let query = HistoricalGameQuery(
|
||||
sport: .mlb,
|
||||
date: Date(),
|
||||
date: TestClock.now,
|
||||
homeTeamAbbrev: "NYY",
|
||||
awayTeamAbbrev: "BOS"
|
||||
)
|
||||
@@ -96,7 +96,7 @@ struct HistoricalGameQueryTests {
|
||||
|
||||
@Test("init: team abbreviations default to nil")
|
||||
func init_defaultNilTeams() {
|
||||
let query = HistoricalGameQuery(sport: .mlb, date: Date())
|
||||
let query = HistoricalGameQuery(sport: .mlb, date: TestClock.now)
|
||||
|
||||
#expect(query.homeTeamAbbrev == nil)
|
||||
#expect(query.awayTeamAbbrev == nil)
|
||||
@@ -117,7 +117,7 @@ struct HistoricalGameResultTests {
|
||||
) -> HistoricalGameResult {
|
||||
HistoricalGameResult(
|
||||
sport: .mlb,
|
||||
gameDate: Date(),
|
||||
gameDate: TestClock.now,
|
||||
homeTeamAbbrev: "NYY",
|
||||
awayTeamAbbrev: "BOS",
|
||||
homeTeamName: "Yankees",
|
||||
@@ -214,7 +214,7 @@ struct ScoreResolutionResultTests {
|
||||
private func makeHistoricalResult() -> HistoricalGameResult {
|
||||
HistoricalGameResult(
|
||||
sport: .mlb,
|
||||
gameDate: Date(),
|
||||
gameDate: TestClock.now,
|
||||
homeTeamAbbrev: "NYY",
|
||||
awayTeamAbbrev: "BOS",
|
||||
homeTeamName: "Yankees",
|
||||
|
||||
Reference in New Issue
Block a user