Skip to content

Commit 8fae11b

Browse files
Introduce Sanitized var on String in tests (#780)
Introduce sanitized var on String
1 parent 0384309 commit 8fae11b

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

Tests/NodesGeneratorTests/StencilRendererTests.swift

+4-4
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ final class StencilRendererTests: XCTestCase, TestFactories {
3131
templates.forEach { name, template in
3232
assertSnapshot(of: template,
3333
as: .lines,
34-
named: "\(name)-\(kind.rawValue)-mockCount-\(count)")
34+
named: "\(name)-\(kind.rawValue.sanitized)-mockCount-\(count)")
3535
}
3636
}
3737
}
@@ -59,7 +59,7 @@ final class StencilRendererTests: XCTestCase, TestFactories {
5959
templates.forEach { name, template in
6060
assertSnapshot(of: template,
6161
as: .lines,
62-
named: "\(name)-\(kind.rawValue)-mockCount-\(count)")
62+
named: "\(name)-\(kind.rawValue.sanitized)-mockCount-\(count)")
6363
}
6464
}
6565
}
@@ -92,7 +92,7 @@ final class StencilRendererTests: XCTestCase, TestFactories {
9292
templates.forEach { name, template in
9393
assertSnapshot(of: template,
9494
as: .lines,
95-
named: "\(name)-\(kind.rawValue)-mockCount-\(count)")
95+
named: "\(name)-\(kind.rawValue.sanitized)-mockCount-\(count)")
9696
}
9797
}
9898
}
@@ -127,7 +127,7 @@ final class StencilRendererTests: XCTestCase, TestFactories {
127127
templates.forEach { name, template in
128128
assertSnapshot(of: template,
129129
as: .lines,
130-
named: "\(name)-\(kind.rawValue)-mockCount-\(count)")
130+
named: "\(name)-\(kind.rawValue.sanitized)-mockCount-\(count)")
131131
}
132132
}
133133
}

Tests/NodesGeneratorTests/Support/String.swift

+6
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,14 @@
22
// Copyright © 2023 Tinder (Match Group, LLC)
33
//
44

5+
import Foundation
6+
57
extension String {
68

9+
internal var sanitized: String {
10+
String(unicodeScalars.filter(CharacterSet.alphanumerics.contains))
11+
}
12+
713
internal func replacingOccurrences(
814
of targets: [String],
915
with replacement: String

Tests/NodesGeneratorTests/UIFrameworkTests.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ final class UIFrameworkTests: XCTestCase {
107107
.map(\.utf8)
108108
.map(Data.init(_:))
109109
.map { try $0.decoded(as: UIFramework.self, using: YAMLDecoder()) }
110-
.forEach { assertSnapshot(of: $0, as: .dump, named: $0.kind.rawValue) }
110+
.forEach { assertSnapshot(of: $0, as: .dump, named: $0.kind.rawValue.sanitized) }
111111
}
112112

113113
private func givenYAML(for kind: UIFramework.Kind) -> String {

0 commit comments

Comments
 (0)