Add visibility parameters to control scope of generated extension
Some checks failed
gitea-openium/resgen.swift/pipeline/head There was a failure building this commit
Some checks failed
gitea-openium/resgen.swift/pipeline/head There was a failure building this commit
This commit is contained in:
@ -21,10 +21,13 @@ final class FontExtensionGeneratorTests: XCTestCase {
|
||||
]
|
||||
|
||||
// When
|
||||
let extensionContent = FontExtensionGenerator.getExtensionContent(fontsNames: fontNames,
|
||||
staticVar: false,
|
||||
extensionName: "GenFonts",
|
||||
isSwiftUI: false)
|
||||
let extensionContent = FontExtensionGenerator.getExtensionContent(
|
||||
fontsNames: fontNames,
|
||||
staticVar: false,
|
||||
extensionName: "GenFonts",
|
||||
isSwiftUI: false,
|
||||
visibility: .public
|
||||
)
|
||||
|
||||
// Expect
|
||||
let expect = """
|
||||
@ -34,18 +37,18 @@ final class FontExtensionGeneratorTests: XCTestCase {
|
||||
|
||||
extension GenFonts {
|
||||
|
||||
enum FontName: String {
|
||||
public enum FontName: String {
|
||||
case CircularStdRegular = "CircularStd-Regular"
|
||||
case CircularStdBold = "CircularStd-Bold"
|
||||
}
|
||||
|
||||
// MARK: - Getter
|
||||
|
||||
func CircularStdRegular(withSize size: CGFloat) -> UIFont {
|
||||
public func CircularStdRegular(withSize size: CGFloat) -> UIFont {
|
||||
UIFont(name: FontName.CircularStdRegular.rawValue, size: size)!
|
||||
}
|
||||
|
||||
func CircularStdBold(withSize size: CGFloat) -> UIFont {
|
||||
public func CircularStdBold(withSize size: CGFloat) -> UIFont {
|
||||
UIFont(name: FontName.CircularStdBold.rawValue, size: size)!
|
||||
}
|
||||
|
||||
@ -64,10 +67,13 @@ final class FontExtensionGeneratorTests: XCTestCase {
|
||||
]
|
||||
|
||||
// When
|
||||
let extensionContent = FontExtensionGenerator.getExtensionContent(fontsNames: fontNames,
|
||||
staticVar: false,
|
||||
extensionName: "GenFonts",
|
||||
isSwiftUI: true)
|
||||
let extensionContent = FontExtensionGenerator.getExtensionContent(
|
||||
fontsNames: fontNames,
|
||||
staticVar: false,
|
||||
extensionName: "GenFonts",
|
||||
isSwiftUI: true,
|
||||
visibility: .package
|
||||
)
|
||||
|
||||
// Expect
|
||||
let expect = """
|
||||
@ -77,18 +83,18 @@ final class FontExtensionGeneratorTests: XCTestCase {
|
||||
|
||||
extension GenFonts {
|
||||
|
||||
enum FontName: String {
|
||||
package enum FontName: String {
|
||||
case CircularStdRegular = "CircularStd-Regular"
|
||||
case CircularStdBold = "CircularStd-Bold"
|
||||
}
|
||||
|
||||
// MARK: - Getter
|
||||
|
||||
func CircularStdRegular(withSize size: CGFloat) -> Font {
|
||||
package func CircularStdRegular(withSize size: CGFloat) -> Font {
|
||||
Font.custom(FontName.CircularStdRegular.rawValue, size: size)
|
||||
}
|
||||
|
||||
func CircularStdBold(withSize size: CGFloat) -> Font {
|
||||
package func CircularStdBold(withSize size: CGFloat) -> Font {
|
||||
Font.custom(FontName.CircularStdBold.rawValue, size: size)
|
||||
}
|
||||
|
||||
|
@ -21,11 +21,15 @@ final class FontNameTests: XCTestCase {
|
||||
)
|
||||
|
||||
// When
|
||||
let property = fontName.getProperty(isStatic: true, isSwiftUI: false)
|
||||
let property = fontName.getProperty(
|
||||
isStatic: true,
|
||||
isSwiftUI: false,
|
||||
visibility: .internal
|
||||
)
|
||||
|
||||
// Expect
|
||||
let expect = """
|
||||
static let CircularStdBold: ((_ size: CGFloat) -> UIFont) = { size in
|
||||
internal static let CircularStdBold: ((_ size: CGFloat) -> UIFont) = { size in
|
||||
UIFont(name: FontName.CircularStdBold.rawValue, size: size)!
|
||||
}
|
||||
"""
|
||||
@ -42,11 +46,15 @@ final class FontNameTests: XCTestCase {
|
||||
)
|
||||
|
||||
// When
|
||||
let property = fontName.getProperty(isStatic: true, isSwiftUI: false)
|
||||
let property = fontName.getProperty(
|
||||
isStatic: true,
|
||||
isSwiftUI: false,
|
||||
visibility: .package
|
||||
)
|
||||
|
||||
// Expect
|
||||
let expect = """
|
||||
static let CircularStdBoldUnderline: ((_ size: CGFloat) -> UIFont) = { size in
|
||||
package static let CircularStdBoldUnderline: ((_ size: CGFloat) -> UIFont) = { size in
|
||||
UIFont(name: FontName.CircularStdBoldUnderline.rawValue, size: size)!
|
||||
}
|
||||
"""
|
||||
@ -63,11 +71,15 @@ final class FontNameTests: XCTestCase {
|
||||
)
|
||||
|
||||
// When
|
||||
let property = fontName.getProperty(isStatic: false, isSwiftUI: false)
|
||||
let property = fontName.getProperty(
|
||||
isStatic: false,
|
||||
isSwiftUI: false,
|
||||
visibility: .private
|
||||
)
|
||||
|
||||
// Expect
|
||||
let expect = """
|
||||
func CircularStdBold(withSize size: CGFloat) -> UIFont {
|
||||
private func CircularStdBold(withSize size: CGFloat) -> UIFont {
|
||||
UIFont(name: FontName.CircularStdBold.rawValue, size: size)!
|
||||
}
|
||||
"""
|
||||
@ -84,11 +96,15 @@ final class FontNameTests: XCTestCase {
|
||||
)
|
||||
|
||||
// When
|
||||
let property = fontName.getProperty(isStatic: false, isSwiftUI: false)
|
||||
let property = fontName.getProperty(
|
||||
isStatic: false,
|
||||
isSwiftUI: false,
|
||||
visibility: .public
|
||||
)
|
||||
|
||||
// Expect
|
||||
let expect = """
|
||||
func CircularStdBoldUnderline(withSize size: CGFloat) -> UIFont {
|
||||
public func CircularStdBoldUnderline(withSize size: CGFloat) -> UIFont {
|
||||
UIFont(name: FontName.CircularStdBoldUnderline.rawValue, size: size)!
|
||||
}
|
||||
"""
|
||||
@ -105,11 +121,15 @@ final class FontNameTests: XCTestCase {
|
||||
)
|
||||
|
||||
// When
|
||||
let property = fontName.getProperty(isStatic: true, isSwiftUI: true)
|
||||
let property = fontName.getProperty(
|
||||
isStatic: true,
|
||||
isSwiftUI: true,
|
||||
visibility: .public
|
||||
)
|
||||
|
||||
// Expect
|
||||
let expect = """
|
||||
static let CircularStdBold: ((_ size: CGFloat) -> Font) = { size in
|
||||
public static let CircularStdBold: ((_ size: CGFloat) -> Font) = { size in
|
||||
Font.custom(FontName.CircularStdBold.rawValue, size: size)
|
||||
}
|
||||
"""
|
||||
@ -126,11 +146,15 @@ final class FontNameTests: XCTestCase {
|
||||
)
|
||||
|
||||
// When
|
||||
let property = fontName.getProperty(isStatic: true, isSwiftUI: true)
|
||||
let property = fontName.getProperty(
|
||||
isStatic: true,
|
||||
isSwiftUI: true,
|
||||
visibility: .package
|
||||
)
|
||||
|
||||
// Expect
|
||||
let expect = """
|
||||
static let CircularStdBoldUnderline: ((_ size: CGFloat) -> Font) = { size in
|
||||
package static let CircularStdBoldUnderline: ((_ size: CGFloat) -> Font) = { size in
|
||||
Font.custom(FontName.CircularStdBoldUnderline.rawValue, size: size)
|
||||
}
|
||||
"""
|
||||
@ -147,11 +171,15 @@ final class FontNameTests: XCTestCase {
|
||||
)
|
||||
|
||||
// When
|
||||
let property = fontName.getProperty(isStatic: false, isSwiftUI: true)
|
||||
let property = fontName.getProperty(
|
||||
isStatic: false,
|
||||
isSwiftUI: true,
|
||||
visibility: .package
|
||||
)
|
||||
|
||||
// Expect
|
||||
let expect = """
|
||||
func CircularStdBold(withSize size: CGFloat) -> Font {
|
||||
package func CircularStdBold(withSize size: CGFloat) -> Font {
|
||||
Font.custom(FontName.CircularStdBold.rawValue, size: size)
|
||||
}
|
||||
"""
|
||||
@ -168,11 +196,15 @@ final class FontNameTests: XCTestCase {
|
||||
)
|
||||
|
||||
// When
|
||||
let property = fontName.getProperty(isStatic: false, isSwiftUI: true)
|
||||
let property = fontName.getProperty(
|
||||
isStatic: false,
|
||||
isSwiftUI: true,
|
||||
visibility: .internal
|
||||
)
|
||||
|
||||
// Expect
|
||||
let expect = """
|
||||
func CircularStdBoldUnderline(withSize size: CGFloat) -> Font {
|
||||
internal func CircularStdBoldUnderline(withSize size: CGFloat) -> Font {
|
||||
Font.custom(FontName.CircularStdBoldUnderline.rawValue, size: size)
|
||||
}
|
||||
"""
|
||||
|
Reference in New Issue
Block a user