-
Notifications
You must be signed in to change notification settings - Fork 346
/
Copy pathThemeDocCTests.swift
186 lines (147 loc) · 5.38 KB
/
ThemeDocCTests.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
#if os(iOS)
import SnapshotTesting
import SwiftUI
import XCTest
import MarkdownUI
final class ThemeDocCTests: XCTestCase {
private let layout = SwiftUISnapshotLayout.device(config: .iPhone8)
override func setUpWithError() throws {
try XCTSkipIf(UIDevice.current.userInterfaceIdiom == .pad, "Skipping on Mac Catalyst")
}
func testInlines() {
let view = ThemePreview(theme: .docC) {
#"""
**This is bold text**
*This text is italicized*
~~This was mistaken text~~
**This text is _extremely_ important**
MarkdownUI is fully compliant with the [CommonMark Spec](https://spec.commonmark.org/current/).
Use `git status` to list all new or modified files that haven't yet been committed.
"""#
}
assertSnapshot(of: view, as: .image(layout: layout))
}
func testHeadings() {
let view = ThemePreview(theme: .docC, colorScheme: .light) {
#"""
Paragraph.
# Heading 1
Paragraph.
## Heading 2
Paragraph.
### Heading 3
Paragraph.
#### Heading 4
Paragraph.
##### Heading 5
Paragraph.
###### Heading 6
Paragraph.
"""#
}
assertSnapshot(of: view, as: .image(layout: layout))
}
func testParagraph() {
let view = ThemePreview(theme: .docC, colorScheme: .light) {
#"""
The sky above the port was the color of television, tuned to a dead channel.
It was a bright cold day in April, and the clocks were striking thirteen.
The sky above the port was the color of television, tuned to a dead channel.
It was a bright cold day in April, and the clocks were striking thirteen.
"""#
}
assertSnapshot(of: view, as: .image(layout: layout))
}
func testBlockquote() {
let view = ThemePreview(theme: .docC) {
#"""
The sky above the port was the color of television, tuned to a dead channel.
> Outside of a dog, a book is man's best friend. Inside of a dog it's too dark to read.
It was a bright cold day in April, and the clocks were striking thirteen.
"""#
}
assertSnapshot(of: view, as: .image(layout: layout))
}
func testCodeBlock() {
let view = ThemePreview(theme: .docC) {
#"""
The sky above the port was the color of television, tuned to a dead channel.
```swift
struct Sightseeing: Activity {
func perform(with sloth: inout Sloth) -> Speed {
sloth.energyLevel -= 10
return .slow
}
}
```
It was a bright cold day in April, and the clocks were striking thirteen.
"""#
}
assertSnapshot(of: view, as: .image(layout: layout))
}
func testImage() throws {
guard #available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *) else {
throw XCTSkip("Required API is not available for this test")
}
let view = ThemePreview(theme: .docC, colorScheme: .light) {
#"""
The sky above the port was the color of television, tuned to a dead channel.
![](https://example.com/picsum/237-100x150)
It was a bright cold day in April, and the clocks were striking thirteen.
![](https://example.com/picsum/237-100x150)
![](https://example.com/picsum/237-125x75)
― Photo by André Spieker
"""#
}
.markdownImageProvider(AssetImageProvider(bundle: .module))
assertSnapshot(of: view, as: .image(layout: layout))
}
func testList() {
let view = ThemePreview(theme: .docC, colorScheme: .light) {
#"""
The sky above the port was the color of television, tuned to a dead channel.
* Systems
* FFF units
* Great Underground Empire (Zork)
* Potrzebie
* Equals the thickness of Mad issue 26
* Developed by 19-year-old Donald E. Knuth
It was a bright cold day in April, and the clocks were striking thirteen.
10. Helmets
1. Hoods
1. Headbands, headscarves, wimples
The sky above the port was the color of television, tuned to a dead channel.
- [x] A finished task
- [ ] An unfinished task
"""#
}
assertSnapshot(of: view, as: .image(layout: layout))
}
func testTable() throws {
guard #available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *) else {
throw XCTSkip("Required API is not available for this test")
}
let view = ThemePreview(theme: .docC) {
#"""
Add tables of data:
| Sloth speed | Description |
| ------------ | ------------------------------------- |
| `slow` | Moves slightly faster than a snail. |
| `medium` | Moves at an average speed. |
| `fast` | Moves faster than a hare. |
"""#
}
assertSnapshot(of: view, as: .image(layout: layout))
}
func testThematicBreak() {
let view = ThemePreview(theme: .docC) {
#"""
The sky above the port was the color of television, tuned to a dead channel.
---
It was a bright cold day in April, and the clocks were striking thirteen.
"""#
}
assertSnapshot(of: view, as: .image(layout: layout))
}
}
#endif