Skip to content

Commit e8d2b46

Browse files
author
quoid
committed
tests for encoded check and getRemoteFileContents
1 parent 3182f79 commit e8d2b46

1 file changed

Lines changed: 35 additions & 1 deletion

File tree

extension/UserscriptsTests/UserscriptsTests.swift

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,41 @@ class UserscriptsTests: XCTestCase {
5353
// then
5454
XCTAssert(result.elementsEqual(strs))
5555
}
56-
56+
57+
func testEncodedCheck() throws {
58+
let urls = [
59+
"https://greasyfork.org/scripts/416338-redirect-外链跳转/code/redirect%20外链跳转.user.js",
60+
"https://raw.githubusercontent.com/Anarios/return-youtube-dislike/main/Extensions/UserScript/Return%20Youtube%20Dislike.user.js",
61+
"https://cdn.frankerfacez.com/static/ffz_injector.user.js",
62+
"http://www.k21p.com/example.user.js", // add http protocol
63+
"https://greasyfork.org/scripts/416338-redirect-外链跳转/code/redirect 外链跳转.user.js"
64+
]
65+
var result = [String]()
66+
for url in urls {
67+
if isEncoded(url) {
68+
result.append(url)
69+
}
70+
}
71+
// 2 urls already percent encoded
72+
XCTAssert(result.count == 2)
73+
}
74+
75+
func testGetRemoteFileContents() throws {
76+
let urls = [
77+
"https://greasyfork.org/scripts/416338-redirect-外链跳转/code/redirect%20外链跳转.user.js",
78+
"https://greasyfork.org/scripts/416338-redirect-外链跳转/code/redirect 外链跳转.user.js",
79+
"https://raw.githubusercontent.com/Anarios/return-youtube-dislike/main/Extensions/UserScript/Return%20Youtube%20Dislike.user.js",
80+
"https://cdn.frankerfacez.com/static/ffz_injector.user.js",
81+
"http://www.k21p.com/example.user.js" // add http protocol
82+
]
83+
var result = [String]()
84+
for url in urls {
85+
if let contents = getRemoteFileContents(url) {
86+
result.append(contents)
87+
}
88+
}
89+
XCTAssert(result.count == urls.count)
90+
}
5791

5892
func testPerformanceExample() throws {
5993
// This is an example of a performance test case.

0 commit comments

Comments
 (0)