Skip to content

Commit

Permalink
[WEAV-32] add DesignCore font test
Browse files Browse the repository at this point in the history
  • Loading branch information
jisu15-kim committed Sep 14, 2024
1 parent 87e9876 commit 8fbce93
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Projects/DesignSystem/DesignCore/Sources/Pretendard.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public extension UIFont {
}
}

private struct PretendardModifier: ViewModifier {
internal struct PretendardModifier: ViewModifier {
let weight: PretendardWeight
let size: CGFloat
var lineHeight: CGFloat? = nil
Expand Down
2 changes: 1 addition & 1 deletion Projects/DesignSystem/DesignCore/Sources/Typography.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import SwiftUI

public enum Typography {
public enum Typography: CaseIterable {
// EN - Medium
case en_medium_20
case en_medium_16
Expand Down
46 changes: 46 additions & 0 deletions Projects/DesignSystem/DesignCore/UnitTest/DesignCoreTest.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
//
// DesignCoreTest.swift
// DesignCore-UnitTest
//
// Created by 김지수 on 9/14/24.
// Copyright © 2024 com.studentcenter. All rights reserved.
//

import XCTest
@testable import DesignCore

final class DesignCoreTest: XCTestCase {

override func setUpWithError() throws {
// Put setup code here. This method is called before the invocation of each test method in the class.
}

override func tearDownWithError() throws {
// Put teardown code here. This method is called after the invocation of each test method in the class.
}

func testFontImport() {
let pretendard = UIFont.pretendard(._600, size: 20)
XCTAssertEqual(pretendard.familyName, "Pretendard")
let robotoSlab = UIFont.robotoSlab(size: 20)
XCTAssertEqual(robotoSlab.familyName, "Roboto Slab")
}

func testTypography() {
/// en-typo 는 pretendardWeight 를 가져선 안됨
let enTypo = [Typography.en_medium_16, Typography.en_medium_20]
let enPretendardWeight = enTypo
.compactMap { $0.pretendardWeight }
XCTAssertEqual(enPretendardWeight, [])

/// pretendard typo 는 pretendardWeight 를 항상 가지고 있어야 함
let pretendardTypos = Typography.allCases
.filter { typo in
!enTypo.contains { $0 == typo }
}
.compactMap { $0.pretendardWeight }

let pretendardCount = Typography.allCases.count - enTypo.count
XCTAssertEqual(pretendardTypos.count, pretendardCount)
}
}
6 changes: 6 additions & 0 deletions Projects/DesignSystem/Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ let project: Project = .make(
.external(.nuke)
]
),
.makeUnitTest(
target: .DesignCore,
dependencies: [
.target(name: .DesignCore)
]
),
.make(
target: .componentsKit,
dependencies: [
Expand Down
6 changes: 6 additions & 0 deletions Workspace.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ let workspace = Workspace(
target: TargetName.coreKit.unitTestName
)
),
.testableTarget(
target: .project(
path: "./\(ProjectPath.designSystem.rawValue)",
target: TargetName.DesignCore.unitTestName
)
)
]
)
),
Expand Down

0 comments on commit 8fbce93

Please sign in to comment.