Some checks reported warnings
gitea-openium/resgen.swift/pipeline/head This commit is unstable
96 lines
3.2 KiB
Swift
96 lines
3.2 KiB
Swift
//
|
|
// Section+Mock.swift
|
|
// ResgenSwift
|
|
//
|
|
// Created by Thibaut Schmitt on 30/04/2025.
|
|
//
|
|
|
|
@testable import ResgenSwift
|
|
|
|
extension Section {
|
|
|
|
enum Mock {
|
|
|
|
static func getSectionOne(
|
|
defOneFr: String = "Section Un - Definition Un",
|
|
defOneEn: String = "Section One - Definition One",
|
|
defOneComment: String? = nil,
|
|
defOneTag: [String] = ["ios","iosonly"],
|
|
defTwoFr: String = "Section Un - Definition Deux",
|
|
defTwoEn: String = "Section One - Definition Two",
|
|
defTwoComment: String? = nil,
|
|
defTwoTag: [String] = ["ios","iosonly"]
|
|
) -> Section {
|
|
let section = Section(name: "section_one")
|
|
section.definitions = [
|
|
Self.getDefinition(
|
|
name: "s1_def_one",
|
|
translations: ["fr": defOneFr,
|
|
"en": defOneEn],
|
|
tags: defOneTag,
|
|
comment: defOneComment
|
|
),
|
|
Self.getDefinition(
|
|
name: "s1_def_two",
|
|
translations: ["fr": defTwoFr,
|
|
"en": defTwoEn],
|
|
tags: defTwoTag,
|
|
comment: defTwoComment
|
|
)
|
|
]
|
|
return section
|
|
}
|
|
|
|
static func getSectionTwo(
|
|
defOneFr: String = "Section Deux - Definition Un",
|
|
defOneEn: String = "Section Two - Definition One",
|
|
defOneComment: String? = nil,
|
|
defOneTag: [String] = ["ios","iosonly"],
|
|
defTwoFr: String = "Section Deux - Definition Deux",
|
|
defTwoEn: String? = nil,
|
|
defTwoComment: String? = nil,
|
|
defTwoTag: [String] = ["notranslation"]
|
|
) -> Section {
|
|
let section = Section(name: "section_two")
|
|
let defTwoTranslations: [String: String] = {
|
|
var translations = ["fr": "Section Deux - Definition Deux"]
|
|
if let defTwoEn {
|
|
translations["en"] = defTwoEn
|
|
}
|
|
return translations
|
|
}()
|
|
section.definitions = [
|
|
Self.getDefinition(
|
|
name: "s2_def_one",
|
|
translations: ["fr": defOneFr,
|
|
"en": defOneEn],
|
|
tags: defOneTag,
|
|
comment: defOneComment
|
|
),
|
|
Self.getDefinition(
|
|
name: "s2_def_two",
|
|
translations: defTwoTranslations,
|
|
tags: defTwoTag,
|
|
comment: defTwoComment
|
|
)
|
|
]
|
|
return section
|
|
}
|
|
|
|
// MARK: - Private methods
|
|
|
|
private static func getDefinition(
|
|
name: String,
|
|
translations: [String: String],
|
|
tags: [String],
|
|
comment: String? = nil
|
|
) -> Definition {
|
|
let definition = Definition(name: name)
|
|
definition.tags = tags
|
|
definition.translations = translations
|
|
definition.comment = comment
|
|
return definition
|
|
}
|
|
}
|
|
}
|