mirror of
https://github.com/yattee/yattee.git
synced 2025-08-05 02:04:07 +00:00
Open videos via URL scheme
This commit is contained in:
19
Tests macOS/Extensions/Int+FormatTests.swift
Normal file
19
Tests macOS/Extensions/Int+FormatTests.swift
Normal file
@@ -0,0 +1,19 @@
|
||||
import XCTest
|
||||
|
||||
final class IntFormatTests: XCTestCase {
|
||||
func testFormattedAsAbbreviation() throws {
|
||||
let samples: [Int: String] = [
|
||||
1: "1",
|
||||
999: "999",
|
||||
1000: "1K",
|
||||
1101: "1,1K",
|
||||
12345: "12,3K",
|
||||
123_456: "123,5K",
|
||||
123_626_789: "123,6M"
|
||||
]
|
||||
|
||||
samples.forEach { value, formatted in
|
||||
XCTAssertEqual(value.formattedAsAbbreviation(), formatted)
|
||||
}
|
||||
}
|
||||
}
|
@@ -8,28 +8,6 @@
|
||||
import XCTest
|
||||
|
||||
class Tests_macOS: XCTestCase {
|
||||
override func setUpWithError() throws {
|
||||
// Put setup code here. This method is called before the invocation of each test method in the class.
|
||||
|
||||
// In UI tests it is usually best to stop immediately when a failure occurs.
|
||||
continueAfterFailure = false
|
||||
|
||||
// In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this.
|
||||
}
|
||||
|
||||
override func tearDownWithError() throws {
|
||||
// Put teardown code here. This method is called after the invocation of each test method in the class.
|
||||
}
|
||||
|
||||
func testExample() throws {
|
||||
// UI tests must launch the application that they test.
|
||||
let app = XCUIApplication()
|
||||
app.launch()
|
||||
|
||||
// Use recording to get started writing UI tests.
|
||||
// Use XCTAssert and related functions to verify your tests produce the correct results.
|
||||
}
|
||||
|
||||
func testLaunchPerformance() throws {
|
||||
if #available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 7.0, *) {
|
||||
// This measures how long it takes to launch your application.
|
||||
|
39
Tests macOS/VideoURLParserTests.swift
Normal file
39
Tests macOS/VideoURLParserTests.swift
Normal file
@@ -0,0 +1,39 @@
|
||||
import XCTest
|
||||
|
||||
final class VideoURLParserTests: XCTestCase {
|
||||
func testIDParsing() throws {
|
||||
let samples: [String: String] = [
|
||||
"https://www.youtube.com/watch?v=_E0PWQvW-14&list=WL&index=4&t=155s": "_E0PWQvW-14",
|
||||
"https://youtu.be/IRsc57nK8mg?t=20": "IRsc57nK8mg",
|
||||
"https://www.youtube-nocookie.com/watch?index=4&v=cE1PSQrWc11&list=WL&t=155s": "cE1PSQrWc11",
|
||||
"https://invidious.snopyta.org/watch?v=XpowfENlJAw" : "XpowfENlJAw",
|
||||
"/watch?v=VQ_f5RymW70" : "VQ_f5RymW70",
|
||||
"watch?v=IUTGFQpKaPU&t=30s": "IUTGFQpKaPU"
|
||||
]
|
||||
|
||||
samples.forEach { url, id in
|
||||
XCTAssertEqual(
|
||||
VideoURLParser(url: URL(string: url)!).id,
|
||||
id
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
func testTimeParsing() throws {
|
||||
let samples: [String: TimeInterval?] = [
|
||||
"https://www.youtube.com/watch?v=_E0PWQvW-14&list=WL&index=4&t=155s": 155,
|
||||
"https://youtu.be/IRsc57nK8mg?t=20m10s": 1210,
|
||||
"https://youtu.be/IRsc57nK8mg?t=3x4z": nil,
|
||||
"https://www.youtube-nocookie.com/watch?index=4&v=cE1PSQrWc11&list=WL&t=2H3m5s": 7385,
|
||||
"https://youtu.be/VQ_f5RymW70?t=378": 378,
|
||||
"watch?v=IUTGFQpKaPU&t=30s": 30
|
||||
]
|
||||
|
||||
samples.forEach { url, time in
|
||||
XCTAssertEqual(
|
||||
VideoURLParser(url: URL(string: url)!).time,
|
||||
time
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user