From 7023ae44d3f313b9cdf78c685bec6fc7f2216f6e Mon Sep 17 00:00:00 2001 From: Naomi Plasterer Date: Wed, 13 Sep 2023 15:01:14 -0700 Subject: [PATCH] add a test for it --- Sources/XMTPTestHelpers/TestHelpers.swift | 9 +++++++++ Tests/XMTPTests/IntegrationTests.swift | 6 ++++++ 2 files changed, 15 insertions(+) diff --git a/Sources/XMTPTestHelpers/TestHelpers.swift b/Sources/XMTPTestHelpers/TestHelpers.swift index d0f568af..eb67dac6 100644 --- a/Sources/XMTPTestHelpers/TestHelpers.swift +++ b/Sources/XMTPTestHelpers/TestHelpers.swift @@ -197,6 +197,15 @@ public class FakeApiClient: ApiClient { } } } + + if let direction = pagination?.direction { + switch direction { + case .ascending: + result = Array(result.reversed()) + default: + break + } + } var queryResponse = QueryResponse() queryResponse.envelopes = result diff --git a/Tests/XMTPTests/IntegrationTests.swift b/Tests/XMTPTests/IntegrationTests.swift index bdc84b71..be93d24f 100644 --- a/Tests/XMTPTests/IntegrationTests.swift +++ b/Tests/XMTPTests/IntegrationTests.swift @@ -414,6 +414,12 @@ final class IntegrationTests: XCTestCase { XCTAssertEqual(1, messages3.count) let nowMessage2 = messages3[0] XCTAssertEqual("now", nowMessage2.body) + + let messagesAsc = try await convo.messages(direction: .ascending) + XCTAssertEqual("10 seconds ago", messagesAsc[0].body) + + let messagesDesc = try await convo.messages(direction: .descending) + XCTAssertEqual("now", messagesDesc[0].body) } func testStreamingMessagesShouldBeReceived() async throws {