Skip to content

Commit

Permalink
REFACTOR: Migrate watch provider 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 614e0fd commit a808b3a
Show file tree
Hide file tree
Showing 4 changed files with 120 additions and 115 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,57 +17,59 @@
// limitations under the License.
//

import Foundation
import Testing
@testable import TMDb
import XCTest

final class WatchProviderRegionsRequestTests: XCTestCase {
@Suite(.tags(.requests, .watchProvider))
struct WatchProviderRegionsRequestTests {

var request: WatchProviderRegionsRequest!

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

override func tearDown() {
request = nil
super.tearDown()
}

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

XCTAssertEqual(request.path, "/watch/providers/regions")
#expect(request.path == "/watch/providers/regions")
}

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

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

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

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

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

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

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

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

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

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

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

XCTAssertEqual(request.path, "/watch/providers/movie")
#expect(request.path == "/watch/providers/movie")
}

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

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

func testQueryItemsWithWatchRegion() {
@Test("queryItems with country")
func queryItemsWithCountry() {
let request = WatchProvidersForMoviesRequest(country: "GB")

XCTAssertEqual(request.queryItems, ["watch_region": "GB"])
#expect(request.queryItems == ["watch_region": "GB"])
}

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

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

func testQueryItemsWithWatchRegionAndLanguage() {
@Test("queryItems with country and language")
func queryItemsWithCountryAndLanguage() {
let request = WatchProvidersForMoviesRequest(country: "GB", language: "en")

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

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

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

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

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

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

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

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

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

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

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

func testQueryItemsWithWatchRegion() {
@Test("queryItems with country")
func queryItemsWithCountry() {
let request = WatchProvidersForTVSeriesRequest(country: "GB")

XCTAssertEqual(request.queryItems, ["watch_region": "GB"])
#expect(request.queryItems == ["watch_region": "GB"])
}

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

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

func testQueryItemsWithWatchRegionAndLanguage() {
@Test("queryItems with country and language")
func queryItemsWithCountryAndLanguage() {
let request = WatchProvidersForTVSeriesRequest(country: "GB", language: "en")

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

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

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

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

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

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

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

}
Loading

0 comments on commit a808b3a

Please sign in to comment.