Skip to content

Commit

Permalink
REFACTOR: Migrate TV season 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 40cd874 commit 7fd83c1
Show file tree
Hide file tree
Showing 6 changed files with 144 additions and 132 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@ jobs:
matrix:
include:
- name: iOS
destination: platform=iOS Simulator,name=iPhone 15,OS=17.5
destination: platform=iOS Simulator,name=iPhone 15,OS=18.0
- name: watchOS
destination: platform=watchOS Simulator,name=Apple Watch Series 9 (45mm),OS=10.5
destination: platform=watchOS Simulator,name=Apple Watch Series 9 (45mm),OS=11.0
- name: tvOS
destination: platform=tvOS Simulator,name=Apple TV 4K (3rd generation),OS=17.5
destination: platform=tvOS Simulator,name=Apple TV 4K (3rd generation),OS=18.0
- name: visionOS
destination: platform=visionOS Simulator,name=Apple Vision Pro,OS=1.2
destination: platform=visionOS Simulator,name=Apple Vision Pro,OS=2.0
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down
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 TVSeasonAggregateCreditsRequestTests: XCTestCase {
@Suite(.tags(.requests, .tvSeason))
struct TVSeasonAggregateCreditsRequestTests {

func testPath() {
@Test("path is correct")
func path() {
let request = TVSeasonAggregateCreditsRequest(seasonNumber: 2, tvSeriesID: 1)

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

func testQueryItemsIsEmpty() {
@Test("queryItems is empty")
func queryItemsIsEmpty() {
let request = TVSeasonAggregateCreditsRequest(seasonNumber: 2, tvSeriesID: 1)

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

func testQueryItemsWithLanguage() {
@Test("queryItems with language")
func queryItemsWithLanguage() {
let request = TVSeasonAggregateCreditsRequest(seasonNumber: 2, tvSeriesID: 1, language: "en")

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

func testMethodIsGet() {
@Test("method is GET")
func methodIsGet() {
let request = TVSeasonAggregateCreditsRequest(seasonNumber: 2, tvSeriesID: 1)

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

func testHeadersIsEmpty() {
@Test("headers is empty")
func headersIsEmpty() {
let request = TVSeasonAggregateCreditsRequest(seasonNumber: 2, tvSeriesID: 1)

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

func testBodyIsNil() {
@Test("body is nil")
func bodyIsNil() {
let request = TVSeasonAggregateCreditsRequest(seasonNumber: 2, tvSeriesID: 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 TVSeasonImagesRequestTests: XCTestCase {
@Suite(.tags(.requests, .tvSeason))
struct TVSeasonImagesRequestTests {

func testPath() {
@Test("path is correct")
func path() {
let request = TVSeasonImagesRequest(seasonNumber: 2, tvSeriesID: 3)

XCTAssertEqual(request.path, "/tv/3/season/2/images")
#expect(request.path == "/tv/3/season/2/images")
}

func testQueryItemsIsEmpty() {
@Test("queryItems is empty")
func queryItemsIsEmpty() {
let request = TVSeasonImagesRequest(seasonNumber: 2, tvSeriesID: 3)

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

func testQueryItemsWithLanguages() {
@Test("queryItems with languages")
func queryItemsWithLanguages() {
let request = TVSeasonImagesRequest(seasonNumber: 2, tvSeriesID: 3, languages: ["en-GB", "fr"])

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

func testMethodIsGet() {
@Test("method is GET")
func methodIsGet() {
let request = TVSeasonImagesRequest(seasonNumber: 2, tvSeriesID: 3)

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

func testHeadersIsEmpty() {
@Test("headers is empty")
func headersIsEmpty() {
let request = TVSeasonImagesRequest(seasonNumber: 2, tvSeriesID: 3)

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

func testBodyIsNil() {
@Test("body is nil")
func bodyIsNil() {
let request = TVSeasonImagesRequest(seasonNumber: 2, tvSeriesID: 3)

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

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

import Foundation
import Testing
@testable import TMDb
import XCTest

final class TVSeasonRequestTests: XCTestCase {
@Suite(.tags(.requests, .tvSeason))
struct TVSeasonRequestTests {

func testPath() {
@Test("path is correct")
func path() {
let request = TVSeasonRequest(seasonNumber: 2, tvSeriesID: 3)
XCTAssertEqual(request.path, "/tv/3/season/2")

#expect(request.path == "/tv/3/season/2")
}

func testQueryItemsIsEmpty() {
@Test("queryItems is empty")
func queryItemsIsEmpty() {
let request = TVSeasonRequest(seasonNumber: 2, tvSeriesID: 3)

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

func testQueryItemsWithLanguage() {
@Test("queryItems with language")
func queryItemsWithLanguage() {
let request = TVSeasonRequest(seasonNumber: 2, tvSeriesID: 3, language: "en")

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

func testMethodIsGet() {
@Test("method is GET")
func methodIsGet() {
let request = TVSeasonRequest(seasonNumber: 2, tvSeriesID: 3)

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

func testHeadersIsEmpty() {
@Test("headers is empty")
func headersIsEmpty() {
let request = TVSeasonRequest(seasonNumber: 2, tvSeriesID: 3)

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

func testBodyIsNil() {
@Test("body is nil")
func bodyIsNil() {
let request = TVSeasonRequest(seasonNumber: 2, tvSeriesID: 3)

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

func testPath() {
@Test("path is correct")
func path() {
let request = TVSeasonVideosRequest(seasonNumber: 2, tvSeriesID: 3)

XCTAssertEqual(request.path, "/tv/3/season/2/videos")
#expect(request.path == "/tv/3/season/2/videos")
}

func testQueryItemsIsEmpty() {
@Test("queryItems is empty")
func queryItemsIsEmpty() {
let request = TVSeasonVideosRequest(seasonNumber: 2, tvSeriesID: 3)

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

func testQueryItemsWithLanguages() {
@Test("queryItems with languages")
func queryItemsWithLanguages() {
let request = TVSeasonVideosRequest(seasonNumber: 2, tvSeriesID: 3, languages: ["en-GB", "fr"])

XCTAssertEqual(request.queryItems["include_video_language"], "en-GB,fr")
#expect(request.queryItems == ["include_video_language": "en-GB,fr"])
}

func testMethodIsGet() {
@Test("method is GET")
func methodIsGet() {
let request = TVSeasonVideosRequest(seasonNumber: 2, tvSeriesID: 3)

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

func testHeadersIsEmpty() {
@Test("headers is empty")
func headersIsEmpty() {
let request = TVSeasonVideosRequest(seasonNumber: 2, tvSeriesID: 3)

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

func testBodyIsNil() {
@Test("body is nil")
func bodyIsNil() {
let request = TVSeasonVideosRequest(seasonNumber: 2, tvSeriesID: 3)

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

}
Loading

0 comments on commit 7fd83c1

Please sign in to comment.