-
Notifications
You must be signed in to change notification settings - Fork 338
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Paywalls V2] Optionalizing padding, margin, and corner radius proper…
…ties for safety (#4644) * I thought I removed this change but did so oops * Optional properties on padding/margin for safety * Optionalizing properties that can easily default to zero for safety
- Loading branch information
1 parent
069df52
commit 0e37a9c
Showing
8 changed files
with
147 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
Tests/UnitTests/Paywalls/Components/Properties/CornerRadiusesPropertyTests.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import Nimble | ||
@testable import RevenueCat | ||
import XCTest | ||
|
||
#if PAYWALL_COMPONENTS | ||
|
||
class CornerRadiusesPropertyTests: TestCase { | ||
|
||
func testAllValues() throws { | ||
let json = """ | ||
{ | ||
"top_leading": 5, | ||
"top_trailing": 5, | ||
"bottom_leading": 5, | ||
"bottom_trailing": 5 | ||
} | ||
""" | ||
|
||
_ = try JSONDecoder.default.decode( | ||
PaywallComponent.CornerRadiuses.self, | ||
from: json.data(using: .utf8)! | ||
) | ||
} | ||
|
||
func testNullValues() throws { | ||
let json = """ | ||
{ | ||
"top_leading": null, | ||
"top_trailing": null, | ||
"bottom_leading": null, | ||
"bottom_trailing": null | ||
} | ||
""" | ||
|
||
_ = try JSONDecoder.default.decode( | ||
PaywallComponent.CornerRadiuses.self, | ||
from: json.data(using: .utf8)! | ||
) | ||
} | ||
|
||
func testEmptyObject() throws { | ||
let json = """ | ||
{} | ||
""" | ||
|
||
_ = try JSONDecoder.default.decode( | ||
PaywallComponent.CornerRadiuses.self, | ||
from: json.data(using: .utf8)! | ||
) | ||
} | ||
|
||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
Tests/UnitTests/Paywalls/Components/Properties/PaddingPropertyTests.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import Nimble | ||
@testable import RevenueCat | ||
import XCTest | ||
|
||
#if PAYWALL_COMPONENTS | ||
|
||
class PaddingPropertyTests: TestCase { | ||
|
||
func testAllValues() throws { | ||
let json = """ | ||
{ | ||
"top": 5, | ||
"bottom": 5, | ||
"leading": 5, | ||
"trailing": 5 | ||
} | ||
""" | ||
|
||
_ = try JSONDecoder.default.decode( | ||
PaywallComponent.Padding.self, | ||
from: json.data(using: .utf8)! | ||
) | ||
} | ||
|
||
func testNullValues() throws { | ||
let json = """ | ||
{ | ||
"top": null, | ||
"bottom": null, | ||
"leading": null, | ||
"trailing": null | ||
} | ||
""" | ||
|
||
_ = try JSONDecoder.default.decode( | ||
PaywallComponent.Padding.self, | ||
from: json.data(using: .utf8)! | ||
) | ||
} | ||
|
||
func testEmptyObject() throws { | ||
let json = """ | ||
{} | ||
""" | ||
|
||
_ = try JSONDecoder.default.decode( | ||
PaywallComponent.Padding.self, | ||
from: json.data(using: .utf8)! | ||
) | ||
} | ||
|
||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters