mirror of
https://github.com/RevenueCat/purchases-ios
synced 2026-11-11 22:55:55 +05:45
Example:
```diff
- var result: Result<Offerings, OfferingsManager.Error>?
- offeringsManager.offerings(appUserID: MockData.anyAppUserID) {
- result = $0
+ let result = waitUntilValue { completed in
+ self.offeringsManager.offerings(appUserID: MockData.anyAppUserID) {
+ completed($0)
+ }
}
- expect(result).toEventuallyNot(beNil())
```
This removes the need to _poll_ for when the value is returned, and
instead it gets detected immediately, potentially providing a
significant boost in test execution speed.
I've also used `Nimble`'s own `waitUntil` for cases where we don't need
to return a value.
#### `toEventually` usage:
- Before this PR: 353
- After: 229
There's still a lot of legitimate usage of `toEventually`, but I'm sure
I missed other places where this can also simplify the code. This is a
good start for now.
35 lines
889 B
Swift
35 lines
889 B
Swift
//
|
|
// Copyright RevenueCat Inc. All Rights Reserved.
|
|
//
|
|
// Licensed under the MIT License (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// https://opensource.org/licenses/MIT
|
|
//
|
|
// BackendPostSubscriberAttributesTests.swift
|
|
//
|
|
// Created by Nacho Soto on 3/7/22.
|
|
|
|
import Foundation
|
|
import Nimble
|
|
import XCTest
|
|
|
|
@testable import RevenueCat
|
|
|
|
class BackendPostSubscriberAttributesTests: BaseBackendTests {
|
|
|
|
override func createClient() -> MockHTTPClient {
|
|
super.createClient(#file)
|
|
}
|
|
|
|
func testPostingWithNoSubscriberAttributesProducesAnError() {
|
|
let error = waitUntilValue { completed in
|
|
self.backend.post(subscriberAttributes: [:], appUserID: "testUserID", completion: completed)
|
|
}
|
|
|
|
expect(error) == .emptySubscriberAttributes()
|
|
}
|
|
|
|
}
|