Skip to content

Commit

Permalink
updated Tests
Browse files Browse the repository at this point in the history
- Client: added tests for automatic version pinning
- Client: added test for listSheets/listVersions
- NpcYell: added test for implied closure
  • Loading branch information
Eisenhuth committed Jan 5, 2025
1 parent f817721 commit 912e0ce
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
24 changes: 24 additions & 0 deletions Tests/xivapi-swiftTests/Client+Tests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import xivapi_swift
@Suite("Client")
struct Client_Tests {
let xivapi = xivapiClient()
let xivapiPinned = xivapiClient(automaticallyPin: true)

//MARK: commonly used
@Test("Search: Name (Recipe/Item)") func TestSearch() async throws {
Expand Down Expand Up @@ -39,6 +40,11 @@ struct Client_Tests {
#expect(item.name == "Grade 2 Gemdraught of Strength")
}

@Test("Decode Item /w Version & Schema") func DecodeItem2() async throws {
let item = try #require(await xivapiPinned.getItem(44162))
#expect(item.name == "Grade 2 Gemdraught of Strength")
}

@Test("Decode ItemMinimal") func DecodeItemMinimal() async throws {
let itemMinimal = try #require(await xivapi.getItemMinimal(44162))
#expect(itemMinimal.name == "Grade 2 Gemdraught of Strength")
Expand Down Expand Up @@ -77,5 +83,23 @@ struct Client_Tests {
@Test("Decode Town") func DecodeTown() async throws { #expect(await xivapi.getSheet(.Town, id: 1) as Town? != nil) }
@Test("Decode TripleTriadCard") func DecodeTripleTriadCard() async throws { #expect(await xivapi.getSheet(.TripleTriadCard, id: 346) as TripleTriadCard? != nil) }

//MARK: others
@Test("List Versions") func ListVersions() async throws {
let versions = try #require(await xivapi.listVersions())
#expect(versions.count > 1)
#expect(versions.contains("latest"))
}

@Test("List Sheets") func ListSheets() async throws {
let sheets = try #require(await xivapi.listSheets())
#expect(sheets.count > 100)
}

@Test("Test Pin") func TestPin() async throws {
#expect(xivapiPinned.version == verifiedVersion)
#expect(xivapiPinned.schema == verifiedSchema)
#expect(xivapi.version == nil)
#expect(xivapi.schema == nil)
#expect(xivapiPinned.assetUrl(at: "") != xivapi.assetUrl(at: "test"))
}
}
5 changes: 4 additions & 1 deletion Tests/xivapi-swiftTests/NpcYell+Tests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ struct NpcYell_Tests {
#expect(quote.Text_kr == nil)
}

@Test func NpcYell2() async throws { #expect(await xivapi.getNpcYell(6492) != nil) }
@Test func NpcYell2() async throws {
let quote = try #require(await xivapi.getNpcYell(6492))
#expect(quote.Text_en == "O hallowed moon,\nshine you the iron path!")
}

}
2 changes: 2 additions & 0 deletions Tests/xivapi-swiftTests/Recipe+Tests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ struct Recipe_Tests {
#expect(recipe.ingredients.first != recipe.ingredients.last)
#expect(recipe.recipeLevelTable.fields.Stars == 2)
#expect(recipe.ingredients.contains { $0.itemId == 44051 })
let firstIngredient = recipe.ingredients.first
#expect(firstIngredient?.id == firstIngredient?.itemId)
}

}

0 comments on commit 912e0ce

Please sign in to comment.