Files
asconnect-service/Tests/ASConnectService/Cases/Public/Extensions/PagedDocumentLinksTests.swift
T

51 lines
1.5 KiB
Swift
Raw Normal View History

import Testing
// A non-testable import ensures that the extension can be used from outside the module.
import ASConnectService
@Suite("PagedDocumentLinks")
struct PagedDocumentLinksTests {
// MARK: Tests
@Test("Returns the cursor from the next link")
func returnsNextCursor() {
let links = Components.Schemas.PagedDocumentLinks(
_self: .Link.current,
next: "https://api.appstoreconnect.apple.com/v1/apps?cursor=Mg.ANmP3sY&limit=2"
)
#expect(links.nextCursor == "Mg.ANmP3sY")
}
@Test("Returns nil when there is no next link")
func returnsNilWithoutNextLink() {
let links = Components.Schemas.PagedDocumentLinks(_self: .Link.current)
#expect(links.nextCursor == nil)
}
@Test("Returns nil when the next link has no cursor")
func returnsNilWithoutCursor() {
let links = Components.Schemas.PagedDocumentLinks(
_self: .Link.current,
next: "https://api.appstoreconnect.apple.com/v1/apps?limit=2"
)
#expect(links.nextCursor == nil)
}
@Test("Passes the cursor to the query of a paged operation")
func passesCursorToQuery() {
let query = Operations.AppsGetCollection.Input.Query(limit: 2, cursor: "Mg.ANmP3sY")
#expect(query.cursor == "Mg.ANmP3sY")
}
}
// MARK: - String+Samples
private extension String {
enum Link {
static let current: String = "https://api.appstoreconnect.apple.com/v1/apps?limit=2"
}
}