Files
bulkhealth/BulkHealthTests/BulkHealthTests.swift

59 lines
1.6 KiB
Swift

import Testing
@testable import BulkHealth
struct BulkHealthTests {
@Test
func moodwellToStateOfMindTransform() throws {
let entry = MoodwellEntry(
arrayOfPhotos: [],
moodType: 4,
moodUniqueIdentifier: "abc-123",
arrayOfBadEmotions: ["Frustrated"],
notesString: "stressful but okay",
arrayOfWeathers: ["Sunny"],
createdAt: "2023-01-01T10:00:00.000Z",
arrayOfActivities: ["Work", "Sports"],
arrayOfGoodEmotions: ["Happy", "Optimistic"]
)
let result = MoodwellStateOfMindTemplate.makeDrafts(
entries: [entry],
mapping: MoodwellStateOfMindTemplate.defaultMapping,
moodValenceScale: [1: -0.8, 2: -0.25, 3: 0.3, 4: 0.8]
)
#expect(result.errors.isEmpty)
#expect(result.drafts.count == 1)
let draft = try #require(result.drafts.first)
#expect(draft.valence == 0.8)
#expect(draft.labels.contains(.happy))
#expect(draft.labels.contains(.hopeful))
#expect(draft.labels.contains(.frustrated))
#expect(draft.associations.contains(.work))
#expect(draft.associations.contains(.fitness))
#expect(draft.associations.contains(.weather))
}
@Test
func invalidDateCreatesError() {
let entry = MoodwellEntry(
arrayOfPhotos: [],
moodType: 2,
moodUniqueIdentifier: "broken-date",
arrayOfBadEmotions: [],
notesString: nil,
arrayOfWeathers: [],
createdAt: "not-a-date",
arrayOfActivities: [],
arrayOfGoodEmotions: []
)
let result = MoodwellStateOfMindTemplate.makeDrafts(
entries: [entry],
mapping: MoodwellStateOfMindTemplate.defaultMapping,
moodValenceScale: [1: -0.8, 2: -0.25, 3: 0.3, 4: 0.8]
)
#expect(result.drafts.isEmpty)
#expect(!result.errors.isEmpty)
}
}