Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PackageTypeTests: fixed iOS 12 #2807

Merged
merged 1 commit into from
Jul 14, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions Tests/UnitTests/Purchasing/PackageTypeTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ class PackageTypeTests: TestCase {
func testCodable() throws {
for type in PackageType.allCases where type != .custom {
do {
let encoded = try type.encodeAndDecode()
let encoded = try Data(type: type).encodeAndDecode()

expect(encoded).to(
expect(encoded.type).to(
equal(type),
description: "Failed encoding '\(type.debugDescription)'"
)
Expand All @@ -37,7 +37,16 @@ class PackageTypeTests: TestCase {

func testEncodingCustom() throws {
// We don't have a way to tell this appart from `.unknown`
expect(try PackageType.custom.encodeAndDecode()) == .unknown
expect(try Data(type: .custom).encodeAndDecode().type) == .unknown
}

}

private extension PackageTypeTests {

/// iOS 12 does not allow literalls as root types, so we test encoding it inside of a dictionary
struct Data: Codable {
var type: PackageType
}

}