Skip to content

Commit

Permalink
REFACTOR: Migrate Configuration tests to Swift Testing
Browse files Browse the repository at this point in the history
  • Loading branch information
adamayoung committed Sep 17, 2024
1 parent 44acc55 commit 8c03175
Show file tree
Hide file tree
Showing 8 changed files with 130 additions and 142 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,41 +17,42 @@
// limitations under the License.
//

import Foundation
import Testing
@testable import TMDb
import XCTest

final class APIConfigurationRequestTests: XCTestCase {
@Suite(.tags(.requests, .configuration))
struct APIConfigurationRequestTests {

var request: APIConfigurationRequest!

override func setUp() {
super.setUp()
request = APIConfigurationRequest()
init() {
self.request = APIConfigurationRequest()
}

override func tearDown() {
request = nil
super.tearDown()
@Test("path is correct")
func path() {
#expect(request.path == "/configuration")
}

func testPath() {
XCTAssertEqual(request.path, "/configuration")
@Test("queryItems is empty")
func queryItemsAreEmpty() {
#expect(request.queryItems.isEmpty)
}

func testQueryItemsAreEmpty() {
XCTAssertTrue(request.queryItems.isEmpty)
@Test("method is GET")
func methodIsGet() {
#expect(request.method == .get)
}

func testMethodIsGet() {
XCTAssertEqual(request.method, .get)
@Test("headers is empty")
func headersIsEmpty() {
#expect(request.headers.isEmpty)
}

func testHeadersIsEmpty() {
XCTAssertTrue(request.headers.isEmpty)
}

func testBodyIsNil() {
XCTAssertNil(request.body)
@Test("body is nil")
func bodyIsNil() {
#expect(request.body == nil)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,45 +17,53 @@
// limitations under the License.
//

import Foundation
import Testing
@testable import TMDb
import XCTest

final class CountriesConfigurationRequestTests: XCTestCase {
@Suite(.tags(.requests, .configuration))
struct CountriesConfigurationRequestTests {

func testPath() {
@Test("path is correct")
func path() {
let request = CountriesConfigurationRequest()

XCTAssertEqual(request.path, "/configuration/countries")
#expect(request.path == "/configuration/countries")
}

func testQueryItems() {
@Test("queryItems is empty")
func queryItemsAreEmpty() {
let request = CountriesConfigurationRequest()

XCTAssertTrue(request.queryItems.isEmpty)
#expect(request.queryItems.isEmpty)
}

func testQueryItemsWithLanguage() {
@Test("queryItems with language")
func queryItemsWithLanguage() {
let request = CountriesConfigurationRequest(language: "en")

XCTAssertEqual(request.queryItems, ["language": "en"])
#expect(request.queryItems == ["language": "en"])
}

func testMethodIsGet() {
@Test("method is GET")
func methodIsGet() {
let request = CountriesConfigurationRequest()

XCTAssertEqual(request.method, .get)
#expect(request.method == .get)
}

func testHeadersIsEmpty() {
@Test("headers is empty")
func headersIsEmpty() {
let request = CountriesConfigurationRequest()

XCTAssertTrue(request.headers.isEmpty)
#expect(request.headers.isEmpty)
}

func testBodyIsNil() {
@Test("body is nil")
func bodyIsNil() {
let request = CountriesConfigurationRequest()

XCTAssertNil(request.body)
#expect(request.body == nil)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,41 +17,42 @@
// limitations under the License.
//

import Foundation
import Testing
@testable import TMDb
import XCTest

final class JobsConfigurationRequestTests: XCTestCase {
@Suite(.tags(.requests, .configuration))
struct JobsConfigurationRequestTests {

var request: JobsConfigurationRequest!

override func setUp() {
super.setUp()
request = JobsConfigurationRequest()
init() {
self.request = JobsConfigurationRequest()
}

override func tearDown() {
request = nil
super.tearDown()
@Test("path is correct")
func path() {
#expect(request.path == "/configuration/jobs")
}

func testPath() {
XCTAssertEqual(request.path, "/configuration/jobs")
@Test("queryItems is empty")
func queryItemsAreEmpty() {
#expect(request.queryItems.isEmpty)
}

func testQueryItemsAreEmpty() {
XCTAssertTrue(request.queryItems.isEmpty)
@Test("method is GET")
func methodIsGet() {
#expect(request.method == .get)
}

func testMethodIsGet() {
XCTAssertEqual(request.method, .get)
@Test("headers is empty")
func headersIsEmpty() {
#expect(request.headers.isEmpty)
}

func testHeadersIsEmpty() {
XCTAssertTrue(request.headers.isEmpty)
}

func testBodyIsNil() {
XCTAssertNil(request.body)
@Test("body is nil")
func bodyIsNil() {
#expect(request.body == nil)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,41 +17,42 @@
// limitations under the License.
//

import Foundation
import Testing
@testable import TMDb
import XCTest

final class LanguaguesConfigurationRequestTests: XCTestCase {
@Suite(.tags(.requests, .configuration))
struct LanguaguesConfigurationRequestTests {

var request: LanguaguesConfigurationRequest!

override func setUp() {
super.setUp()
request = LanguaguesConfigurationRequest()
init() {
self.request = LanguaguesConfigurationRequest()
}

override func tearDown() {
request = nil
super.tearDown()
@Test("path is correct")
func path() {
#expect(request.path == "/configuration/languages")
}

func testPath() {
XCTAssertEqual(request.path, "/configuration/languages")
@Test("queryItems is empty")
func queryItemsAreEmpty() {
#expect(request.queryItems.isEmpty)
}

func testQueryItemsAreEmpty() {
XCTAssertTrue(request.queryItems.isEmpty)
@Test("method is GET")
func methodIsGet() {
#expect(request.method == .get)
}

func testMethodIsGet() {
XCTAssertEqual(request.method, .get)
@Test("headers is empty")
func headersIsEmpty() {
#expect(request.headers.isEmpty)
}

func testHeadersIsEmpty() {
XCTAssertTrue(request.headers.isEmpty)
}

func testBodyIsNil() {
XCTAssertNil(request.body)
@Test("body is nil")
func bodyIsNil() {
#expect(request.body == nil)
}

}
Loading

0 comments on commit 8c03175

Please sign in to comment.