-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Feat] #466 - ChangeSocialEntity 구현 및 테스트
- Loading branch information
Showing
3 changed files
with
80 additions
and
0 deletions.
There are no files selected for viewing
9 changes: 9 additions & 0 deletions
9
SOPT-iOS/Projects/Modules/Networks/Sources/API/SocialAPI.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// | ||
// SocialAPI.swift | ||
// Networks | ||
// | ||
// Created by 장석우 on 12/28/24. | ||
// Copyright © 2024 SOPT-iOS. All rights reserved. | ||
// | ||
|
||
import Foundation |
35 changes: 35 additions & 0 deletions
35
SOPT-iOS/Projects/Modules/Networks/Sources/Entity/ChangeSocialAccountEntity.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// | ||
// ChangeSocialAccountEntity.swift | ||
// Networks | ||
// | ||
// Created by 장석우 on 12/28/24. | ||
// Copyright © 2024 SOPT-iOS. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
struct ChangeSocialAccountEntity: Encodable { | ||
let phone: String | ||
let authPlatform: SocialAccountType | ||
let code: String | ||
|
||
|
||
enum CodingKeys: CodingKey { | ||
case phone | ||
case authPlatform | ||
case code | ||
} | ||
|
||
func encode(to encoder: any Encoder) throws { | ||
var container = encoder.container(keyedBy: CodingKeys.self) | ||
try container.encode(self.phone, forKey: .phone) | ||
try container.encode(self.authPlatform.rawValue, forKey: .authPlatform) | ||
try container.encode(self.code, forKey: .code) | ||
} | ||
|
||
} | ||
|
||
enum SocialAccountType: String, Encodable { | ||
case google = "GOOGLE" | ||
case apple = "APPLE" | ||
} |
36 changes: 36 additions & 0 deletions
36
SOPT-iOS/Projects/Modules/Networks/Tests/Sources/SocialEntityTests.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// | ||
// SocialEntityTests.swift | ||
// NetworksTests | ||
// | ||
// Created by 장석우 on 12/28/24. | ||
// Copyright © 2024 SOPT-iOS. All rights reserved. | ||
// | ||
|
||
import XCTest | ||
@testable import Networks | ||
|
||
final class SocialEntityTests: XCTestCase { | ||
|
||
override func setUp() { | ||
} | ||
|
||
override func tearDown() { | ||
} | ||
|
||
func test_changeSocialEntity의_authPlatform가_enum의_RAW값으로_encode되는가() throws { | ||
|
||
// given | ||
let encoder = JSONEncoder() | ||
let entity = ChangeSocialAccountEntity(phone: "", authPlatform: .apple, code: "") | ||
|
||
// when | ||
let data = try encoder.encode(entity) | ||
let jsonString = String(data: data, encoding: .utf8) | ||
|
||
//then | ||
XCTAssertTrue(jsonString!.contains("\"authPlatform\":\"APPLE\""), "authPlatform 값이 올바르게 인코딩되지 않았습니다.") | ||
|
||
} | ||
|
||
|
||
} |