Skip to content

Commit

Permalink
test: for episode with no persons
Browse files Browse the repository at this point in the history
  • Loading branch information
devahmedshendy committed Sep 6, 2023
1 parent e2171d9 commit f0a5c48
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
3 changes: 3 additions & 0 deletions Sources/SyndiKit/Formats/Media/PodcastEpisode.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public protocol PodcastEpisode {
var duration: TimeInterval? { get }
var image: iTunesImage? { get }
var enclosure: Enclosure { get }
var people: [PodcastPerson] { get }
}

struct PodcastEpisodeProperties: PodcastEpisode {
Expand All @@ -21,6 +22,7 @@ struct PodcastEpisodeProperties: PodcastEpisode {
public let duration: TimeInterval?
public let image: iTunesImage?
public let enclosure: Enclosure
public let people: [PodcastPerson]

init?(rssItem: RSSItem) {
guard let enclosure = rssItem.enclosure else {
Expand All @@ -35,5 +37,6 @@ struct PodcastEpisodeProperties: PodcastEpisode {
duration = rssItem.itunesDuration?.value
image = rssItem.itunesImage
self.enclosure = enclosure
people = rssItem.podcastPerson ?? []
}
}
23 changes: 22 additions & 1 deletion Tests/SyndiKitTests/RSSCodedTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,28 @@ public final class SyndiKitTests: XCTestCase {
XCTAssertNotNil(episode.summary)
}

func testEpisodePodcastPerson() {
func testEpisodesWithNoPersons() {
guard let feed = try? Content.xmlFeeds["empowerapps-show-cdata_summary"]?.get() else {
XCTFail("Missing Podcast \(name)")
return
}

guard let rss = feed as? RSSFeed else {
XCTFail("Wrong Type \(name)")
return
}

let itemTitle = "My Taylor Deep Dish Swift Heroes World Tour"

guard let item = rss.channel.items.first(where: { $0.title == itemTitle } ) else {
XCTFail("Expected to find episode of title: \(itemTitle)")
return
}

XCTAssertNil(item.podcastPerson)
}

func testEpisodesWithHostAndGuestPersons() {
guard let feed = try? Content.xmlFeeds["empowerapps-show-cdata_summary"]?.get() else {
XCTFail("Missing Podcast \(name)")
return
Expand Down

0 comments on commit f0a5c48

Please sign in to comment.