Some checks failed
gitea-openium/resgen.swift/pipeline/head There was a failure building this commit
Reviewed-on: #1
84 lines
2.2 KiB
Swift
84 lines
2.2 KiB
Swift
//
|
|
// FontNameTests.swift
|
|
//
|
|
//
|
|
// Created by Thibaut Schmitt on 05/09/2022.
|
|
//
|
|
|
|
import Foundation
|
|
import XCTest
|
|
|
|
@testable import ResgenSwift
|
|
|
|
final class FontNameTests: XCTestCase {
|
|
|
|
func testGeneratedProperty_noForbiddenCharacter() {
|
|
// Given
|
|
let fontName: FontName = "CircularStdBold"
|
|
|
|
// When
|
|
let property = fontName.staticProperty
|
|
|
|
// Expect
|
|
let expect = """
|
|
static let CircularStdBold: ((_ size: CGFloat) -> UIFont) = { size in
|
|
UIFont(name: FontName.CircularStdBold.rawValue, size: size)!
|
|
}
|
|
"""
|
|
|
|
XCTAssertEqual(property.adaptForXCTest(), expect.adaptForXCTest())
|
|
}
|
|
|
|
func testGeneratedProperty_withForbiddenCharacter() {
|
|
// Given
|
|
let fontName: FontName = "[Circular_Std+Bold-Underline]"
|
|
|
|
// When
|
|
let property = fontName.staticProperty
|
|
|
|
// Expect
|
|
let expect = """
|
|
static let CircularStdBoldUnderline: ((_ size: CGFloat) -> UIFont) = { size in
|
|
UIFont(name: FontName.CircularStdBoldUnderline.rawValue, size: size)!
|
|
}
|
|
"""
|
|
|
|
XCTAssertEqual(property.adaptForXCTest(), expect.adaptForXCTest())
|
|
}
|
|
|
|
func testGeneratedMethod_noForbiddenCharacter() {
|
|
// Given
|
|
let fontName: FontName = "CircularStdBold"
|
|
|
|
// When
|
|
let property = fontName.method
|
|
|
|
// Expect
|
|
let expect = """
|
|
func CircularStdBold(withSize size: CGFloat) -> UIFont {
|
|
UIFont(name: FontName.CircularStdBold.rawValue, size: size)!
|
|
}
|
|
"""
|
|
|
|
XCTAssertEqual(property.adaptForXCTest(), expect.adaptForXCTest())
|
|
}
|
|
|
|
func testGeneratedMethod_withForbiddenCharacter() {
|
|
// Given
|
|
let fontName: FontName = "[Circular_Std+Bold-Underline]"
|
|
|
|
// When
|
|
let property = fontName.method
|
|
|
|
// Expect
|
|
let expect = """
|
|
func CircularStdBoldUnderline(withSize size: CGFloat) -> UIFont {
|
|
UIFont(name: FontName.CircularStdBoldUnderline.rawValue, size: size)!
|
|
}
|
|
"""
|
|
|
|
XCTAssertEqual(property.adaptForXCTest(), expect.adaptForXCTest())
|
|
}
|
|
|
|
}
|