diff --git a/Projects/DesignSystem/DesignCore/Sources/Pretendard.swift b/Projects/DesignSystem/DesignCore/Sources/Pretendard.swift index ae19a4d..bcaf83b 100644 --- a/Projects/DesignSystem/DesignCore/Sources/Pretendard.swift +++ b/Projects/DesignSystem/DesignCore/Sources/Pretendard.swift @@ -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 diff --git a/Projects/DesignSystem/DesignCore/Sources/Typography.swift b/Projects/DesignSystem/DesignCore/Sources/Typography.swift index 7114b0e..27f662c 100644 --- a/Projects/DesignSystem/DesignCore/Sources/Typography.swift +++ b/Projects/DesignSystem/DesignCore/Sources/Typography.swift @@ -8,7 +8,7 @@ import SwiftUI -public enum Typography { +public enum Typography: CaseIterable { // EN - Medium case en_medium_20 case en_medium_16 diff --git a/Projects/DesignSystem/DesignCore/UnitTest/DesignCoreTest.swift b/Projects/DesignSystem/DesignCore/UnitTest/DesignCoreTest.swift new file mode 100644 index 0000000..061c98c --- /dev/null +++ b/Projects/DesignSystem/DesignCore/UnitTest/DesignCoreTest.swift @@ -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) + } +} diff --git a/Projects/DesignSystem/Project.swift b/Projects/DesignSystem/Project.swift index 063dbaf..87efb20 100644 --- a/Projects/DesignSystem/Project.swift +++ b/Projects/DesignSystem/Project.swift @@ -11,6 +11,12 @@ let project: Project = .make( .external(.nuke) ] ), + .makeUnitTest( + target: .DesignCore, + dependencies: [ + .target(name: .DesignCore) + ] + ), .make( target: .componentsKit, dependencies: [ diff --git a/Workspace.swift b/Workspace.swift index 7ca8d0d..9884bde 100644 --- a/Workspace.swift +++ b/Workspace.swift @@ -49,6 +49,12 @@ let workspace = Workspace( target: TargetName.coreKit.unitTestName ) ), + .testableTarget( + target: .project( + path: "./\(ProjectPath.designSystem.rawValue)", + target: TargetName.DesignCore.unitTestName + ) + ) ] ) ),