Skip to content
This repository was archived by the owner on Feb 17, 2026. It is now read-only.

Commit 354a84c

Browse files
Aleksei ZelentsovAleksei Zelentsov
authored andcommitted
add tests
1 parent 95fcccf commit 354a84c

1 file changed

Lines changed: 37 additions & 5 deletions

File tree

Tests/SmsHubApiTests/SmsHubApiTests.swift

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,42 @@ import XCTest
33
@testable import SmsHubApi
44

55
final class SmsHubApiTests: XCTestCase {
6-
func testExample() throws {
7-
// This is an example of a functional test case.
8-
// Use XCTAssert and related functions to verify your tests produce the correct
9-
// results.
10-
6+
private var smsHubAPI: ISmsHubAPI!
7+
private var apiKey: String = "api_token"
8+
9+
override func setUp() {
10+
super.setUp()
11+
smsHubAPI = SmsHubAPI(apiKey: apiKey)
12+
}
13+
14+
override func tearDown() {
15+
smsHubAPI = nil
16+
super.tearDown()
17+
}
18+
19+
func testGetBalance() async throws {
20+
let balance = try await smsHubAPI.getBalance()
21+
XCTAssertNotNil(balance, "Balance should not be nil")
22+
}
23+
24+
func testPurchasePhoneNumber() async throws {
25+
let getNumberRequest = GetNumberRequest(service: .kuhnaNaRayone, country: .russia)
26+
let result = try await smsHubAPI.purchasePhoneNumber(by: getNumberRequest)
27+
print(result.0)
28+
XCTAssertNotNil(result.0, "ID should not be nil")
29+
XCTAssertNotNil(result.1, "Phone number should not be nil")
30+
}
31+
32+
func testGetStatus() async throws {
33+
let getStatusId = 393619569 // Replace with a valid ID
34+
let result = try await smsHubAPI.getStatus(id: getStatusId)
35+
print(result)
36+
XCTAssertNotNil(result.0, "GetStatusResponse should not be nil")
37+
}
38+
39+
func testSetStatus() async throws {
40+
let setStatusId = 393619569 // Replace with a valid ID
41+
let setStatusResponse = try await smsHubAPI.setStatus(id: setStatusId, status: .cancelActivation)
42+
XCTAssertEqual(setStatusResponse, SetStatusResponse.accessCancel, "Expected status to be '.success'")
1143
}
1244
}

0 commit comments

Comments
 (0)