Merge branch 'setup' into template
This commit is contained in:
@@ -23,13 +23,13 @@ struct AssetExtensionTests {
|
||||
|
||||
@Test(arguments: zip(
|
||||
Self.extensions,
|
||||
Self.subdirectories
|
||||
Self.folders
|
||||
))
|
||||
func `subdirectory`(
|
||||
func `folder`(
|
||||
for fileExtension: AssetExtension,
|
||||
expects subdirectory: String?
|
||||
expects folder: String?
|
||||
) {
|
||||
#expect(fileExtension.subdirectory == subdirectory)
|
||||
#expect(fileExtension.folder == folder)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -60,7 +60,7 @@ private extension AssetExtensionTests {
|
||||
"application/manifest+json",
|
||||
"application/xml"
|
||||
]
|
||||
static let subdirectories: [String?] = [
|
||||
static let folders: [String?] = [
|
||||
"css",
|
||||
"js",
|
||||
nil,
|
||||
|
||||
@@ -14,6 +14,11 @@ struct AssetTests {
|
||||
fileExtensions: [.png],
|
||||
fileName: "icon"
|
||||
)
|
||||
private let portrait = StubAsset(
|
||||
folder: "img/organizer",
|
||||
fileExtensions: [.jpg],
|
||||
fileName: "portrait"
|
||||
)
|
||||
private let shared = StubAsset(
|
||||
fileExtensions: [.css, .js],
|
||||
fileName: "shared"
|
||||
@@ -22,13 +27,18 @@ struct AssetTests {
|
||||
// MARK: Method tests
|
||||
|
||||
@Test
|
||||
func `relative path nests the file inside its extension's sub-directory`() {
|
||||
func `relative path nests the file inside its extension's folder`() {
|
||||
#expect(shared.relativePath(for: .css) == "css/shared.css")
|
||||
#expect(shared.relativePath(for: .js) == "js/shared.js")
|
||||
}
|
||||
|
||||
@Test
|
||||
func `relative path keeps the file at the root without a sub-directory`() {
|
||||
func `relative path prefers the asset's own folder over the extension's`() {
|
||||
#expect(portrait.relativePath(for: .jpg) == "img/organizer/portrait.jpg")
|
||||
}
|
||||
|
||||
@Test
|
||||
func `relative path keeps the file at the root without a folder`() {
|
||||
#expect(image.relativePath(for: .png) == "icon.png")
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import Infrastructure
|
||||
|
||||
/// An ``Asset`` with a fixed file name and set of extensions.
|
||||
/// An ``Asset`` with a fixed file name and set of extensions, optionally held in a folder of its own.
|
||||
struct StubAsset: Asset {
|
||||
|
||||
// MARK: Properties
|
||||
|
||||
var folder: String? = nil
|
||||
let fileExtensions: [AssetExtension]
|
||||
let fileName: String
|
||||
|
||||
|
||||
Reference in New Issue
Block a user