缺少代码差异信息,无法生成具体的commit message。请提供code differences内容以便分析并生成符合Angular规范的提交信息。
当您提供代码差异后,我将按照以下格式生成: ``` <type>(<scope>): <subject> <body> ``` 其中type会根据更改类型选择(feat、fix、docs、style、refactor等),scope表示影响范围,subject简要描述变更内容,body详细说明修改内容。
This commit is contained in:
54
康康Tests/HealthProfileImportTests.swift
Normal file
54
康康Tests/HealthProfileImportTests.swift
Normal file
@@ -0,0 +1,54 @@
|
||||
import Foundation
|
||||
import Testing
|
||||
@testable import 康康
|
||||
|
||||
struct HealthProfileImportTests {
|
||||
@Test func previewKeepsExistingValuesWhenHealthKitValueIsMissing() {
|
||||
let existing = UserProfile(
|
||||
birthYear: 1988,
|
||||
biologicalSexRaw: "female",
|
||||
heightCM: 162,
|
||||
bloodTypeRaw: "A"
|
||||
)
|
||||
let draft = HealthProfileImportDraft(heightCM: 175)
|
||||
|
||||
let preview = HealthProfileImportPreview(draft: draft, current: existing)
|
||||
|
||||
#expect(preview.birthYear.current == "1988")
|
||||
#expect(preview.birthYear.imported == nil)
|
||||
#expect(preview.birthYear.willUpdate == false)
|
||||
#expect(preview.sex.imported == nil)
|
||||
#expect(preview.height.imported == "175cm")
|
||||
#expect(preview.height.willUpdate == true)
|
||||
#expect(preview.bloodType.imported == nil)
|
||||
}
|
||||
|
||||
@Test func applyOnlyOverwritesFieldsPresentInDraft() {
|
||||
let profile = UserProfile(
|
||||
birthYear: 1988,
|
||||
biologicalSexRaw: "female",
|
||||
heightCM: 162,
|
||||
bloodTypeRaw: "A"
|
||||
)
|
||||
let draft = HealthProfileImportDraft(
|
||||
birthYear: 1990,
|
||||
biologicalSexRaw: "male",
|
||||
heightCM: nil,
|
||||
bloodTypeRaw: "O"
|
||||
)
|
||||
|
||||
draft.apply(to: profile, now: Date(timeIntervalSince1970: 123))
|
||||
|
||||
#expect(profile.birthYear == 1990)
|
||||
#expect(profile.biologicalSexRaw == "male")
|
||||
#expect(profile.heightCM == 162)
|
||||
#expect(profile.bloodTypeRaw == "O")
|
||||
#expect(profile.updatedAt == Date(timeIntervalSince1970: 123))
|
||||
}
|
||||
|
||||
@Test func emptyDraftReportsNoImportableFields() {
|
||||
let draft = HealthProfileImportDraft()
|
||||
|
||||
#expect(draft.hasAnyImportableField == false)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user