Added cursor pagination support to paged operations.
This commit is contained in:
1 parent
fde2382056
commit
c984be3263
7 files changed
+4340
-4
No files matched your search
@@ -0,0 +1,51 @@
|
||||
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"
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user