Files
ccn/Packages/Infrastructure/Tests/Cases/Public/Enumerations/AssetExtensionTests.swift
T
javier 65b62681eb Project updates from Template (#1)
This PR contains the latest updates from the generic Website template, which have been added while working on #loud-amsterdam.

Reviewed-on: #1
Co-authored-by: Javier Cicchelli <javier@rock-n-code.com>
2026-09-04 13:40:35 +00:00

98 lines
2.0 KiB
Swift

import Testing
@testable import Infrastructure
@Suite(
"AssetExtension enumeration",
.tags(.asset)
)
struct AssetExtensionTests {
// MARK: Computed tests
@Test(arguments: zip(
Self.extensions,
Self.contentTypes
))
func `content type`(
for fileExtension: AssetExtension,
expects contentType: String
) {
#expect(fileExtension.contentType == contentType)
}
@Test(arguments: zip(
Self.extensions,
Self.folders
))
func `folder`(
for fileExtension: AssetExtension,
expects folder: String?
) {
#expect(fileExtension.folder == folder)
}
// MARK: CaseIterable tests
@Test
func `covers every case in the parameterised tests`() {
// `zip` stops at the shorter sequence, so a case missing from the arrays below is silently untested rather
// than failing — this is what catches that.
#expect(Self.extensions == AssetExtension.allCases)
#expect(Self.contentTypes.count == AssetExtension.allCases.count)
#expect(Self.folders.count == AssetExtension.allCases.count)
}
}
// MARK: - Helpers
private extension AssetExtensionTests {
// MARK: Constants
static let extensions: [AssetExtension] = [
.css,
.ico,
.jpg,
.js,
.mp4,
.png,
.svg,
.txt,
.webmanifest,
.webp,
.woff2,
.xml
]
static let contentTypes: [String] = [
"text/css",
"image/vnd.microsoft.icon",
"image/jpeg",
"text/javascript",
"video/mp4",
"image/png",
"image/svg+xml",
"text/plain",
"application/manifest+json",
"image/webp",
"font/woff2",
"application/xml"
]
static let folders: [String?] = [
"css",
nil,
"img",
"js",
"video",
nil,
nil,
nil,
nil,
"img",
"font",
nil
]
}