Publish v1.0
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
Reviewed-on: #1
This commit is contained in:
83
Tests/ResgenSwiftTests/Fonts/FontNameTests.swift
Normal file
83
Tests/ResgenSwiftTests/Fonts/FontNameTests.swift
Normal file
@ -0,0 +1,83 @@
|
||||
//
|
||||
// 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())
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user