Skip to content

Commit 92a0398

Browse files
Mark Pospeselmpospese
authored andcommitted
[Issue-68] Fix unit tests that fail in Bold Text mode
1 parent 23592a5 commit 92a0398

File tree

5 files changed

+34
-9
lines changed

5 files changed

+34
-9
lines changed

Tests/YMatterTypeTests/Elements/TypographyButtonTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ final class TypographyButtonTests: TypographyElementTests {
160160
sut.typography.lineHeight * 2 + sut.contentEdgeInsets.vertical
161161
)
162162

163-
let fontFamily = DefaultFontFamily(familyName: "AvenirNext")
163+
let fontFamily = AvenirNextFontFamily()
164164
let typography = Typography(
165165
fontFamily: fontFamily,
166166
fontWeight: .bold,
@@ -423,7 +423,7 @@ final class TypographyButtonTests: TypographyElementTests {
423423
private extension TypographyButtonTests {
424424
func makeSUT(spacing: CGFloat = 0, file: StaticString = #filePath, line: UInt = #line) -> MockButton {
425425
let typography = Typography(
426-
familyName: "NotoSans",
426+
fontFamily: Typography.notoSans,
427427
fontWeight: .regular,
428428
fontSize: 16,
429429
lineHeight: 24,

Tests/YMatterTypeTests/Elements/TypographyLabelTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ final class TypographyLabelTests: TypographyElementTests {
144144
// we expect label height to be a multiple of the old lineHeight
145145
XCTAssertEqual(sut.intrinsicContentSize.height, sut.typography.lineHeight * 2)
146146

147-
let fontFamily = DefaultFontFamily(familyName: "AvenirNext")
147+
let fontFamily = AvenirNextFontFamily()
148148
let typography = Typography(
149149
fontFamily: fontFamily,
150150
fontWeight: .bold,
@@ -364,7 +364,7 @@ private extension TypographyLabelTests {
364364
line: UInt = #line
365365
) -> MockLabel {
366366
let typography = Typography(
367-
familyName: "NotoSans",
367+
fontFamily: Typography.notoSans,
368368
fontWeight: .regular,
369369
fontSize: 24,
370370
lineHeight: 32,

Tests/YMatterTypeTests/Elements/TypographyTextFieldTests.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ final class TypographyTextFieldTests: TypographyElementTests {
8383
// we expect text field height to equal the old lineHeight
8484
XCTAssertEqual(sut.intrinsicContentSize.height, sut.typography.lineHeight)
8585

86-
let fontFamily = DefaultFontFamily(familyName: "AvenirNext")
86+
let fontFamily = AvenirNextFontFamily()
8787
let typography = Typography(
8888
fontFamily: fontFamily,
8989
fontWeight: .bold,
@@ -211,7 +211,7 @@ final class TypographyTextFieldTests: TypographyElementTests {
211211
XCTAssertEqual(sut.intrinsicContentSize.height, sut.typography.lineHeight)
212212

213213
// changing the typograhy will restyle the attributed text
214-
let fontFamily = DefaultFontFamily(familyName: "AvenirNext")
214+
let fontFamily = AvenirNextFontFamily()
215215
sut.typography = Typography(
216216
fontFamily: fontFamily,
217217
fontWeight: .bold,
@@ -299,7 +299,7 @@ final class TypographyTextFieldTests: TypographyElementTests {
299299
private extension TypographyTextFieldTests {
300300
func makeSUT(file: StaticString = #filePath, line: UInt = #line) -> MockTextField {
301301
let typography = Typography(
302-
familyName: "NotoSans",
302+
fontFamily: Typography.notoSans,
303303
fontWeight: .regular,
304304
fontSize: 13,
305305
lineHeight: 20,

Tests/YMatterTypeTests/Elements/TypographyTextViewTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ final class TypographyTextViewTests: TypographyElementTests {
109109
// we expect label height to be a multiple of the old lineHeight
110110
XCTAssertEqual(sut.intrinsicContentSize.height, sut.typography.lineHeight * 2)
111111

112-
let fontFamily = DefaultFontFamily(familyName: "AvenirNext")
112+
let fontFamily = AvenirNextFontFamily()
113113
let typography = Typography(
114114
fontFamily: fontFamily,
115115
fontWeight: .bold,
@@ -302,7 +302,7 @@ final class TypographyTextViewTests: TypographyElementTests {
302302
private extension TypographyTextViewTests {
303303
func makeSUT(spacing: CGFloat = 0, file: StaticString = #filePath, line: UInt = #line) -> MockTextView {
304304
let typography = Typography(
305-
familyName: "NotoSans",
305+
fontFamily: Typography.notoSans,
306306
fontWeight: .regular,
307307
fontSize: 22,
308308
lineHeight: 28,

Tests/YMatterTypeTests/Typography/TypogaphyTests.swift

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,31 @@ struct NotoSansFontFamily: FontFamily {
6060
var supportedWeights: [Typography.FontWeight] { [.regular] }
6161
}
6262

63+
struct AvenirNextFontFamily: FontFamily {
64+
let familyName = "AvenirNext"
65+
66+
var supportedWeights: [Typography.FontWeight] { [.ultralight, .regular, .medium, .semibold, .bold, .heavy] }
67+
68+
func weightName(for weight: Typography.FontWeight) -> String {
69+
switch weight {
70+
case .ultralight:
71+
return "UltraLight"
72+
case .regular:
73+
return "Regular"
74+
case .medium:
75+
return "Medium"
76+
case .semibold:
77+
return "DemiBold"
78+
case .bold:
79+
return "Bold"
80+
case .heavy:
81+
return "Heavy"
82+
case .thin, .light, .black:
83+
return "" // these 3 weights are not installed
84+
}
85+
}
86+
}
87+
6388
extension Typography {
6489
static let notoSans = NotoSansFontFamily()
6590
}

0 commit comments

Comments
 (0)