From e2171d98e75e7ef1a5ffc63bb087cc35b561638c Mon Sep 17 00:00:00 2001 From: Ahmed Shendy Date: Wed, 6 Sep 2023 19:22:34 +0300 Subject: [PATCH] test: simple test for decoding PodcastPerson --- Tests/SyndiKitTests/RSSCodedTests.swift | 36 +++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/Tests/SyndiKitTests/RSSCodedTests.swift b/Tests/SyndiKitTests/RSSCodedTests.swift index 05089f3..5958a92 100644 --- a/Tests/SyndiKitTests/RSSCodedTests.swift +++ b/Tests/SyndiKitTests/RSSCodedTests.swift @@ -242,6 +242,42 @@ public final class SyndiKitTests: XCTestCase { XCTAssertNotNil(episode.summary) } + func testEpisodePodcastPerson() { + 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 item1Title = "WWDC Spectacular (Part 2) with Peter Witham" + let item2Title = "How to WWDC with Peter Witham" + + let items = rss.channel.items.filter { $0.title == item1Title || $0.title == item2Title } + + XCTAssertFalse(items.isEmpty) + + for item in items { + let host = item.podcastPerson?.first(where: { $0.role.lowercased() == "host" }) + + XCTAssertNotNil(host) + XCTAssertEqual(host?.name, "Leo Dion") + XCTAssertEqual(host?.href, "https://brightdigit.com") + XCTAssertEqual(host?.img, "https://images.transistor.fm/file/transistor/images/person/401f05b8-f63f-4b96-803f-c7ac9233b459/1664979700-image.jpg") + + // Both podcasts have the same guest + let guest = item.podcastPerson?.first(where: { $0.role.lowercased() == "guest" }) + + XCTAssertNotNil(guest) + XCTAssertEqual(guest?.name, "CompileSwift") + XCTAssertEqual(guest?.href, "https://compileswift.com") + XCTAssertEqual(guest?.img, "https://images.transistor.fm/file/transistor/images/person/e36ebf22-69fa-4e4f-a79b-1348c4d39267/1668262451-image.jpg") + } + } + func testEpisodeCDataSummary() { guard let feed = try? Content.xmlFeeds["empowerapps-show-cdata_summary"]?.get() else { XCTFail("Missing Podcast \(name)")