Skip to content

Commit 004de9d

Browse files
Introduce UIFramework.Kind.name
1 parent 8fae11b commit 004de9d

File tree

4 files changed

+15
-7
lines changed

4 files changed

+15
-7
lines changed

Sources/NodesGenerator/UIFramework.swift

+5-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ public struct UIFramework: Equatable, Codable {
1212
case uiKit = "UIKit"
1313
case swiftUI = "SwiftUI"
1414
case custom = "Custom"
15+
16+
public var name: String {
17+
rawValue
18+
}
1519
}
1620

1721
public enum Framework: Equatable, Codable {
@@ -43,7 +47,7 @@ public struct UIFramework: Equatable, Codable {
4347
internal var name: String {
4448
switch self {
4549
case .appKit, .uiKit, .uiKitSwiftUI:
46-
return kind.rawValue
50+
return kind.name
4751
case let .custom(name, _, _, _, _):
4852
return name
4953
}

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.sanitized)-mockCount-\(count)")
34+
named: "\(name)-\(kind.name.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.sanitized)-mockCount-\(count)")
62+
named: "\(name)-\(kind.name.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.sanitized)-mockCount-\(count)")
95+
named: "\(name)-\(kind.name.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.sanitized)-mockCount-\(count)")
130+
named: "\(name)-\(kind.name.sanitized)-mockCount-\(count)")
131131
}
132132
}
133133
}

Tests/NodesGeneratorTests/UIFrameworkKindTests.swift

+4
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,8 @@ final class UIFrameworkKindTests: XCTestCase {
1515
func testRawValues() {
1616
expect(UIFramework.Kind.allCases.map(\.rawValue)) == ["AppKit", "UIKit", "SwiftUI", "Custom"]
1717
}
18+
19+
func testNames() {
20+
expect(UIFramework.Kind.allCases.map(\.name)) == ["AppKit", "UIKit", "SwiftUI", "Custom"]
21+
}
1822
}

Tests/NodesGeneratorTests/UIFrameworkTests.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -107,13 +107,13 @@ 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.sanitized) }
110+
.forEach { assertSnapshot(of: $0, as: .dump, named: $0.kind.name.sanitized) }
111111
}
112112

113113
private func givenYAML(for kind: UIFramework.Kind) -> String {
114114
switch kind {
115115
case .appKit, .uiKit, .swiftUI:
116-
return "framework: \(kind.rawValue)"
116+
return "framework: \(kind.name)"
117117
case .custom:
118118
return """
119119
framework:

0 commit comments

Comments
 (0)