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

65 lines
2.0 KiB
Swift
Raw Normal View History

// ===----------------------------------------------------------------------===
//
// This source file is part of the ASConnectService open source project
//
// Copyright (c) 2026 Röck+Cöde VoF. and the ASConnectService project authors
// Licensed under Apache license v2.0
//
// See LICENSE for license information
// See CONTRIBUTORS for the list of ASConnectService project authors
//
// SPDX-License-Identifier: Apache-2.0
//
// ===----------------------------------------------------------------------===
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"
}
}