Skip to content

Commit 264a06c

Browse files
Introduce SnapshotTestingExtensions
1 parent fabb32d commit 264a06c

File tree

6 files changed

+49
-23
lines changed

6 files changed

+49
-23
lines changed

Package.swift

+10
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ let package = Package(
1111
.library(
1212
name: "Layout",
1313
targets: ["Layout"]),
14+
.library(
15+
name: "SnapshotTestingExtensions",
16+
targets: ["SnapshotTestingExtensions"]),
1417
],
1518
dependencies: [
1619
.package(
@@ -23,11 +26,18 @@ let package = Package(
2326
targets: [
2427
.target(
2528
name: "Layout"),
29+
.target(
30+
name: "SnapshotTestingExtensions",
31+
swiftSettings: .swiftSettings,
32+
plugins: [
33+
.plugin(name: SwiftLint.plugin),
34+
]),
2635
.testTarget(
2736
name: "LayoutTests",
2837
dependencies: [
2938
"Layout",
3039
"Nimble",
40+
"SnapshotTestingExtensions",
3141
.product(name: "SnapshotTesting", package: "swift-snapshot-testing"),
3242
],
3343
exclude: [

[email protected]

+10
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ let package = Package(
1818
.library(
1919
name: "Layout",
2020
targets: ["Layout"]),
21+
.library(
22+
name: "SnapshotTestingExtensions",
23+
targets: ["SnapshotTestingExtensions"]),
2124
],
2225
dependencies: [
2326
.package(
@@ -34,11 +37,18 @@ let package = Package(
3437
plugins: [
3538
.plugin(name: SwiftLint.plugin),
3639
]),
40+
.target(
41+
name: "SnapshotTestingExtensions",
42+
swiftSettings: .swiftSettings,
43+
plugins: [
44+
.plugin(name: SwiftLint.plugin),
45+
]),
3746
.testTarget(
3847
name: "LayoutTests",
3948
dependencies: [
4049
"Layout",
4150
"Nimble",
51+
"SnapshotTestingExtensions",
4252
.product(name: "SnapshotTesting", package: "swift-snapshot-testing"),
4353
],
4454
exclude: [

[email protected]

+10
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ let package = Package(
1818
.library(
1919
name: "Layout",
2020
targets: ["Layout"]),
21+
.library(
22+
name: "SnapshotTestingExtensions",
23+
targets: ["SnapshotTestingExtensions"]),
2124
],
2225
dependencies: [
2326
.package(
@@ -34,11 +37,18 @@ let package = Package(
3437
plugins: [
3538
.plugin(name: SwiftLint.plugin),
3639
]),
40+
.target(
41+
name: "SnapshotTestingExtensions",
42+
swiftSettings: .swiftSettings,
43+
plugins: [
44+
.plugin(name: SwiftLint.plugin),
45+
]),
3746
.testTarget(
3847
name: "LayoutTests",
3948
dependencies: [
4049
"Layout",
4150
"Nimble",
51+
"SnapshotTestingExtensions",
4252
.product(name: "SnapshotTesting", package: "swift-snapshot-testing"),
4353
],
4454
exclude: [

Tests/LayoutTests/Support/UITraitCollection.swift Sources/SnapshotTestingExtensions/UITraitCollection.swift

+13-13
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// All Contributions by Match Group
33
//
4-
// Copyright © 2023 Tinder (Match Group, LLC)
4+
// Copyright © 2024 Tinder (Match Group, LLC)
55
//
66
// Licensed under the Match Group Modified 3-Clause BSD License.
77
// See https://github.com/Tinder/Layout/blob/main/LICENSE for license information.
@@ -19,16 +19,16 @@ extension UITraitCollection {
1919
UITraitCollection(preferredContentSizeCategory: .medium),
2020
UITraitCollection(userInterfaceIdiom: .phone)
2121
]
22-
switch orientation {
22+
return switch orientation {
2323
case .landscape:
24-
return UITraitCollection(
24+
UITraitCollection(
2525
traitsFrom: base + [
2626
UITraitCollection(horizontalSizeClass: .regular),
2727
UITraitCollection(verticalSizeClass: .compact)
2828
]
2929
)
3030
case .portrait:
31-
return UITraitCollection(
31+
UITraitCollection(
3232
traitsFrom: base + [
3333
UITraitCollection(horizontalSizeClass: .compact),
3434
UITraitCollection(verticalSizeClass: .regular)
@@ -44,16 +44,16 @@ extension UITraitCollection {
4444
UITraitCollection(preferredContentSizeCategory: .medium),
4545
UITraitCollection(userInterfaceIdiom: .phone)
4646
]
47-
switch orientation {
47+
return switch orientation {
4848
case .landscape:
49-
return UITraitCollection(
49+
UITraitCollection(
5050
traitsFrom: base + [
5151
UITraitCollection(horizontalSizeClass: .regular),
5252
UITraitCollection(verticalSizeClass: .compact)
5353
]
5454
)
5555
case .portrait:
56-
return UITraitCollection(
56+
UITraitCollection(
5757
traitsFrom: base + [
5858
UITraitCollection(horizontalSizeClass: .compact),
5959
UITraitCollection(verticalSizeClass: .regular)
@@ -69,16 +69,16 @@ extension UITraitCollection {
6969
UITraitCollection(preferredContentSizeCategory: .medium),
7070
UITraitCollection(userInterfaceIdiom: .phone)
7171
]
72-
switch orientation {
72+
return switch orientation {
7373
case .landscape:
74-
return UITraitCollection(
74+
UITraitCollection(
7575
traitsFrom: base + [
7676
UITraitCollection(horizontalSizeClass: .regular),
7777
UITraitCollection(verticalSizeClass: .compact)
7878
]
7979
)
8080
case .portrait:
81-
return UITraitCollection(
81+
UITraitCollection(
8282
traitsFrom: base + [
8383
UITraitCollection(horizontalSizeClass: .compact),
8484
UITraitCollection(verticalSizeClass: .regular)
@@ -94,16 +94,16 @@ extension UITraitCollection {
9494
UITraitCollection(preferredContentSizeCategory: .medium),
9595
UITraitCollection(userInterfaceIdiom: .phone)
9696
]
97-
switch orientation {
97+
return switch orientation {
9898
case .landscape:
99-
return UITraitCollection(
99+
UITraitCollection(
100100
traitsFrom: base + [
101101
UITraitCollection(horizontalSizeClass: .regular),
102102
UITraitCollection(verticalSizeClass: .compact)
103103
]
104104
)
105105
case .portrait:
106-
return UITraitCollection(
106+
UITraitCollection(
107107
traitsFrom: base + [
108108
UITraitCollection(horizontalSizeClass: .compact),
109109
UITraitCollection(verticalSizeClass: .regular)

Tests/LayoutTests/Support/ViewImageConfig.swift Sources/SnapshotTestingExtensions/ViewImageConfig.swift

+5-10
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// All Contributions by Match Group
33
//
4-
// Copyright © 2023 Tinder (Match Group, LLC)
4+
// Copyright © 2024 Tinder (Match Group, LLC)
55
//
66
// Licensed under the Match Group Modified 3-Clause BSD License.
77
// See https://github.com/Tinder/Layout/blob/main/LICENSE for license information.
@@ -12,12 +12,7 @@ import UIKit
1212

1313
extension ViewImageConfig {
1414

15-
internal static let iPhone14: ViewImageConfig = .iPhone14(.portrait)
16-
internal static let iPhone14Plus: ViewImageConfig = .iPhone14Plus(.portrait)
17-
internal static let iPhone14Pro: ViewImageConfig = .iPhone14Pro(.portrait)
18-
internal static let iPhone14ProMax: ViewImageConfig = .iPhone14ProMax(.portrait)
19-
20-
internal static func iPhone14(_ orientation: Orientation) -> ViewImageConfig {
15+
public static func iPhone14(_ orientation: Orientation) -> ViewImageConfig {
2116
let safeArea: UIEdgeInsets
2217
let size: CGSize
2318
switch orientation {
@@ -31,7 +26,7 @@ extension ViewImageConfig {
3126
return ViewImageConfig(safeArea: safeArea, size: size, traits: .iPhone14(orientation))
3227
}
3328

34-
internal static func iPhone14Plus(_ orientation: Orientation) -> ViewImageConfig {
29+
public static func iPhone14Plus(_ orientation: Orientation) -> ViewImageConfig {
3530
let safeArea: UIEdgeInsets
3631
let size: CGSize
3732
switch orientation {
@@ -45,7 +40,7 @@ extension ViewImageConfig {
4540
return ViewImageConfig(safeArea: safeArea, size: size, traits: .iPhone14Plus(orientation))
4641
}
4742

48-
internal static func iPhone14Pro(_ orientation: Orientation) -> ViewImageConfig {
43+
public static func iPhone14Pro(_ orientation: Orientation) -> ViewImageConfig {
4944
let safeArea: UIEdgeInsets
5045
let size: CGSize
5146
switch orientation {
@@ -59,7 +54,7 @@ extension ViewImageConfig {
5954
return ViewImageConfig(safeArea: safeArea, size: size, traits: .iPhone14Pro(orientation))
6055
}
6156

62-
internal static func iPhone14ProMax(_ orientation: Orientation) -> ViewImageConfig {
57+
public static func iPhone14ProMax(_ orientation: Orientation) -> ViewImageConfig {
6358
let safeArea: UIEdgeInsets
6459
let size: CGSize
6560
switch orientation {

Tests/LayoutTests/Support/SnapshotTesting.swift

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
import Nimble
1212
import SnapshotTesting
13+
import SnapshotTestingExtensions
1314
import UIKit
1415
import XCTest
1516

0 commit comments

Comments
 (0)