Skip to content

Commit

Permalink
Add SetDTO+Util test
Browse files Browse the repository at this point in the history
  • Loading branch information
dogo committed Aug 23, 2024
1 parent f82e9b8 commit 9314980
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 39 deletions.
60 changes: 21 additions & 39 deletions SWDestinyTrades/Classes/Extensions/SetDTO+Utils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,44 +11,26 @@ import UIKit
extension SetDTO {

var icon: UIImage {
if code.lowercased() == "aw" {
return Asset.Sets.icAwakenings.image
} else if code.lowercased() == "sor" {
return Asset.Sets.icSpiritOfRebellion.image
} else if code.lowercased() == "eaw" {
return Asset.Sets.icEmpireAtWar.image
} else if code.lowercased() == "tpg" {
return Asset.Sets.icTwoPlayerGame.image
} else if code.lowercased() == "leg" {
return Asset.Sets.icLegacies.image
} else if code.lowercased() == "riv" {
return Asset.Sets.icRivals.image
} else if code.lowercased() == "wotf" {
return Asset.Sets.icWayOfTheForce.image
} else if code.lowercased() == "atg" {
return Asset.Sets.icAcrossTheGalaxy.image
} else if code.lowercased() == "conv" {
return Asset.Sets.icConvergence.image
} else if code.lowercased() == "aon" {
return Asset.Sets.icAlliesOfNecessity.image
} else if code.lowercased() == "soh" {
return Asset.Sets.icSparkOfHope.image
} else if code.lowercased() == "cm" {
return Asset.Sets.icCovertMissions.image
} else if code.lowercased() == "tr" {
return Asset.Sets.icTransformations.image
} else if code.lowercased() == "fa" {
return Asset.Sets.icFalteringAllegiances.image
} else if code.lowercased() == "ec" {
return Asset.Sets.icEternalConflict.image
} else if code.lowercased() == "rm" {
return Asset.Sets.icRedemption.image
} else if code.lowercased() == "hs" {
return Asset.Sets.icHighStakes.image
} else if code.lowercased() == "pw" {
return Asset.Sets.icPartingWords.image
} else {
return Asset.Sets.icNotFound.image
}
let icons: [String: UIImage] = [
"aw": Asset.Sets.icAwakenings.image,
"sor": Asset.Sets.icSpiritOfRebellion.image,
"eaw": Asset.Sets.icEmpireAtWar.image,
"tpg": Asset.Sets.icTwoPlayerGame.image,
"leg": Asset.Sets.icLegacies.image,
"riv": Asset.Sets.icRivals.image,
"wotf": Asset.Sets.icWayOfTheForce.image,
"atg": Asset.Sets.icAcrossTheGalaxy.image,
"conv": Asset.Sets.icConvergence.image,
"aon": Asset.Sets.icAlliesOfNecessity.image,
"soh": Asset.Sets.icSparkOfHope.image,
"cm": Asset.Sets.icCovertMissions.image,
"tr": Asset.Sets.icTransformations.image,
"fa": Asset.Sets.icFalteringAllegiances.image,
"ec": Asset.Sets.icEternalConflict.image,
"rm": Asset.Sets.icRedemption.image,
"hs": Asset.Sets.icHighStakes.image,
"pw": Asset.Sets.icPartingWords.image
]
return icons[code.lowercased()] ?? Asset.Sets.icNotFound.image
}
}
43 changes: 43 additions & 0 deletions SWDestinyTradesTests/Extensions/SetDTO+UtilsTest.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
//
// SetDTO+UtilsTest.swift
// SWDestinyTradesTests
//
// Created by Diogo Autilio on 23/08/24.
// Copyright © 2024 Diogo Autilio. All rights reserved.
//

import XCTest

@testable import SWDestinyTrades

final class SetDTOTests: XCTestCase {

func test_icon() {
let testCases: [(code: String, expectedIcon: UIImage)] = [
("aw", Asset.Sets.icAwakenings.image),
("sor", Asset.Sets.icSpiritOfRebellion.image),
("eaw", Asset.Sets.icEmpireAtWar.image),
("tpg", Asset.Sets.icTwoPlayerGame.image),
("leg", Asset.Sets.icLegacies.image),
("riv", Asset.Sets.icRivals.image),
("wotf", Asset.Sets.icWayOfTheForce.image),
("atg", Asset.Sets.icAcrossTheGalaxy.image),
("conv", Asset.Sets.icConvergence.image),
("aon", Asset.Sets.icAlliesOfNecessity.image),
("soh", Asset.Sets.icSparkOfHope.image),
("cm", Asset.Sets.icCovertMissions.image),
("tr", Asset.Sets.icTransformations.image),
("fa", Asset.Sets.icFalteringAllegiances.image),
("ec", Asset.Sets.icEternalConflict.image),
("rm", Asset.Sets.icRedemption.image),
("hs", Asset.Sets.icHighStakes.image),
("pw", Asset.Sets.icPartingWords.image),
("unknown", Asset.Sets.icNotFound.image)
]

for testCase in testCases {
let setDTO = SetDTO(name: "Test", code: testCase.code)
XCTAssertEqual(setDTO.icon, testCase.expectedIcon, "Icon for code \(testCase.code) did not match expected icon.")
}
}
}

0 comments on commit 9314980

Please sign in to comment.