diff --git a/Sources/XXClient/Models/Fact.swift b/Sources/XXClient/Models/Fact.swift index f239a86dc52c98f36cb9abf098f3328116b171c4..4fb4134c2b440208f2043bc87578cb41c7d9d434 100644 --- a/Sources/XXClient/Models/Fact.swift +++ b/Sources/XXClient/Models/Fact.swift @@ -3,14 +3,14 @@ import Foundation public struct Fact: Equatable { public init( fact: String, - type: Int + type: FactType ) { self.fact = fact self.type = type } public var fact: String - public var type: Int + public var type: FactType } extension Fact: Codable { @@ -46,13 +46,13 @@ extension Array where Element == Fact { extension Array where Element == Fact { public func get(_ type: FactType) -> Fact? { - first(where: { $0.type == type.rawValue }) + first(where: { $0.type == type }) } public mutating func set(_ type: FactType, _ value: String?) { - removeAll(where: { $0.type == type.rawValue }) + removeAll(where: { $0.type == type }) if let value = value { - append(Fact(fact: value, type: type.rawValue)) + append(Fact(fact: value, type: type)) sort(by: { $0.type < $1.type }) } } diff --git a/Tests/XXClientTests/Models/FactTests.swift b/Tests/XXClientTests/Models/FactTests.swift index 0e777e7db1b32cc47d11e4cda58cbdbbc1d5b3e2..5c218ad07cebb0c0b69ee96a3172518744d1f695 100644 --- a/Tests/XXClientTests/Models/FactTests.swift +++ b/Tests/XXClientTests/Models/FactTests.swift @@ -5,7 +5,7 @@ import XCTest final class FactTests: XCTestCase { func testCoding() throws { let factValue = "Zezima" - let factType: Int = 0 + let factType: Int = 123 let jsonString = """ { "Fact": "\(factValue)", @@ -17,7 +17,7 @@ final class FactTests: XCTestCase { XCTAssertNoDifference(model, Fact( fact: factValue, - type: factType + type: 123 )) let encodedModel = try model.encode()