Skip to content

Commit

Permalink
REFACTOR: Migrate Person 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 0922f06 commit f48a356
Show file tree
Hide file tree
Showing 9 changed files with 235 additions and 225 deletions.
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 PersonCombinedCreditsRequestTests: XCTestCase {
@Suite(.tags(.requests, .people))
struct PersonCombinedCreditsRequestTests {

func testPath() {
@Test("path is correct")
func path() {
let request = PersonCombinedCreditsRequest(id: 1)

XCTAssertEqual(request.path, "/person/1/combined_credits")
#expect(request.path == "/person/1/combined_credits")
}

func testQueryItemsIsEmpty() {
@Test("queryItems is empty")
func queryItemsIsEmpty() {
let request = PersonCombinedCreditsRequest(id: 1)

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

func testQueryItemsWithLanguage() {
@Test("queryItems with language")
func queryItemsWithLanguage() {
let request = PersonCombinedCreditsRequest(id: 1, language: "en")

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

func testMethodIsGet() {
@Test("method is GET")
func methodIsGet() {
let request = PersonCombinedCreditsRequest(id: 1)

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

func testHeadersIsEmpty() {
@Test("headers is empty")
func headersIsEmpty() {
let request = PersonCombinedCreditsRequest(id: 1)

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

func testBodyIsNil() {
@Test("body is nil")
func bodyIsNil() {
let request = PersonCombinedCreditsRequest(id: 1)

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 PersonExternalLinksRequestTests: XCTestCase {
@Suite(.tags(.requests, .people))
struct PersonExternalLinksRequestTests {

var request: PersonExternalLinksRequest!

override func setUp() {
super.setUp()
request = PersonExternalLinksRequest(id: 1)
init() {
self.request = PersonExternalLinksRequest(id: 1)
}

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

func testPath() {
XCTAssertEqual(request.path, "/person/1/external_ids")
@Test("queryItems is empty")
func queryItemsIsEmpty() {
#expect(request.queryItems.isEmpty)
}

func testQueryItemsIsEmpty() {
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 PersonImagesRequestTests: XCTestCase {
@Suite(.tags(.requests, .people))
struct PersonImagesRequestTests {

var request: PersonImagesRequest!

override func setUp() {
super.setUp()
request = PersonImagesRequest(id: 1)
init() {
self.request = PersonImagesRequest(id: 1)
}

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

func testPath() {
XCTAssertEqual(request.path, "/person/1/images")
@Test("queryItems is empty")
func queryItemsIsEmpty() {
#expect(request.queryItems.isEmpty)
}

func testQueryItemsIsEmpty() {
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 PersonMovieCreditsRequestTests: XCTestCase {
@Suite(.tags(.requests, .people))
struct PersonMovieCreditsRequestTests {

func testPath() {
@Test("path is correct")
func path() {
let request = PersonMovieCreditsRequest(id: 1)

XCTAssertEqual(request.path, "/person/1/movie_credits")
#expect(request.path == "/person/1/movie_credits")
}

func testQueryItemsIsEmpty() {
@Test("queryItems is empty")
func queryItemsIsEmpty() {
let request = PersonMovieCreditsRequest(id: 1)

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

func testQueryItemsWithLanguage() {
@Test("queryItems with language")
func queryItemsWithLanguage() {
let request = PersonMovieCreditsRequest(id: 1, language: "en")

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

func testMethodIsGet() {
@Test("method is GET")
func methodIsGet() {
let request = PersonMovieCreditsRequest(id: 1)

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

func testHeadersIsEmpty() {
@Test("headers is empty")
func headersIsEmpty() {
let request = PersonMovieCreditsRequest(id: 1)

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

func testBodyIsNil() {
@Test("body is nil")
func bodyIsNil() {
let request = PersonMovieCreditsRequest(id: 1)

XCTAssertNil(request.body)
#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 PersonRequestTests: XCTestCase {
@Suite(.tags(.requests, .people))
struct PersonRequestTests {

func testPath() {
@Test("path is correct")
func path() {
let request = PersonRequest(id: 1)

XCTAssertEqual(request.path, "/person/1")
#expect(request.path == "/person/1")
}

func testQueryItemsIsEmpty() {
@Test("queryItems is empty")
func queryItemsIsEmpty() {
let request = PersonRequest(id: 1)

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

func testQueryItemsWithLanguage() {
@Test("queryItems with language")
func queryItemsWithLanguage() {
let request = PersonRequest(id: 1, language: "en")

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

func testMethodIsGet() {
@Test("method is GET")
func methodIsGet() {
let request = PersonRequest(id: 1)

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

func testHeadersIsEmpty() {
@Test("headers is empty")
func headersIsEmpty() {
let request = PersonRequest(id: 1)

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

func testBodyIsNil() {
@Test("body is nil")
func bodyIsNil() {
let request = PersonRequest(id: 1)

XCTAssertNil(request.body)
#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 PersonTVSeriesCreditsRequestTests: XCTestCase {
@Suite(.tags(.requests, .people))
struct PersonTVSeriesCreditsRequestTests {

func testPath() {
@Test("path is correct")
func path() {
let request = PersonTVSeriesCreditsRequest(id: 1)

XCTAssertEqual(request.path, "/person/1/tv_credits")
#expect(request.path == "/person/1/tv_credits")
}

func testQueryItemsIsEmpty() {
@Test("queryItems is empty")
func queryItemsIsEmpty() {
let request = PersonTVSeriesCreditsRequest(id: 1)

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

func testQueryItemsWithLanguage() {
@Test("queryItems with language")
func queryItemsWithLanguage() {
let request = PersonTVSeriesCreditsRequest(id: 1, language: "en")

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

func testMethodIsGet() {
@Test("method is GET")
func methodIsGet() {
let request = PersonTVSeriesCreditsRequest(id: 1)

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

func testHeadersIsEmpty() {
@Test("headers is empty")
func headersIsEmpty() {
let request = PersonTVSeriesCreditsRequest(id: 1)

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

func testBodyIsNil() {
@Test("body is nil")
func bodyIsNil() {
let request = PersonTVSeriesCreditsRequest(id: 1)

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

}
Loading

0 comments on commit f48a356

Please sign in to comment.