From 4fef1f7f786291651afdac3728743e40d48a0604 Mon Sep 17 00:00:00 2001 From: Dariusz Rybicki <dariusz@elixxir.io> Date: Thu, 8 Sep 2022 00:24:55 +0200 Subject: [PATCH] Change type of Fact.type property to FactType --- Sources/XXClient/Models/Fact.swift | 10 +++++----- Tests/XXClientTests/Models/FactTests.swift | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Sources/XXClient/Models/Fact.swift b/Sources/XXClient/Models/Fact.swift index f239a86d..4fb4134c 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 0e777e7d..5c218ad0 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() -- GitLab