Skip to content

Commit

Permalink
fix: revisit how we test dynamic type (#2034)
Browse files Browse the repository at this point in the history
  • Loading branch information
gert-janvercauteren authored Aug 1, 2024
1 parent 04ea0b8 commit 17f817d
Show file tree
Hide file tree
Showing 6 changed files with 2 additions and 19 deletions.
21 changes: 2 additions & 19 deletions Backpack-SwiftUI/Tests/Text/BPKTextDynamicTypeTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,38 +22,21 @@ import SnapshotTesting
@testable import Backpack_SwiftUI

class BPKTextDynamicTypeTests: XCTestCase {
private let categories: [(UIContentSizeCategory, String)] = [
(.extraSmall, "xs"),
(.large, "l"),
(.accessibilityMedium, "a11y_m"),
(.accessibilityExtraExtraExtraLarge, "a11y_3xl")
]

func test_dynamicType() {
let sut = generateView([
(.hero1, "Hero 1"),
(.heading1, "Heading 1"),
(.bodyDefault, "Body default"),
(.caption, "Caption"),
(.footnote, "Footnote")
]).frame(width: 700, height: 500)

let view: UIView = UIHostingController(rootView: sut).view

categories.forEach { category in
assertSnapshot(
matching: view,
as: .image(size: view.intrinsicContentSize, traits: .init(preferredContentSizeCategory: category.0)),
named: "dynamic_type_\(category.1)")
}
])
assertA11ySnapshot(sut)
}

private func generateView(_ styles: [(BPKFontStyle, String)]) -> some View {
VStack(alignment: .leading) {
ForEach(styles, id: \.self.1) { style in
BPKText(style.1, style: style.0)
}
Spacer()
}
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit 17f817d

Please sign in to comment.