Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions .github/workflows/pages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Pages

# Publishes site/, the project's landing page, to GitHub Pages when it changes on main.
on:
push:
branches: [main]
paths: [site/**, .github/workflows/pages.yml]
workflow_dispatch:

permissions:
contents: read

concurrency:
group: pages
cancel-in-progress: false

jobs:
deploy:
name: Deploy
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Configure Pages
uses: actions/configure-pages@v5
- name: Upload site
uses: actions/upload-pages-artifact@v3
with:
path: site
- name: Deploy
id: deployment
uses: actions/deploy-pages@v4
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,23 @@ final class EnvironmentVariationPreviewTests: XCTestCase {
let view = Text("Hello").environmentVariations()
XCTAssertNotNil(view)
}

/// The captions drawn on site/index.html.
@available(iOS 15.0, tvOS 15.0, watchOS 8.0, *) // DynamicTypeSize
func testCaptionsShownOnTheSite() {
let list: EnvironmentValueItemList = [
.colorScheme(.light), .colorScheme(.dark), .layoutDirection(.rightToLeft),
.dynamicTypeSize(DynamicTypeSize.xSmall), .dynamicTypeSize(DynamicTypeSize.xxxLarge),
]
XCTAssertEqual(list.map(\.description), [
"colorScheme: light",
"colorScheme: dark",
"layoutDirection: rightToLeft",
"dynamicTypeSize: xSmall",
"dynamicTypeSize: xxxLarge",
])
let locale: EnvironmentValueItemList = [.locale(Locale(identifier: "fr_FR"))]
XCTAssertTrue(locale[0].description.hasPrefix("locale: fr_FR"), locale[0].description)
}
}
#endif
46 changes: 46 additions & 0 deletions Tests/EnvironmentVariationPreviewTests/ReadmeTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// Mirrors the snippets in README.md and site/index.html, so a snippet that stops compiling fails here.
#if targetEnvironment(simulator)
import SwiftUI
import XCTest
import EnvironmentVariationPreview

private struct ProfileCard: View {
var body: some View {
HStack {
Circle().frame(width: 32, height: 32)
VStack(alignment: .leading) {
Text("Ada Lovelace").font(.headline)
Text(Date(timeIntervalSince1970: 1_680_000_000), style: .date)
}
}
}
}

final class ReadmeTests: XCTestCase {
@available(iOS 15.0, tvOS 15.0, watchOS 8.0, *) // DynamicTypeSize
func testUsage() {
let view = ProfileCard()
.environmentVariations([
.colorScheme(.light),
.colorScheme(.dark),
.layoutDirection(.rightToLeft),
.dynamicTypeSize(DynamicTypeSize.xSmall),
.dynamicTypeSize(DynamicTypeSize.large),
.dynamicTypeSize(DynamicTypeSize.xxxLarge),
.locale(Locale(identifier: "fr_FR")),
])
XCTAssertNotNil(view)
}

@available(iOS 15.0, tvOS 15.0, watchOS 8.0, *) // DynamicTypeSize
func testDefaultsAlignmentAndSpacing() {
_ = ProfileCard().environmentVariations()
_ = ProfileCard().environmentVariations([.horizontalSizeClass(.compact), .horizontalSizeClass(.regular)], .leading, 16)
_ = ProfileCard().environmentVariations([
.dynamicTypeSize(DynamicTypeSize.accessibility5),
.legibilityWeight(.bold),
.redactionReasons(.placeholder),
])
}
}
#endif
Loading
Loading