- Replace force-unwrap HK types with modern HKQuantityType(_:) initializer - Replace Calendar.date force-unwraps with guard/let in HealthService, HeaderPercView, MoodStreakActivity, DayViewViewModel, MonthTotalTemplate - Extract DayViewViewModel.countEntries into testable static method with safe flatMap - Replace DispatchQueue.main.asyncAfter with Task.sleep in CelebrationAnimations - Add .minimumScaleFactor(0.5) to SmallRollUpHeaderView for Dynamic Type - Add VoiceOver accessibility labels to HeaderPercView mood percentages - Fix @testable import iFeel → Feels in Tests_iOS.swift - Add 4 unit tests for countEntries (TDD) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
59 lines
2.4 KiB
Swift
59 lines
2.4 KiB
Swift
//
|
||
// Tests_iOS.swift
|
||
// Tests iOS
|
||
//
|
||
// Created by Trey Tartt on 1/10/22.
|
||
//
|
||
|
||
import XCTest
|
||
@testable import Feels
|
||
|
||
class Tests_iOS: XCTestCase {
|
||
override func setUpWithError() throws {
|
||
// Put setup code here. This method is called before the invocation of each test method in the class.
|
||
|
||
// In UI tests it is usually best to stop immediately when a failure occurs.
|
||
continueAfterFailure = false
|
||
|
||
// In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this.
|
||
}
|
||
|
||
override func tearDownWithError() throws {
|
||
// Put teardown code here. This method is called after the invocation of each test method in the class.
|
||
}
|
||
|
||
func testDatesBetween() {
|
||
let today = Calendar.current.date(bySettingHour: 0, minute: 0, second: 0, of: Date())!
|
||
let yesterday = Calendar.current.date(byAdding: .day, value: -1, to: today)!
|
||
let tenDaysAgo = Calendar.current.date(byAdding: .day, value: -10, to: today)!
|
||
|
||
let dates = Date.dates(from: Calendar.current.date(byAdding: .day, value: -10, to: Date())!, toDate: Date())
|
||
|
||
XCTAssertTrue(dates.last == yesterday)
|
||
XCTAssertTrue(dates.first == tenDaysAgo)
|
||
}
|
||
|
||
func testDatesIncluding() {
|
||
let today = Calendar.current.date(bySettingHour: 0, minute: 0, second: 0, of: Date())!
|
||
let yesterday = Calendar.current.date(bySettingHour: 0, minute: 0, second: 0, of: Date())!
|
||
let tenDaysAgo = Calendar.current.date(byAdding: .day, value: -10, to: today)!
|
||
|
||
let dates = Date.dates(from: Calendar.current.date(byAdding: .day, value: -10, to: Date())!, toDate: Date(), includingToDate: true)
|
||
|
||
XCTAssertTrue(dates.last == today)
|
||
XCTAssertTrue(dates.first == tenDaysAgo)
|
||
}
|
||
|
||
// func testLastVoteShouldExist() {
|
||
// let todayOneHourAhead = Calendar.current.date(byAdding: .day, value: 1, to: Date())!
|
||
// let fakeOnboarding = OnboardingData()
|
||
// fakeOnboarding.inputDay = DayOptions.Today
|
||
// fakeOnboarding.date = todayOneHourAhead
|
||
//
|
||
// let lastDay = ShowBasedOnVoteLogics.getLastDateVoteShouldExist(onboardingData: fakeOnboarding)
|
||
// let yesterday = Calendar.current.date(byAdding: .day, value: -1, to: Date())!
|
||
// XCTAssertTrue(lastDay == yesterday)
|
||
// }
|
||
|
||
}
|