Restructured every test case to follow the same GIVEN?WHEN/THEN structure with backticked, descriptive test names.
This commit is contained in:
1 parent
3784c04df2
commit
647f63ee1e
5 files changed
+114
-120
No files matched your search
@@ -25,8 +25,8 @@ struct ISODateTimeTranscoderTests {
|
|||||||
|
|
||||||
// MARK: Decode tests
|
// MARK: Decode tests
|
||||||
|
|
||||||
@Test("decodes a timestamp as UTC")
|
@Test
|
||||||
func decodesTimestamp() throws {
|
func `decodes a timestamp as UTC`() throws {
|
||||||
// GIVEN
|
// GIVEN
|
||||||
let string = "2026-07-24T12:34:56.123000"
|
let string = "2026-07-24T12:34:56.123000"
|
||||||
|
|
||||||
@@ -37,8 +37,8 @@ struct ISODateTimeTranscoderTests {
|
|||||||
#expect(abs(date.timeIntervalSince(.utc(2026, 7, 24, 12, 34, 56)) - 0.123) < 0.001)
|
#expect(abs(date.timeIntervalSince(.utc(2026, 7, 24, 12, 34, 56)) - 0.123) < 0.001)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test("decodes a date-only string as midnight UTC")
|
@Test
|
||||||
func decodesDate() throws {
|
func `decodes a date-only string as midnight UTC`() throws {
|
||||||
// GIVEN
|
// GIVEN
|
||||||
let string = "2014-11-21"
|
let string = "2014-11-21"
|
||||||
|
|
||||||
@@ -49,10 +49,10 @@ struct ISODateTimeTranscoderTests {
|
|||||||
#expect(date == .utc(2014, 11, 21))
|
#expect(date == .utc(2014, 11, 21))
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test("throws a decoding error for an unsupported string", arguments: [
|
@Test(arguments: [
|
||||||
"", "2014-11", "2014-11-21T12:34:56", "2014-11-21T12:34:56Z", "21/11/2014", "yesterday"
|
"", "2014-11", "2014-11-21T12:34:56", "2014-11-21T12:34:56Z", "21/11/2014", "yesterday"
|
||||||
])
|
])
|
||||||
func throwsForUnsupportedString(string: String) {
|
func `throws a decoding error for an unsupported string`(string: String) {
|
||||||
// GIVEN
|
// GIVEN
|
||||||
// WHEN
|
// WHEN
|
||||||
// THEN
|
// THEN
|
||||||
@@ -63,8 +63,8 @@ struct ISODateTimeTranscoderTests {
|
|||||||
|
|
||||||
// MARK: Encode tests
|
// MARK: Encode tests
|
||||||
|
|
||||||
@Test("encodes a date as a timestamp")
|
@Test
|
||||||
func encodesTimestamp() throws {
|
func `encodes a date as a timestamp`() throws {
|
||||||
// GIVEN
|
// GIVEN
|
||||||
let date: Date = .utc(2026, 7, 24, 12, 34, 56)
|
let date: Date = .utc(2026, 7, 24, 12, 34, 56)
|
||||||
|
|
||||||
|
|||||||
@@ -22,8 +22,8 @@ struct AmiiboLiveClientTests {
|
|||||||
|
|
||||||
// MARK: Server URL tests
|
// MARK: Server URL tests
|
||||||
|
|
||||||
@Test("resolves the server URL defined in the OpenAPI specification")
|
@Test
|
||||||
func serverURLResolves() throws {
|
func `resolves the server URL defined in the OpenAPI specification`() throws {
|
||||||
// GIVEN
|
// GIVEN
|
||||||
// WHEN
|
// WHEN
|
||||||
let url = try Servers.Server1.url()
|
let url = try Servers.Server1.url()
|
||||||
@@ -32,8 +32,8 @@ struct AmiiboLiveClientTests {
|
|||||||
#expect(url.absoluteString == "https://www.amiiboapi.org/api")
|
#expect(url.absoluteString == "https://www.amiiboapi.org/api")
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test("uses the server URL from the OpenAPI specification")
|
@Test
|
||||||
func serverURLMatchesSpecification() throws {
|
func `uses the server URL from the OpenAPI specification`() throws {
|
||||||
// GIVEN
|
// GIVEN
|
||||||
let expected = try Servers.Server1.url()
|
let expected = try Servers.Server1.url()
|
||||||
|
|
||||||
@@ -46,14 +46,11 @@ struct AmiiboLiveClientTests {
|
|||||||
|
|
||||||
// MARK: Error mapping tests
|
// MARK: Error mapping tests
|
||||||
|
|
||||||
@Test(
|
@Test(arguments: zip(
|
||||||
"maps an error thrown by the transport to the matching service error",
|
TransportErrors.thrown,
|
||||||
arguments: zip(
|
TransportErrors.expected
|
||||||
TransportErrors.thrown,
|
))
|
||||||
TransportErrors.expected
|
func `maps an error thrown by the transport to the matching service error`(
|
||||||
)
|
|
||||||
)
|
|
||||||
func mapsTransportError(
|
|
||||||
thrown: any Error,
|
thrown: any Error,
|
||||||
expected: AmiiboServiceError
|
expected: AmiiboServiceError
|
||||||
) async {
|
) async {
|
||||||
@@ -67,14 +64,11 @@ struct AmiiboLiveClientTests {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(
|
@Test(arguments: zip(
|
||||||
"maps a response status to the matching service error",
|
Responses.failing,
|
||||||
arguments: zip(
|
Responses.expected
|
||||||
Responses.failing,
|
))
|
||||||
Responses.expected
|
func `maps a response status to the matching service error`(
|
||||||
)
|
|
||||||
)
|
|
||||||
func mapsResponseStatus(
|
|
||||||
response: (status: Int, json: String?),
|
response: (status: Int, json: String?),
|
||||||
expected: AmiiboServiceError
|
expected: AmiiboServiceError
|
||||||
) async {
|
) async {
|
||||||
@@ -93,8 +87,8 @@ struct AmiiboLiveClientTests {
|
|||||||
|
|
||||||
// MARK: Get Amiibos tests
|
// MARK: Get Amiibos tests
|
||||||
|
|
||||||
@Test("returns amiibos sorted by identifier")
|
@Test
|
||||||
func getAmiibosSorted() async throws {
|
func `returns amiibos sorted by identifier`() async throws {
|
||||||
// GIVEN
|
// GIVEN
|
||||||
let client = AmiiboLiveClient(transport: StubTransport(status: .ok, json: JSON.amiibos))
|
let client = AmiiboLiveClient(transport: StubTransport(status: .ok, json: JSON.amiibos))
|
||||||
|
|
||||||
@@ -106,8 +100,8 @@ struct AmiiboLiveClientTests {
|
|||||||
#expect(amiibos.map(\.name) == ["Mario", "Zelda"])
|
#expect(amiibos.map(\.name) == ["Mario", "Zelda"])
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test("returns a single amiibo when the response holds an object")
|
@Test
|
||||||
func getAmiibosSingle() async throws {
|
func `returns a single amiibo when the response holds an object`() async throws {
|
||||||
// GIVEN
|
// GIVEN
|
||||||
let client = AmiiboLiveClient(transport: StubTransport(status: .ok, json: JSON.amiibo))
|
let client = AmiiboLiveClient(transport: StubTransport(status: .ok, json: JSON.amiibo))
|
||||||
|
|
||||||
@@ -128,8 +122,8 @@ struct AmiiboLiveClientTests {
|
|||||||
#expect(amiibo.platform == nil)
|
#expect(amiibo.platform == nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test("returns no amiibos when the response holds null")
|
@Test
|
||||||
func getAmiibosNull() async throws {
|
func `returns no amiibos when the response holds null`() async throws {
|
||||||
// GIVEN
|
// GIVEN
|
||||||
let client = AmiiboLiveClient(transport: StubTransport(status: .ok, json: JSON.amiibosNull))
|
let client = AmiiboLiveClient(transport: StubTransport(status: .ok, json: JSON.amiibosNull))
|
||||||
|
|
||||||
@@ -140,8 +134,8 @@ struct AmiiboLiveClientTests {
|
|||||||
#expect(amiibos.isEmpty)
|
#expect(amiibos.isEmpty)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test("returns no amiibos when the response holds an empty list")
|
@Test
|
||||||
func getAmiibosEmpty() async throws {
|
func `returns no amiibos when the response holds an empty list`() async throws {
|
||||||
// GIVEN
|
// GIVEN
|
||||||
let client = AmiiboLiveClient(transport: StubTransport(status: .ok, json: JSON.amiibosEmpty))
|
let client = AmiiboLiveClient(transport: StubTransport(status: .ok, json: JSON.amiibosEmpty))
|
||||||
|
|
||||||
@@ -152,8 +146,8 @@ struct AmiiboLiveClientTests {
|
|||||||
#expect(amiibos.isEmpty)
|
#expect(amiibos.isEmpty)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test("decodes release dates as midnight UTC, and missing or null ones as nil")
|
@Test
|
||||||
func getAmiibosRelease() async throws {
|
func `decodes release dates as midnight UTC, and missing or null ones as nil`() async throws {
|
||||||
// GIVEN
|
// GIVEN
|
||||||
let client = AmiiboLiveClient(transport: StubTransport(status: .ok, json: JSON.amiibos))
|
let client = AmiiboLiveClient(transport: StubTransport(status: .ok, json: JSON.amiibos))
|
||||||
|
|
||||||
@@ -171,8 +165,8 @@ struct AmiiboLiveClientTests {
|
|||||||
#expect(zelda.release.japan == nil)
|
#expect(zelda.release.japan == nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test("maps related games and usages into the platform")
|
@Test
|
||||||
func getAmiibosPlatform() async throws {
|
func `maps related games and usages into the platform`() async throws {
|
||||||
// GIVEN
|
// GIVEN
|
||||||
let client = AmiiboLiveClient(transport: StubTransport(status: .ok, json: JSON.amiiboWithGames))
|
let client = AmiiboLiveClient(transport: StubTransport(status: .ok, json: JSON.amiiboWithGames))
|
||||||
|
|
||||||
@@ -192,8 +186,8 @@ struct AmiiboLiveClientTests {
|
|||||||
#expect(platform.wiiU.first?.usages == nil)
|
#expect(platform.wiiU.first?.usages == nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test("encodes the amiibo filter as query parameters")
|
@Test
|
||||||
func getAmiibosQuery() async throws {
|
func `encodes the amiibo filter as query parameters`() async throws {
|
||||||
// GIVEN
|
// GIVEN
|
||||||
let client = AmiiboLiveClient(transport: StubTransport { request in
|
let client = AmiiboLiveClient(transport: StubTransport { request in
|
||||||
let path = request.path ?? ""
|
let path = request.path ?? ""
|
||||||
@@ -229,8 +223,8 @@ struct AmiiboLiveClientTests {
|
|||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test("omits nil filter values from the query")
|
@Test
|
||||||
func getAmiibosEmptyQuery() async throws {
|
func `omits nil filter values from the query`() async throws {
|
||||||
// GIVEN
|
// GIVEN
|
||||||
let client = AmiiboLiveClient(transport: StubTransport { request in
|
let client = AmiiboLiveClient(transport: StubTransport { request in
|
||||||
#expect(request.path == "/amiibo")
|
#expect(request.path == "/amiibo")
|
||||||
@@ -245,8 +239,8 @@ struct AmiiboLiveClientTests {
|
|||||||
|
|
||||||
// MARK: Key-name endpoints tests
|
// MARK: Key-name endpoints tests
|
||||||
|
|
||||||
@Test("returns amiibo series sorted by key")
|
@Test
|
||||||
func getAmiiboSeriesSorted() async throws {
|
func `returns amiibo series sorted by key`() async throws {
|
||||||
// GIVEN
|
// GIVEN
|
||||||
let client = AmiiboLiveClient(transport: StubTransport(status: .ok, json: JSON.keyNameList))
|
let client = AmiiboLiveClient(transport: StubTransport(status: .ok, json: JSON.keyNameList))
|
||||||
|
|
||||||
@@ -257,8 +251,8 @@ struct AmiiboLiveClientTests {
|
|||||||
#expect(series == [.init(key: "0x00", name: "Second"), .init(key: "0x01", name: "First")])
|
#expect(series == [.init(key: "0x00", name: "Second"), .init(key: "0x01", name: "First")])
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test("returns a single amiibo series when the response holds an object")
|
@Test
|
||||||
func getAmiiboSeriesSingle() async throws {
|
func `returns a single amiibo series when the response holds an object`() async throws {
|
||||||
// GIVEN
|
// GIVEN
|
||||||
let client = AmiiboLiveClient(transport: StubTransport { request in
|
let client = AmiiboLiveClient(transport: StubTransport { request in
|
||||||
#expect(request.path == "/amiiboseries?key=0x01")
|
#expect(request.path == "/amiiboseries?key=0x01")
|
||||||
@@ -273,8 +267,8 @@ struct AmiiboLiveClientTests {
|
|||||||
#expect(series == [.init(key: "0x01", name: "First")])
|
#expect(series == [.init(key: "0x01", name: "First")])
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test("returns amiibo types sorted by key")
|
@Test
|
||||||
func getAmiiboTypesSorted() async throws {
|
func `returns amiibo types sorted by key`() async throws {
|
||||||
// GIVEN
|
// GIVEN
|
||||||
let client = AmiiboLiveClient(transport: StubTransport { request in
|
let client = AmiiboLiveClient(transport: StubTransport { request in
|
||||||
#expect(request.path == "/type")
|
#expect(request.path == "/type")
|
||||||
@@ -289,8 +283,8 @@ struct AmiiboLiveClientTests {
|
|||||||
#expect(types == [.init(key: "0x00", name: "Second"), .init(key: "0x01", name: "First")])
|
#expect(types == [.init(key: "0x00", name: "Second"), .init(key: "0x01", name: "First")])
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test("returns game characters sorted by key")
|
@Test
|
||||||
func getGameCharactersSorted() async throws {
|
func `returns game characters sorted by key`() async throws {
|
||||||
// GIVEN
|
// GIVEN
|
||||||
let client = AmiiboLiveClient(transport: StubTransport { request in
|
let client = AmiiboLiveClient(transport: StubTransport { request in
|
||||||
#expect(request.path == "/character?name=First")
|
#expect(request.path == "/character?name=First")
|
||||||
@@ -305,8 +299,8 @@ struct AmiiboLiveClientTests {
|
|||||||
#expect(characters == [.init(key: "0x00", name: "Second"), .init(key: "0x01", name: "First")])
|
#expect(characters == [.init(key: "0x00", name: "Second"), .init(key: "0x01", name: "First")])
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test("returns game series sorted by key")
|
@Test
|
||||||
func getGameSeriesSorted() async throws {
|
func `returns game series sorted by key`() async throws {
|
||||||
// GIVEN
|
// GIVEN
|
||||||
let client = AmiiboLiveClient(transport: StubTransport { request in
|
let client = AmiiboLiveClient(transport: StubTransport { request in
|
||||||
#expect(request.path == "/gameseries")
|
#expect(request.path == "/gameseries")
|
||||||
@@ -321,8 +315,8 @@ struct AmiiboLiveClientTests {
|
|||||||
#expect(series == [.init(key: "0x00", name: "Second"), .init(key: "0x01", name: "First")])
|
#expect(series == [.init(key: "0x00", name: "Second"), .init(key: "0x01", name: "First")])
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test("throws notFound when a key-name endpoint matches nothing")
|
@Test
|
||||||
func getKeyNameNotFound() async {
|
func `throws notFound when a key-name endpoint matches nothing`() async {
|
||||||
// GIVEN
|
// GIVEN
|
||||||
let client = AmiiboLiveClient(transport: StubTransport(status: .notFound, json: JSON.notFound))
|
let client = AmiiboLiveClient(transport: StubTransport(status: .notFound, json: JSON.notFound))
|
||||||
|
|
||||||
@@ -335,8 +329,8 @@ struct AmiiboLiveClientTests {
|
|||||||
|
|
||||||
// MARK: Get Last Updated tests
|
// MARK: Get Last Updated tests
|
||||||
|
|
||||||
@Test("returns the last updated timestamp as UTC")
|
@Test
|
||||||
func getLastUpdated() async throws {
|
func `returns the last updated timestamp as UTC`() async throws {
|
||||||
// GIVEN
|
// GIVEN
|
||||||
let client = AmiiboLiveClient(transport: StubTransport { request in
|
let client = AmiiboLiveClient(transport: StubTransport { request in
|
||||||
#expect(request.path == "/lastupdated")
|
#expect(request.path == "/lastupdated")
|
||||||
@@ -351,8 +345,8 @@ struct AmiiboLiveClientTests {
|
|||||||
#expect(lastUpdated == .utc(2026, 7, 24, 12, 34, 56))
|
#expect(lastUpdated == .utc(2026, 7, 24, 12, 34, 56))
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test("throws notAvailable when the last updated endpoint fails")
|
@Test
|
||||||
func getLastUpdatedNotAvailable() async {
|
func `throws notAvailable when the last updated endpoint fails`() async {
|
||||||
// GIVEN
|
// GIVEN
|
||||||
let client = AmiiboLiveClient(transport: StubTransport(status: .internalServerError))
|
let client = AmiiboLiveClient(transport: StubTransport(status: .internalServerError))
|
||||||
|
|
||||||
|
|||||||
@@ -20,8 +20,8 @@ struct FilterConformanceTests {
|
|||||||
|
|
||||||
// MARK: Equatable tests
|
// MARK: Equatable tests
|
||||||
|
|
||||||
@Test("compares amiibo filters by value")
|
@Test
|
||||||
func amiiboFilterEquality() {
|
func `compares amiibo filters by value`() {
|
||||||
// GIVEN
|
// GIVEN
|
||||||
// WHEN
|
// WHEN
|
||||||
// THEN
|
// THEN
|
||||||
@@ -31,8 +31,8 @@ struct FilterConformanceTests {
|
|||||||
#expect(AmiiboFilter() != AmiiboFilter(showGames: true))
|
#expect(AmiiboFilter() != AmiiboFilter(showGames: true))
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test("compares key-name filters by value")
|
@Test
|
||||||
func keyNameFilterEquality() {
|
func `compares key-name filters by value`() {
|
||||||
// GIVEN
|
// GIVEN
|
||||||
// WHEN
|
// WHEN
|
||||||
// THEN
|
// THEN
|
||||||
@@ -46,8 +46,8 @@ struct FilterConformanceTests {
|
|||||||
|
|
||||||
// MARK: Hashable tests
|
// MARK: Hashable tests
|
||||||
|
|
||||||
@Test("hashes equal filters alike")
|
@Test
|
||||||
func filterHashing() {
|
func `hashes equal filters alike`() {
|
||||||
// GIVEN
|
// GIVEN
|
||||||
let amiiboFilters: Set = [AmiiboFilter(name: "zelda"), AmiiboFilter(name: "zelda"), AmiiboFilter(name: "mario")]
|
let amiiboFilters: Set = [AmiiboFilter(name: "zelda"), AmiiboFilter(name: "zelda"), AmiiboFilter(name: "mario")]
|
||||||
let seriesFilters: Set = [AmiiboSeriesFilter(key: "0x01"), AmiiboSeriesFilter(key: "0x01"), AmiiboSeriesFilter()]
|
let seriesFilters: Set = [AmiiboSeriesFilter(key: "0x01"), AmiiboSeriesFilter(key: "0x01"), AmiiboSeriesFilter()]
|
||||||
|
|||||||
@@ -21,8 +21,8 @@ struct ModelConformanceTests {
|
|||||||
|
|
||||||
// MARK: Identifiable tests
|
// MARK: Identifiable tests
|
||||||
|
|
||||||
@Test("identifies an amiibo by its identifier")
|
@Test
|
||||||
func amiiboID() {
|
func `identifies an amiibo by its identifier`() {
|
||||||
// GIVEN
|
// GIVEN
|
||||||
let amiibos = Fixtures.amiibos
|
let amiibos = Fixtures.amiibos
|
||||||
|
|
||||||
@@ -31,8 +31,8 @@ struct ModelConformanceTests {
|
|||||||
#expect(amiibos.map(\.id) == amiibos.map(\.identifier))
|
#expect(amiibos.map(\.id) == amiibos.map(\.identifier))
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test("identifies key-name models by their keys")
|
@Test
|
||||||
func keyNameIDs() {
|
func `identifies key-name models by their keys`() {
|
||||||
// GIVEN
|
// GIVEN
|
||||||
// WHEN
|
// WHEN
|
||||||
// THEN
|
// THEN
|
||||||
@@ -44,8 +44,8 @@ struct ModelConformanceTests {
|
|||||||
|
|
||||||
// MARK: Codable tests
|
// MARK: Codable tests
|
||||||
|
|
||||||
@Test("round-trips amiibos through JSON")
|
@Test
|
||||||
func amiibosRoundTrip() throws {
|
func `round-trips amiibos through JSON`() throws {
|
||||||
// GIVEN
|
// GIVEN
|
||||||
let amiibos = Fixtures.amiibos
|
let amiibos = Fixtures.amiibos
|
||||||
|
|
||||||
@@ -57,8 +57,8 @@ struct ModelConformanceTests {
|
|||||||
#expect(decoded.first?.platform?.switch.first?.usages?.isEmpty == false)
|
#expect(decoded.first?.platform?.switch.first?.usages?.isEmpty == false)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test("round-trips key-name models through JSON")
|
@Test
|
||||||
func keyNameRoundTrip() throws {
|
func `round-trips key-name models through JSON`() throws {
|
||||||
// GIVEN
|
// GIVEN
|
||||||
// WHEN
|
// WHEN
|
||||||
// THEN
|
// THEN
|
||||||
|
|||||||
@@ -21,8 +21,8 @@ struct AmiiboServiceMockTests {
|
|||||||
|
|
||||||
// MARK: Get Amiibos tests
|
// MARK: Get Amiibos tests
|
||||||
|
|
||||||
@Test("returns empty amiibos when mock provides an empty list")
|
@Test
|
||||||
func getAmiibosEmpty() async throws {
|
func `returns empty amiibos when mock provides an empty list`() async throws {
|
||||||
// GIVEN
|
// GIVEN
|
||||||
let service = AmiiboService(client: AmiiboMockClient(amiibos: []))
|
let service = AmiiboService(client: AmiiboMockClient(amiibos: []))
|
||||||
|
|
||||||
@@ -33,8 +33,8 @@ struct AmiiboServiceMockTests {
|
|||||||
#expect(amiibos.isEmpty)
|
#expect(amiibos.isEmpty)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test("returns amiibos when mock provides a list")
|
@Test
|
||||||
func getAmiibosList() async throws {
|
func `returns amiibos when mock provides a list`() async throws {
|
||||||
// GIVEN
|
// GIVEN
|
||||||
let service = AmiiboService(client: AmiiboMockClient(amiibos: Fixtures.amiibos))
|
let service = AmiiboService(client: AmiiboMockClient(amiibos: Fixtures.amiibos))
|
||||||
|
|
||||||
@@ -47,8 +47,8 @@ struct AmiiboServiceMockTests {
|
|||||||
#expect(amiibos.first?.imageURL != nil)
|
#expect(amiibos.first?.imageURL != nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test("throws notFound when mock provides no amiibos")
|
@Test
|
||||||
func getAmiibosNotFound() async {
|
func `throws notFound when mock provides no amiibos`() async {
|
||||||
// GIVEN
|
// GIVEN
|
||||||
let service = AmiiboService(client: AmiiboMockClient())
|
let service = AmiiboService(client: AmiiboMockClient())
|
||||||
|
|
||||||
@@ -59,8 +59,8 @@ struct AmiiboServiceMockTests {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test("throws error for amiibos when mock is configured with error", arguments: Errors.all)
|
@Test(arguments: Errors.all)
|
||||||
func getAmiibosThrows(error: AmiiboServiceError) async {
|
func `throws error for amiibos when mock is configured with error`(error: AmiiboServiceError) async {
|
||||||
// GIVEN
|
// GIVEN
|
||||||
let service = AmiiboService(client: AmiiboMockClient(error: error))
|
let service = AmiiboService(client: AmiiboMockClient(error: error))
|
||||||
|
|
||||||
@@ -73,8 +73,8 @@ struct AmiiboServiceMockTests {
|
|||||||
|
|
||||||
// MARK: Get Amiibo Series tests
|
// MARK: Get Amiibo Series tests
|
||||||
|
|
||||||
@Test("returns empty amiibo series when mock provides an empty list")
|
@Test
|
||||||
func getAmiiboSeriesEmpty() async throws {
|
func `returns empty amiibo series when mock provides an empty list`() async throws {
|
||||||
// GIVEN
|
// GIVEN
|
||||||
let service = AmiiboService(client: AmiiboMockClient(amiiboSeries: []))
|
let service = AmiiboService(client: AmiiboMockClient(amiiboSeries: []))
|
||||||
|
|
||||||
@@ -85,8 +85,8 @@ struct AmiiboServiceMockTests {
|
|||||||
#expect(amiiboSeries.isEmpty)
|
#expect(amiiboSeries.isEmpty)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test("returns amiibo series when mock provides a list")
|
@Test
|
||||||
func getAmiiboSeriesList() async throws {
|
func `returns amiibo series when mock provides a list`() async throws {
|
||||||
// GIVEN
|
// GIVEN
|
||||||
let service = AmiiboService(client: AmiiboMockClient(amiiboSeries: Fixtures.amiiboSeries))
|
let service = AmiiboService(client: AmiiboMockClient(amiiboSeries: Fixtures.amiiboSeries))
|
||||||
|
|
||||||
@@ -97,8 +97,8 @@ struct AmiiboServiceMockTests {
|
|||||||
#expect(amiiboSeries == Fixtures.amiiboSeries)
|
#expect(amiiboSeries == Fixtures.amiiboSeries)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test("throws notFound when mock provides no amiibo series")
|
@Test
|
||||||
func getAmiiboSeriesNotFound() async {
|
func `throws notFound when mock provides no amiibo series`() async {
|
||||||
// GIVEN
|
// GIVEN
|
||||||
let service = AmiiboService(client: AmiiboMockClient())
|
let service = AmiiboService(client: AmiiboMockClient())
|
||||||
|
|
||||||
@@ -109,8 +109,8 @@ struct AmiiboServiceMockTests {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test("throws error for amiibo series when mock is configured with error", arguments: Errors.all)
|
@Test(arguments: Errors.all)
|
||||||
func getAmiiboSeriesThrows(error: AmiiboServiceError) async {
|
func `throws error for amiibo series when mock is configured with error`(error: AmiiboServiceError) async {
|
||||||
// GIVEN
|
// GIVEN
|
||||||
let service = AmiiboService(client: AmiiboMockClient(error: error))
|
let service = AmiiboService(client: AmiiboMockClient(error: error))
|
||||||
|
|
||||||
@@ -123,8 +123,8 @@ struct AmiiboServiceMockTests {
|
|||||||
|
|
||||||
// MARK: Get Amiibo Types tests
|
// MARK: Get Amiibo Types tests
|
||||||
|
|
||||||
@Test("returns empty amiibo types when mock provides an empty list")
|
@Test
|
||||||
func getAmiiboTypesEmpty() async throws {
|
func `returns empty amiibo types when mock provides an empty list`() async throws {
|
||||||
// GIVEN
|
// GIVEN
|
||||||
let service = AmiiboService(client: AmiiboMockClient(amiiboTypes: []))
|
let service = AmiiboService(client: AmiiboMockClient(amiiboTypes: []))
|
||||||
|
|
||||||
@@ -135,8 +135,8 @@ struct AmiiboServiceMockTests {
|
|||||||
#expect(amiiboTypes.isEmpty)
|
#expect(amiiboTypes.isEmpty)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test("returns amiibo types when mock provides a list")
|
@Test
|
||||||
func getAmiiboTypesList() async throws {
|
func `returns amiibo types when mock provides a list`() async throws {
|
||||||
// GIVEN
|
// GIVEN
|
||||||
let service = AmiiboService(client: AmiiboMockClient(amiiboTypes: Fixtures.amiiboTypes))
|
let service = AmiiboService(client: AmiiboMockClient(amiiboTypes: Fixtures.amiiboTypes))
|
||||||
|
|
||||||
@@ -147,8 +147,8 @@ struct AmiiboServiceMockTests {
|
|||||||
#expect(amiiboTypes == Fixtures.amiiboTypes)
|
#expect(amiiboTypes == Fixtures.amiiboTypes)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test("throws notFound when mock provides no amiibo types")
|
@Test
|
||||||
func getAmiiboTypesNotFound() async {
|
func `throws notFound when mock provides no amiibo types`() async {
|
||||||
// GIVEN
|
// GIVEN
|
||||||
let service = AmiiboService(client: AmiiboMockClient())
|
let service = AmiiboService(client: AmiiboMockClient())
|
||||||
|
|
||||||
@@ -159,8 +159,8 @@ struct AmiiboServiceMockTests {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test("throws error for amiibo types when mock is configured with error", arguments: Errors.all)
|
@Test(arguments: Errors.all)
|
||||||
func getAmiiboTypesThrows(error: AmiiboServiceError) async {
|
func `throws error for amiibo types when mock is configured with error`(error: AmiiboServiceError) async {
|
||||||
// GIVEN
|
// GIVEN
|
||||||
let service = AmiiboService(client: AmiiboMockClient(error: error))
|
let service = AmiiboService(client: AmiiboMockClient(error: error))
|
||||||
|
|
||||||
@@ -173,8 +173,8 @@ struct AmiiboServiceMockTests {
|
|||||||
|
|
||||||
// MARK: Get Game Characters tests
|
// MARK: Get Game Characters tests
|
||||||
|
|
||||||
@Test("returns empty game characters when mock provides an empty list")
|
@Test
|
||||||
func getGameCharactersEmpty() async throws {
|
func `returns empty game characters when mock provides an empty list`() async throws {
|
||||||
// GIVEN
|
// GIVEN
|
||||||
let service = AmiiboService(client: AmiiboMockClient(gameCharacters: []))
|
let service = AmiiboService(client: AmiiboMockClient(gameCharacters: []))
|
||||||
|
|
||||||
@@ -185,8 +185,8 @@ struct AmiiboServiceMockTests {
|
|||||||
#expect(gameCharacters.isEmpty)
|
#expect(gameCharacters.isEmpty)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test("returns game characters when mock provides a list")
|
@Test
|
||||||
func getGameCharactersList() async throws {
|
func `returns game characters when mock provides a list`() async throws {
|
||||||
// GIVEN
|
// GIVEN
|
||||||
let service = AmiiboService(client: AmiiboMockClient(gameCharacters: Fixtures.gameCharacters))
|
let service = AmiiboService(client: AmiiboMockClient(gameCharacters: Fixtures.gameCharacters))
|
||||||
|
|
||||||
@@ -197,8 +197,8 @@ struct AmiiboServiceMockTests {
|
|||||||
#expect(gameCharacters == Fixtures.gameCharacters)
|
#expect(gameCharacters == Fixtures.gameCharacters)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test("throws notFound when mock provides no game characters")
|
@Test
|
||||||
func getGameCharactersNotFound() async {
|
func `throws notFound when mock provides no game characters`() async {
|
||||||
// GIVEN
|
// GIVEN
|
||||||
let service = AmiiboService(client: AmiiboMockClient())
|
let service = AmiiboService(client: AmiiboMockClient())
|
||||||
|
|
||||||
@@ -209,8 +209,8 @@ struct AmiiboServiceMockTests {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test("throws error for game characters when mock is configured with error", arguments: Errors.all)
|
@Test(arguments: Errors.all)
|
||||||
func getGameCharactersThrows(error: AmiiboServiceError) async {
|
func `throws error for game characters when mock is configured with error`(error: AmiiboServiceError) async {
|
||||||
// GIVEN
|
// GIVEN
|
||||||
let service = AmiiboService(client: AmiiboMockClient(error: error))
|
let service = AmiiboService(client: AmiiboMockClient(error: error))
|
||||||
|
|
||||||
@@ -223,8 +223,8 @@ struct AmiiboServiceMockTests {
|
|||||||
|
|
||||||
// MARK: Get Game Series tests
|
// MARK: Get Game Series tests
|
||||||
|
|
||||||
@Test("returns empty game series when mock provides an empty list")
|
@Test
|
||||||
func getGameSeriesEmpty() async throws {
|
func `returns empty game series when mock provides an empty list`() async throws {
|
||||||
// GIVEN
|
// GIVEN
|
||||||
let service = AmiiboService(client: AmiiboMockClient(gameSeries: []))
|
let service = AmiiboService(client: AmiiboMockClient(gameSeries: []))
|
||||||
|
|
||||||
@@ -235,8 +235,8 @@ struct AmiiboServiceMockTests {
|
|||||||
#expect(gameSeries.isEmpty)
|
#expect(gameSeries.isEmpty)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test("returns game series when mock provides a list")
|
@Test
|
||||||
func getGameSeriesList() async throws {
|
func `returns game series when mock provides a list`() async throws {
|
||||||
// GIVEN
|
// GIVEN
|
||||||
let service = AmiiboService(client: AmiiboMockClient(gameSeries: Fixtures.gameSeries))
|
let service = AmiiboService(client: AmiiboMockClient(gameSeries: Fixtures.gameSeries))
|
||||||
|
|
||||||
@@ -247,8 +247,8 @@ struct AmiiboServiceMockTests {
|
|||||||
#expect(gameSeries == Fixtures.gameSeries)
|
#expect(gameSeries == Fixtures.gameSeries)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test("throws notFound when mock provides no game series")
|
@Test
|
||||||
func getGameSeriesNotFound() async {
|
func `throws notFound when mock provides no game series`() async {
|
||||||
// GIVEN
|
// GIVEN
|
||||||
let service = AmiiboService(client: AmiiboMockClient())
|
let service = AmiiboService(client: AmiiboMockClient())
|
||||||
|
|
||||||
@@ -259,8 +259,8 @@ struct AmiiboServiceMockTests {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test("throws error for game series when mock is configured with error", arguments: Errors.all)
|
@Test(arguments: Errors.all)
|
||||||
func getGameSeriesThrows(error: AmiiboServiceError) async {
|
func `throws error for game series when mock is configured with error`(error: AmiiboServiceError) async {
|
||||||
// GIVEN
|
// GIVEN
|
||||||
let service = AmiiboService(client: AmiiboMockClient(error: error))
|
let service = AmiiboService(client: AmiiboMockClient(error: error))
|
||||||
|
|
||||||
@@ -273,8 +273,8 @@ struct AmiiboServiceMockTests {
|
|||||||
|
|
||||||
// MARK: Get Last Updated tests
|
// MARK: Get Last Updated tests
|
||||||
|
|
||||||
@Test("returns date when mock provides a last updated date")
|
@Test
|
||||||
func getLastUpdated() async throws {
|
func `returns date when mock provides a last updated date`() async throws {
|
||||||
// GIVEN
|
// GIVEN
|
||||||
let expectedDate = Date(timeIntervalSince1970: 1_700_000_000)
|
let expectedDate = Date(timeIntervalSince1970: 1_700_000_000)
|
||||||
let service = AmiiboService(client: AmiiboMockClient(lastUpdated: expectedDate))
|
let service = AmiiboService(client: AmiiboMockClient(lastUpdated: expectedDate))
|
||||||
@@ -286,8 +286,8 @@ struct AmiiboServiceMockTests {
|
|||||||
#expect(lastUpdated == expectedDate)
|
#expect(lastUpdated == expectedDate)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test("throws notFound when mock provides no last updated date")
|
@Test
|
||||||
func getLastUpdatedNotFound() async {
|
func `throws notFound when mock provides no last updated date`() async {
|
||||||
// GIVEN
|
// GIVEN
|
||||||
let service = AmiiboService(client: AmiiboMockClient())
|
let service = AmiiboService(client: AmiiboMockClient())
|
||||||
|
|
||||||
@@ -298,8 +298,8 @@ struct AmiiboServiceMockTests {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test("throws error for last updated when mock is configured with error", arguments: Errors.all)
|
@Test(arguments: Errors.all)
|
||||||
func getLastUpdatedThrows(error: AmiiboServiceError) async {
|
func `throws error for last updated when mock is configured with error`(error: AmiiboServiceError) async {
|
||||||
// GIVEN
|
// GIVEN
|
||||||
let service = AmiiboService(client: AmiiboMockClient(error: error))
|
let service = AmiiboService(client: AmiiboMockClient(error: error))
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user