Skip to content

Commit

Permalink
REFACTOR: Migrate TV series tests to Swift Testing
Browse files Browse the repository at this point in the history
  • Loading branch information
adamayoung committed Sep 18, 2024
1 parent 3bb497a commit 2fb1d5a
Show file tree
Hide file tree
Showing 20 changed files with 455 additions and 449 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,57 +17,67 @@
// limitations under the License.
//

import Foundation
import Testing
@testable import TMDb
import XCTest

final class PopularTVSeriesRequestTests: XCTestCase {
@Suite(.tags(.requests, .tvSeries))
struct PopularTVSeriesRequestTests {

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

XCTAssertEqual(request.path, "/tv/popular")
#expect(request.path == "/tv/popular")
}

func testQueryItemsIsEmpty() {
@Test("queryItems is empty")
func queryItemsIsEmpty() {
let request = PopularTVSeriesRequest()

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

func testQueryItemsWithPage() {
@Test("queryItems with page")
func queryItemsWithPage() {
let request = PopularTVSeriesRequest(page: 3)

XCTAssertEqual(request.queryItems, ["page": "3"])
#expect(request.queryItems == ["page": "3"])
}

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

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

func testQueryItemsWithPageAndLanguage() {
@Test("queryItems with page and language")
func queryItemsWithPageAndLanguage() {
let request = PopularTVSeriesRequest(page: 3, language: "en")

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

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

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

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

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

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

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

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

import Foundation
import Testing
@testable import TMDb
import XCTest

final class SimilarTVSeriesRequestTests: XCTestCase {
@Suite(.tags(.requests, .tvSeries))
struct SimilarTVSeriesRequestTests {

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

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

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

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

func testQueryItemsWithPage() {
@Test("queryItems with page")
func queryItemsWithPage() {
let request = SimilarTVSeriesRequest(id: 1, page: 3)

XCTAssertEqual(request.queryItems, ["page": "3"])
#expect(request.queryItems == ["page": "3"])
}

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

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

func testQueryItemsWithPageAndLanguage() {
@Test("queryItems with page and language")
func queryItemsWithPageAndLanguage() {
let request = SimilarTVSeriesRequest(id: 1, page: 3, language: "en")

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

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

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

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

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

func testBodyIsNil() {
@Test("body is nil")
func bodyIsNil() {
let request = SimilarTVSeriesRequest(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 TVSeriesAggregateCreditsRequestTests: XCTestCase {
@Suite(.tags(.requests, .tvSeries))
struct TVSeriesAggregateCreditsRequestTests {

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

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

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

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

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

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

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

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

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

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

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

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

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

import Foundation
import Testing
@testable import TMDb
import XCTest

final class TVSeriesContentRatingsRequestTests: XCTestCase {
@Suite(.tags(.requests, .tvSeries))
struct TVSeriesContentRatingsRequestTests {

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

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

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

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

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

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

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

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

func testBodyIsNil() {
@Test("body is nil")
func bodyIsNil() {
let request = ContentRatingRequest(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 TVSeriesCreditsRequestTests: XCTestCase {
@Suite(.tags(.requests, .tvSeries))
struct TVSeriesCreditsRequestTests {

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

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

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

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

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

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

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

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

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

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

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

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

}
Loading

0 comments on commit 2fb1d5a

Please sign in to comment.