Skip to content

Commit 35f1b8d

Browse files
committed
[Update] Refine test cases
1 parent f6ac4d1 commit 35f1b8d

2 files changed

Lines changed: 26 additions & 1 deletion

File tree

Tests/AvailabilityTest.swift

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import XCTest
1010
@testable import APIWrapper
1111

1212
final class AvailabilityTests: XCTestCase {
13-
func testExample() throws {
13+
func testTupleParamAPI() throws {
1414
let param: (id: Int, name: String?) = (1, nil)
1515
let info = TestAPI.$tupleParamAPI.createRequestInfo(param)
1616

@@ -23,6 +23,12 @@ final class AvailabilityTests: XCTestCase {
2323
XCTAssertNil(info.specialBaseURL)
2424
}
2525

26+
func testEnumParamAPI() throws {
27+
let info = TestAPI.$enumAPI.createRequestInfo(.one)
28+
29+
XCTAssertEqual(info.parameters, packToParameters(["id": TestEnum.one.rawValue]))
30+
}
31+
2632
private func packToParameters(_ value: [String: Int?]) -> AnyAPIParameter {
2733
return .init(value.mapValues { AnyAPIParameter($0) })
2834
}
@@ -45,4 +51,9 @@ fileprivate struct TestAPI {
4551
static var test2API: APIParameterBuilder<(id: String, name: String)>? = .init {
4652
["id": $0.id, "name": $0.name]
4753
}
54+
55+
@POST("/api/v1/enum_param")
56+
static var enumAPI: APIParameterBuilder<TestEnum>? = .init {
57+
["id": $0]
58+
}
4859
}

Tests/TestEnum.swift

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
//
2+
// TestEnum.swift
3+
// RaAPIWrapper
4+
//
5+
// Created by Rakuyo on 2023/5/16.
6+
// Copyright © 2022 Rakuyo. All rights reserved.
7+
//
8+
9+
import Foundation
10+
11+
enum TestEnum: Int {
12+
case one = 1
13+
case two = 2
14+
}

0 commit comments

Comments
 (0)