From 2eba81888c722d5ab3be0fae455b3c8fa0c03869 Mon Sep 17 00:00:00 2001 From: Sergey Kazakov Date: Sun, 16 Jun 2024 20:16:29 +0100 Subject: [PATCH] Add watchOS and tvOS platforms support (#15) * added support for watchOS and tvOS platforms * added compile directive to snapshot tests due to SnapshotTesting lib limitations * lint --- Package.swift | 4 +++- .../SegmentedPickerTests/CapsuleSelectionViewTests.swift | 3 +++ .../UnderlineSelectionViewTests.swift | 8 +++++++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/Package.swift b/Package.swift index 163f983..662f9ca 100644 --- a/Package.swift +++ b/Package.swift @@ -7,7 +7,9 @@ let package = Package( name: "SegmentedPicker", platforms: [ .iOS(.v13), - .macOS(.v10_15) + .macOS(.v10_15), + .watchOS(.v6), + .tvOS(.v13) ], products: [ .library( diff --git a/Tests/SegmentedPickerTests/CapsuleSelectionViewTests.swift b/Tests/SegmentedPickerTests/CapsuleSelectionViewTests.swift index 3d6230b..6aa2689 100644 --- a/Tests/SegmentedPickerTests/CapsuleSelectionViewTests.swift +++ b/Tests/SegmentedPickerTests/CapsuleSelectionViewTests.swift @@ -11,7 +11,9 @@ import XCTest import SnapshotTesting @testable import SegmentedPicker +#if os(iOS) || os(tvOS) final class CapsuleSelectionViewTests: XCTestCase { + func test_WhenSelectionIsNotProvided_SelectionIsNotVisible_Snapshot() { let view = CapsuleSelectionView(titles: ["One", "Two", "Three"]) assertSnapshots(of: view, as: [.image(layout: .device(config: .iPhone13))]) @@ -22,3 +24,4 @@ final class CapsuleSelectionViewTests: XCTestCase { assertSnapshots(of: view, as: [.image(layout: .device(config: .iPhone13))]) } } +#endif diff --git a/Tests/SegmentedPickerTests/UnderlineSelectionViewTests.swift b/Tests/SegmentedPickerTests/UnderlineSelectionViewTests.swift index 1c22700..819cdae 100644 --- a/Tests/SegmentedPickerTests/UnderlineSelectionViewTests.swift +++ b/Tests/SegmentedPickerTests/UnderlineSelectionViewTests.swift @@ -4,14 +4,19 @@ // // Created by Sergey Kazakov on 15/06/2024. // - import SwiftUI import UIKit import XCTest import SnapshotTesting @testable import SegmentedPicker +extension CGSize { + static let testView: CGSize = CGSize(width: 390, height: 844) +} + +#if os(iOS) || os(tvOS) final class UnderlineSelectionViewTest: XCTestCase { + func test_WhenSelectionIsNotProvided_SelectionIsNotVisible_Snapshot() { let view = UnderlineSelectionView(titles: ["One", "Two", "Three"]) assertSnapshots(of: view, as: [.image(layout: .device(config: .iPhone13))]) @@ -22,3 +27,4 @@ final class UnderlineSelectionViewTest: XCTestCase { assertSnapshots(of: view, as: [.image(layout: .device(config: .iPhone13))]) } } +#endif