2023-09-20 14:07:18 +02:00
// swiftlint:disable all
// swiftformat:disable all
import XCTest
2024-09-09 15:07:41 +03:00
@testable import ElementX
2023-09-20 14:07:18 +02:00
{% if argument.mainTarget %}
@testable import {{ argument.mainTarget }}
{% endif %}
2024-03-12 13:08:54 +02:00
{% for import in argument.imports %}
{% if import != "last" %}
import {{ import }}
{% endif %}
{% endfor %}
{% for import in argument.testableImports %}
{% if import != "last" %}
@testable import {{ import }}
{% endif %}
{% endfor %}
2023-09-20 14:07:18 +02:00
2024-09-18 17:06:44 +01:00
extension PreviewTests {
2023-09-20 14:07:18 +02:00
{% if argument.file %}
private var file: StaticString { .init(stringLiteral: "{{ argument.file }}") }
{% endif %}
2024-03-12 13:08:54 +02:00
// MARK: - PreviewProvider
2024-09-09 15:07:41 +03:00
{% for type in types.types where (type.implements.TestablePreview or type.based.TestablePreview or type|annotated:"TestablePreview") and type.name != "TestablePreview" %}
2025-03-04 18:33:39 +02:00
func test{{ type.name|replace:"_Previews", "" }}() async throws {
for (index, preview) in {{ type.name }}._allPreviews.enumerated() {
try await assertSnapshots(matching: preview, step: index)
2023-09-20 14:07:18 +02:00
}
}
2024-03-12 13:08:54 +02:00
{%- if not forloop.last %}
2023-09-20 14:07:18 +02:00
2024-03-12 13:08:54 +02:00
{% endif %}
2023-09-20 14:07:18 +02:00
{% endfor %}
2024-03-12 13:08:54 +02:00
{% if argument.previewsMacros %}
// MARK: - Macros
{{ argument.previewsMacros }}
{% endif %}
2024-07-11 17:38:32 +01:00
}
2023-09-20 17:33:31 +02:00
// swiftlint:enable all
// swiftformat:enable all