Defined the AssetFolder enumeration type in. the library target and also, conformed it to the Pathable protocol.

This commit is contained in:
2025-09-22 21:10:00 +02:00
parent dfec69d1bd
commit d86d533198
2 changed files with 120 additions and 0 deletions
@@ -0,0 +1,43 @@
// ===----------------------------------------------------------------------===
//
// This source file is part of the Hummingbird DocC Middleware open source project
//
// Copyright (c) 2025 Röck+Cöde VoF. and the Hummingbird DocC Middleware project authors
// Licensed under the EUPL 1.2 or later.
//
// See LICENSE for license information
// See CONTRIBUTORS for the list of Hummingbird DocC Middleware project authors
//
// ===----------------------------------------------------------------------===
/// An enumeration that represents all possible asset folders that could be generated by the `DocC` building process.
enum AssetFolder: String, CaseIterable {
/// A folder that contains all CSS style sheets.
case css
/// A folder that contains all documentation data.
case data
/// A folder that contains all other resources.
case downloads
/// A folder that contains all image resources.
case images
/// A folder that contains all image resources.
case img
/// A folder that contains all generated `HTML` code.
case index
/// A folder that contains all generated `Javascript` code.
case js
/// A folder that contains all video resources.
case videos
}
// MARK: - Pathable
extension AssetFolder: Pathable {
// MARK: Computed
var path: String {
.init(format: .Format.Path.folder, rawValue)
}
}
@@ -0,0 +1,77 @@
// ===----------------------------------------------------------------------===
//
// This source file is part of the Hummingbird DocC Middleware open source project
//
// Copyright (c) 2025 Röck+Cöde VoF. and the Hummingbird DocC Middleware project authors
// Licensed under the EUPL 1.2 or later.
//
// See LICENSE for license information
// See CONTRIBUTORS for the list of Hummingbird DocC Middleware project authors
//
// ===----------------------------------------------------------------------===
import Testing
@testable import enum DocCMiddleware.AssetFolder
@Suite("Asset Folder", .tags(.enumeration))
struct AssetFolderTests {
// MARK: Properties tests
#if swift(>=6.2)
@Test(arguments: zip(
AssetFolder.allCases,
Output.assetFolderPaths
))
func `path`(
`case`: AssetFolder,
expects result: String
) {
assertPath(`case`, expects: result)
}
#else
@Test("path", arguments: zip(
AssetFolder.allCases,
Output.assetFolderPaths
))
func path(
`case`: AssetFolder,
expects result: String
) {
assertPath(`case`, expects: result)
}
#endif
}
// MARK: - Assertions
private extension AssetFolderTests {
// MARK: Functions
/// Asserts the path property based on a given ``AssetFolder`` enumeration case and an expected result.
/// - Parameters:
/// - case: A representation of the ``AssetFolder`` enumeration
/// - result: An expected result coming out of the property.
func assertPath(
_ case: AssetFolder,
expects result: String
) {
// GIVEN
// WHEN
let output = `case`.path
// THEN
#expect(output == result)
}
}
// MARK: - Constants
extension Output {
/// A list of expected outputs for the paths of the ``AssetFolder`` enumeration cases.
static let assetFolderPaths: [String] = ["/css/", "/data/", "/downloads/", "/images/", "/img/", "/index/", "/js/", "/videos/"]
}