fix: Rebase tags
Some checks failed
gitea-openium/resgen.swift/pipeline/head There was a failure building this commit

This commit is contained in:
2023-12-08 11:29:48 +01:00
parent 3fc2fd9bac
commit ca763cd5d0
13 changed files with 396 additions and 133 deletions

View File

@ -0,0 +1,82 @@
//
// TagsGeneratorTests.swift
//
//
// Created by Thibaut Schmitt on 06/09/2022.
//
import Foundation
import XCTest
import ToolCore
@testable import ResgenSwift
final class TagsGeneratorTests: XCTestCase {
private func getDefinition(name: String, lang: String, tags: [String]) -> Definition {
let definition = Definition(name: name)
definition.tags = tags
definition.translations = [lang: "Some translation"]
return definition
}
func testGeneratedExtensionContent() {
// Given
let sectionOne = Section(name: "section_one")
sectionOne.definitions = [
getDefinition(name: "s1_def_one", lang: "ium", tags: ["ios","iosonly"]),
getDefinition(name: "s1_def_two", lang: "ium", tags: ["ios","iosonly"]),
]
let sectionTwo = Section(name: "section_two")
sectionTwo.definitions = [
getDefinition(name: "s2_def_one", lang: "ium", tags: ["ios","iosonly"]),
getDefinition(name: "s2_def_two", lang: "ium", tags: ["droid","droidonly"])
]
let sectionThree = Section(name: "section_three")
sectionThree.definitions = [
getDefinition(name: "s3_def_one", lang: "ium", tags: ["droid","droidonly"]),
getDefinition(name: "s3_def_two", lang: "ium", tags: ["droid","droidonly"])
]
// When
let extensionContent = TagsGenerator.getExtensionContent(sections: [sectionOne, sectionTwo, sectionThree],
lang: "ium",
tags: ["ios", "iosonly"],
staticVar: false,
extensionName: "GenTags")
// Expect Tags
let expect = """
// Generated by ResgenSwift.Strings.Tags \(ResgenSwiftVersion)
import UIKit
extension GenTags {
// MARK: - section_one
/// Translation in ium :
/// Some translation
var s1_def_one: String {
"Some translation"
}
/// Translation in ium :
/// Some translation
var s1_def_two: String {
"Some translation"
}
// MARK: - section_two
/// Translation in ium :
/// Some translation
var s2_def_one: String {
"Some translation"
}
}
"""
XCTAssertEqual(extensionContent.adaptForXCTest(), expect.adaptForXCTest())
}
}