Skip to content

Commit

Permalink
preview tests added
Browse files Browse the repository at this point in the history
  • Loading branch information
Velin92 committed Sep 21, 2023
1 parent b2c3e7b commit db6ea6f
Show file tree
Hide file tree
Showing 24 changed files with 111 additions and 13 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Tests/CompoundTests/__Snapshots__/** filter=lfs diff=lfs merge=lfs -text
6 changes: 5 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ jobs:

steps:
- uses: actions/checkout@v3

- name: Install GitLFS
run: brew install git-lfs

- name: Run tests
run: xcodebuild test -scheme 'Compound' -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 14'
run: xcodebuild test -scheme 'Compound' -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 14,OS=16.4'

4 changes: 3 additions & 1 deletion Sources/Compound/BaseStyles/CompoundToggleStyle.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ public struct CompoundToggleStyle: ToggleStyle {
}
}

public struct CompoundToggleStyle_Previews: PreviewProvider {
import Prefire

public struct CompoundToggleStyle_Previews: PreviewProvider, PrefireProvider {
public static var previews: some View {
VStack(spacing: 16) {
states
Expand Down
42 changes: 41 additions & 1 deletion Sources/Compound/Icons/CompoundIcon.swift
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,11 @@ public extension Label {
}
}

struct CompoundIcon_Previews: PreviewProvider {
// MARK: - Previews

import Prefire

struct CompoundIcon_Previews: PreviewProvider, PrefireProvider {
static var previews: some View {
form
.previewLayout(.fixed(width: 375, height: 400))
Expand All @@ -164,6 +168,42 @@ struct CompoundIcon_Previews: PreviewProvider {
.padding(8)
.previewLayout(.sizeThatFits)
.previewDisplayName("Buttons")
accessibilityIcons
.previewDisplayName("Accessibility Icons Only")
accessibilityLabels
.previewDisplayName("Accessibility Labels")
}

@ViewBuilder
static var accessibilityIcons: some View {
VStack {
ForEach(DynamicTypeSize.allCases, id: \.self) { size in
HStack {
CompoundIcon(\.userProfile, size: .xSmall, relativeTo: .compound.bodyXS)
CompoundIcon(\.userProfile, size: .small, relativeTo: .compound.bodySM)
CompoundIcon(\.userProfile, size: .medium, relativeTo: .compound.bodyLG)
}
.dynamicTypeSize(size)
}
}
}

@ViewBuilder
static var accessibilityLabels: some View {
VStack {
ForEach(DynamicTypeSize.allCases, id: \.self) { size in
HStack {
Label("Test XS", icon: \.userProfile, iconSize: .xSmall, relativeTo: .compound.bodyXS)
.font(.compound.bodyXS)
Label("Test Small", icon: \.userProfile, iconSize: .small, relativeTo: .compound.bodySM)
.font(.compound.bodySM)
Label("Test Medium", icon: \.userProfile, iconSize: .medium, relativeTo: .compound.bodyLG)
.font(.compound.bodyLG)
}
.lineLimit(1)
.dynamicTypeSize(size)
}
}
}

static var form: some View {
Expand Down
10 changes: 5 additions & 5 deletions Sources/Compound/List/ListDetailsLabel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@ public extension ListDetailsLabel where Icon == Image {

// MARK: - Previews

struct ListDetailsLabel_Previews: PreviewProvider {
static var someCondition: Bool { Bool.random() }
static var otherCondition: Bool { Bool.random() }
import Prefire

struct ListDetailsLabel_Previews: PreviewProvider, PrefireProvider {

static var previews: some View {
VStack(spacing: 20) {
Expand All @@ -106,8 +106,8 @@ struct ListDetailsLabel_Previews: PreviewProvider {
ListDetailsLabel.systemIcon(.squareDashed)
ListDetailsLabel.isWaiting(true)

// Conditional configurations
someCondition ? ListDetailsLabel.isWaiting(true) : otherCondition ? .systemIcon(.checkmark) : .title("Hello")
ListDetailsLabel.systemIcon(.checkmark)
ListDetailsLabel.title("Hello")
}
}
}
6 changes: 5 additions & 1 deletion Sources/Compound/List/ListInlinePicker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ struct ListInlinePicker<SelectedValue: Hashable>: View {
}
}

struct ListInlinePicker_Previews: PreviewProvider {
// MARK: - Previews

import Prefire

struct ListInlinePicker_Previews: PreviewProvider, PrefireProvider {
static var previews: some View { Preview() }

struct Preview: View {
Expand Down
4 changes: 3 additions & 1 deletion Sources/Compound/List/ListLabel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,9 @@ public struct ListLabel<Icon: View>: View {

// MARK: - Previews

struct ListLabel_Previews: PreviewProvider {
import Prefire

struct ListLabel_Previews: PreviewProvider, PrefireProvider {
static var previews: some View {
Form {
Section {
Expand Down
4 changes: 3 additions & 1 deletion Sources/Compound/List/ListRow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,9 @@ private struct RowContent<Label: View, Details: View>: View {

// MARK: - Previews

public struct ListRow_Previews: PreviewProvider {
import Prefire

public struct ListRow_Previews: PreviewProvider, PrefireProvider {
public static var previews: some View {
Form {
Section {
Expand Down
4 changes: 3 additions & 1 deletion Sources/Compound/List/ListRowButtonStyle.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,12 @@ public struct ListRowButtonStyle: PrimitiveButtonStyle {

// MARK: - Previews

import Prefire

// TODO: Fix the previews, either the style should expand the label to fill or
// the previews need to do this manually for demonstration purposes.

public struct ListRowButtonStyle_Previews: PreviewProvider {
public struct ListRowButtonStyle_Previews: PreviewProvider, PrefireProvider {
public static var previews: some View {
Form {
Section {
Expand Down
3 changes: 2 additions & 1 deletion Sources/Compound/List/ListStyles.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,9 @@ public extension View {
}
}

import Prefire

struct ListTextStyles_Previews: PreviewProvider {
struct ListTextStyles_Previews: PreviewProvider, PrefireProvider {
static var previews: some View {
Form {
Section {
Expand Down
4 changes: 4 additions & 0 deletions Sources/Compound/Text Field Styles/SearchFieldStyle.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ public extension View {
}
}

// MARK: - Previews

import Prefire

struct SearchStyle_Previews: PreviewProvider {
static var previews: some View {
NavigationStack {
Expand Down
File renamed without changes.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit db6ea6f

Please sign in to comment.