diff --git a/Tests/TokamakStaticHTMLTests/HTMLStrategy.swift b/Tests/TokamakStaticHTMLTests/HTMLStrategy.swift
new file mode 100644
index 00000000..4714eb79
--- /dev/null
+++ b/Tests/TokamakStaticHTMLTests/HTMLStrategy.swift
@@ -0,0 +1,22 @@
+// Copyright 2021 Tokamak contributors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#if canImport(SnapshotTesting)
+import SnapshotTesting
+
+extension Snapshotting where Value == String, Format == String {
+ public static let html = Snapshotting(pathExtension: "html", diffing: .lines)
+}
+
+#endif
diff --git a/Tests/TokamakStaticHTMLTests/HTMLTests.swift b/Tests/TokamakStaticHTMLTests/HTMLTests.swift
index 47847bb3..724986ed 100644
--- a/Tests/TokamakStaticHTMLTests/HTMLTests.swift
+++ b/Tests/TokamakStaticHTMLTests/HTMLTests.swift
@@ -44,7 +44,7 @@ final class HTMLTests: XCTestCase {
let resultingHTML = StaticHTMLRenderer(OptionalBody(model: Model(color: Color.red)))
.render(shouldSortAttributes: true)
- assertSnapshot(matching: resultingHTML, as: .lines)
+ assertSnapshot(matching: resultingHTML, as: .html)
}
func testPaddingFusion() {
@@ -52,13 +52,13 @@ final class HTMLTests: XCTestCase {
Color.red.padding(10).padding(20)
).render(shouldSortAttributes: true)
- assertSnapshot(matching: nestedTwice, as: .lines)
+ assertSnapshot(matching: nestedTwice, as: .html)
let nestedThrice = StaticHTMLRenderer(
Color.red.padding(20).padding(20).padding(20)
).render(shouldSortAttributes: true)
- assertSnapshot(matching: nestedThrice, as: .lines)
+ assertSnapshot(matching: nestedThrice, as: .html)
}
func testFontStacks() {
@@ -67,7 +67,7 @@ final class HTMLTests: XCTestCase {
.font(.custom("Marker Felt", size: 17))
).render(shouldSortAttributes: true)
- assertSnapshot(matching: customFont, as: .lines)
+ assertSnapshot(matching: customFont, as: .html)
let fallbackFont = StaticHTMLRenderer(
VStack {
@@ -77,7 +77,7 @@ final class HTMLTests: XCTestCase {
.font(.system(.body, design: .serif))
).render(shouldSortAttributes: true)
- assertSnapshot(matching: fallbackFont, as: .lines)
+ assertSnapshot(matching: fallbackFont, as: .html)
}
func testHTMLSanitizer() {
@@ -85,12 +85,12 @@ final class HTMLTests: XCTestCase {
let sanitizedHTML = StaticHTMLRenderer(Text(text))
.render(shouldSortAttributes: true)
- assertSnapshot(matching: sanitizedHTML, as: .lines)
+ assertSnapshot(matching: sanitizedHTML, as: .html)
let insecureHTML =
StaticHTMLRenderer(Text(text)._domTextSanitizer(Sanitizers.HTML.insecure))
.render(shouldSortAttributes: true)
- assertSnapshot(matching: insecureHTML, as: .lines)
+ assertSnapshot(matching: insecureHTML, as: .html)
}
}
diff --git a/Tests/TokamakStaticHTMLTests/__Snapshots__/HTMLTests/testFontStacks.1.txt b/Tests/TokamakStaticHTMLTests/__Snapshots__/HTMLTests/testFontStacks.1.html
similarity index 100%
rename from Tests/TokamakStaticHTMLTests/__Snapshots__/HTMLTests/testFontStacks.1.txt
rename to Tests/TokamakStaticHTMLTests/__Snapshots__/HTMLTests/testFontStacks.1.html
diff --git a/Tests/TokamakStaticHTMLTests/__Snapshots__/HTMLTests/testFontStacks.2.txt b/Tests/TokamakStaticHTMLTests/__Snapshots__/HTMLTests/testFontStacks.2.html
similarity index 100%
rename from Tests/TokamakStaticHTMLTests/__Snapshots__/HTMLTests/testFontStacks.2.txt
rename to Tests/TokamakStaticHTMLTests/__Snapshots__/HTMLTests/testFontStacks.2.html
diff --git a/Tests/TokamakStaticHTMLTests/__Snapshots__/HTMLTests/testHTMLSanitizer.1.txt b/Tests/TokamakStaticHTMLTests/__Snapshots__/HTMLTests/testHTMLSanitizer.1.html
similarity index 100%
rename from Tests/TokamakStaticHTMLTests/__Snapshots__/HTMLTests/testHTMLSanitizer.1.txt
rename to Tests/TokamakStaticHTMLTests/__Snapshots__/HTMLTests/testHTMLSanitizer.1.html
diff --git a/Tests/TokamakStaticHTMLTests/__Snapshots__/HTMLTests/testHTMLSanitizer.2.txt b/Tests/TokamakStaticHTMLTests/__Snapshots__/HTMLTests/testHTMLSanitizer.2.html
similarity index 100%
rename from Tests/TokamakStaticHTMLTests/__Snapshots__/HTMLTests/testHTMLSanitizer.2.txt
rename to Tests/TokamakStaticHTMLTests/__Snapshots__/HTMLTests/testHTMLSanitizer.2.html
diff --git a/Tests/TokamakStaticHTMLTests/__Snapshots__/HTMLTests/testOptional.1.txt b/Tests/TokamakStaticHTMLTests/__Snapshots__/HTMLTests/testOptional.1.html
similarity index 100%
rename from Tests/TokamakStaticHTMLTests/__Snapshots__/HTMLTests/testOptional.1.txt
rename to Tests/TokamakStaticHTMLTests/__Snapshots__/HTMLTests/testOptional.1.html
diff --git a/Tests/TokamakStaticHTMLTests/__Snapshots__/HTMLTests/testPaddingFusion.1.txt b/Tests/TokamakStaticHTMLTests/__Snapshots__/HTMLTests/testPaddingFusion.1.html
similarity index 100%
rename from Tests/TokamakStaticHTMLTests/__Snapshots__/HTMLTests/testPaddingFusion.1.txt
rename to Tests/TokamakStaticHTMLTests/__Snapshots__/HTMLTests/testPaddingFusion.1.html
diff --git a/Tests/TokamakStaticHTMLTests/__Snapshots__/HTMLTests/testPaddingFusion.2.txt b/Tests/TokamakStaticHTMLTests/__Snapshots__/HTMLTests/testPaddingFusion.2.html
similarity index 100%
rename from Tests/TokamakStaticHTMLTests/__Snapshots__/HTMLTests/testPaddingFusion.2.txt
rename to Tests/TokamakStaticHTMLTests/__Snapshots__/HTMLTests/testPaddingFusion.2.html