Files
purchases-ios/Tests/UnitTests/Networking/Responses/UIConfigDecodingTests.swift
T
Antonio Pallares 81aaf6a051 Offering hasPaywall getter (#4847)
* feat: add `hasPaywall` getter to `Offering`

Returns `true` if the offering has either a v1 or a v2 paywall

* docs: update some methods references changing `PaywallData` with "paywall", as `PaywallData` only refers to v1 paywalls

* docs: improve reference of `Offering`'s `paywall` and `paywallComponents` to mention the new `hasPaywall` property

* lint

* tests: add unit tests that check the `hasPaywall` property of `Offering`

* api tests: add `paywallComponents` and `hasPaywall` to SwiftAPITester
2025-03-04 12:09:53 +01:00

62 lines
1.7 KiB
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
//
// UIConfigDecodingTests.swift
//
// Created by Josh Holtz on 12/31/24.
import Nimble
@testable import RevenueCat
import XCTest
#if !os(macOS) && !os(tvOS) // For Paywalls V2
class UIConfigDecodingTests: BaseHTTPResponseTest {
func testDecodesPaywallData() throws {
let uiConfig: UIConfig = try Self.decodeFixture("UIConfig")
expect(uiConfig.app.colors).to(equal([
"primary": .init(light: .hex("#ffcc00")),
"secondary": .init(light: .linear(45, [
.init(color: "#032400ff", percent: 0),
.init(color: "#090979ff", percent: 35),
.init(color: "#216c32ff", percent: 100)
])),
"tertiary": .init(light: .radial([
.init(color: "#032400ff", percent: 0),
.init(color: "#090979ff", percent: 35),
.init(color: "#216c32ff", percent: 100)
]))
]))
expect(uiConfig.app.fonts).to(equal([
"primary": .init(ios: .name("SF Pro"))
]))
expect(uiConfig.localizations).to(equal([
"en_US": [
"monthly": "monthly"
],
"es_ES": [
"monthly": "mensual"
]
]))
expect(uiConfig.variableConfig.variableCompatibilityMap).to(equal([
"new var": "guaranteed var"
]))
expect(uiConfig.variableConfig.functionCompatibilityMap).to(equal([
"new fun": "guaranteed fun"
]))
}
}
#endif