From e15d3c32d37da33a1203219c65bbbac3c9711488 Mon Sep 17 00:00:00 2001 From: cayZ <13341339+Cay-Zhang@users.noreply.github.com> Date: Tue, 9 Mar 2021 11:36:53 +0800 Subject: [PATCH] updated radar tests --- RSSBudTests/RSSBudTests.swift | 104 +++------------------------------- 1 file changed, 9 insertions(+), 95 deletions(-) diff --git a/RSSBudTests/RSSBudTests.swift b/RSSBudTests/RSSBudTests.swift index f0e4553a..96dda434 100644 --- a/RSSBudTests/RSSBudTests.swift +++ b/RSSBudTests/RSSBudTests.swift @@ -79,92 +79,21 @@ class RSSBudTests: XCTestCase { } } - func testBilibiliSpace() throws { - measureMetrics([.wallClockTime], automaticallyStartMeasuring: false) { - let expectation = XCTestExpectation(description: "Detect the 8 feeds from the url.") - - let urlString = "https://space.bilibili.com/53456" - let url = URLComponents(autoPercentEncoding: urlString)! - - startMeasuring() - - RSSHub.Radar.detecting(url: url) - .sink { _ in - - } receiveValue: { feeds in - self.stopMeasuring() - XCTAssertEqual(feeds.count, 8, "Unexpected feed count.") - expectation.fulfill() - }.store(in: &self.cancelBag) - - wait(for: [expectation], timeout: 3.0) - } - } - - func testBilibiliVideo() { - let expectation = XCTestExpectation(description: "Detect the 2 feeds from the url.") - - let urlString = "https://www.bilibili.com/video/BV1qK4y1v7yQ?p=2" - let url = URLComponents(autoPercentEncoding: urlString)! - - RSSHub.Radar.detecting(url: url) - .sink { _ in - - } receiveValue: { feeds in - XCTAssertEqual(feeds.count, 2, "Unexpected feed count.") - expectation.fulfill() - }.store(in: &self.cancelBag) - - wait(for: [expectation], timeout: 3.0) + func testTrivialDetections() throws { + _testProcess("bilibili 空间", urlString: "https://space.bilibili.com/53456", feedCount: 8) + _testProcess("企鹅电竞直播间", urlString: "https://egame.qq.com/526905271", feedCount: 1) } - func testQQEgame() { - - let expectation = XCTestExpectation(description: "Detect the feed from the url.") - - let urlString = "https://egame.qq.com/526905271" - let url = URLComponents(autoPercentEncoding: urlString)! - - RSSHub.Radar.detecting(url: url) - .sink { _ in - - } receiveValue: { feeds in - XCTAssertEqual(feeds.count, 1, "Unexpected feed count.") - expectation.fulfill() - }.store(in: &self.cancelBag) - - wait(for: [expectation], timeout: 3.0) + func testMobileSubdomains() { + _testProcess("斋书苑", urlString: "https://m.zhaishuyuan.com/book/38082", feedCount: 1) + _testProcess("Twitter 用户", urlString: "https://mobile.twitter.com/SwiftUILab", feedCount: 3) } - func testMobileSubdomains() { - let expectation1 = XCTestExpectation(description: "Detect the feed from the url containing a mobile subdomain.") - let urlString1 = "https://m.zhaishuyuan.com/book/38082" - let url1 = URLComponents(autoPercentEncoding: urlString1)! - - RSSHub.Radar.detecting(url: url1) - .sink { _ in - - } receiveValue: { feeds in - XCTAssertEqual(feeds.count, 1, "Unexpected feed count.") - expectation1.fulfill() - }.store(in: &self.cancelBag) - - let expectation2 = XCTestExpectation(description: "Detect the feed from the url containing a mobile subdomain.") - let urlString2 = "https://mobile.twitter.com/SwiftUILab" - let url2 = URLComponents(autoPercentEncoding: urlString2)! - - RSSHub.Radar.detecting(url: url2) - .sink { _ in - - } receiveValue: { feeds in - XCTAssertEqual(feeds.count, 3, "Unexpected feed count.") - expectation2.fulfill() - }.store(in: &self.cancelBag) - - wait(for: [expectation1, expectation2], timeout: 6.0) + func testURLDetections() throws { + _testProcess("bilibili 视频", urlString: "https://www.bilibili.com/video/BV1qK4y1v7yQ?p=2", feedCount: 2) } - func testHTMLParsing() { + func testDocumentDetections() { _testProcess("谷歌相册", urlString: "https://photos.google.com/share/AF1QipN-3SZHWnuYatO_p13elqJZjhIXBUV_ySkStFuYPXCusNA1U35Nwq5xeWqxEIfRRw?key=dzAzZGtzcUxpYW4wV2t6MXZJWk9VdURoUnJsSk1n", feedCount: 1) _testProcess("Telegram 频道", urlString: "https://t.me/RSSBud", feedCount: 1) _testProcess("Telegram 群组", urlString: "https://t.me/RSSBud_Discussion", feedCount: 0) @@ -176,20 +105,5 @@ class RSSBudTests: XCTestCase { // _testProcess("快递 100 快递追踪", urlString: "https://kuaidi100.com/", feedCount: 1) // _testProcess("Behance User", urlString: "https://www.behance.net/mishapetrick", feedCount: 1) } - - func testRSSHubRadarRulesConsistency() { - let expectation = XCTestExpectation(description: "Remote rules are equal to bundled rules.") - - let path = Bundle.main.path(forResource: "radar-rules", ofType: "js")! - let bundledRules = try! String(contentsOfFile: path) - - RuleManager.shared.remoteRules() - .sink { _ in } receiveValue: { remoteRules in - XCTAssertEqual(remoteRules, bundledRules, "Remote rules and bundled rules are different.") - expectation.fulfill() - }.store(in: &self.cancelBag) - - wait(for: [expectation], timeout: 3.0) - } }