]>
Commit | Line | Data |
---|---|---|
1 | import | |
2 | tables, | |
3 | unittest | |
4 | ||
5 | import lib | |
6 | ||
7 | suite "Playing direct links": | |
8 | ||
9 | test "sanitize URL": | |
10 | let expected = "https://www.youtube.com/watch?v=QOEMv0S8AcA" | |
11 | check(sanitizeURL("https://youtu.be/QOEMv0S8AcA") == expected) | |
12 | check(sanitizeURL("https://www.youtube.com/watch\\?v\\=QOEMv0S8AcA") == expected) | |
13 | ||
14 | test "validate options": | |
15 | let invalidOptionsList = [ | |
16 | to_table({"musicOnly": true, "feelingLucky": false, "fullScreen": true, "download": false, "autoPlay": false}), | |
17 | to_table({"musicOnly": false, "feelingLucky": true, "fullScreen": true, "download": true, "autoPlay": false}), | |
18 | # autoPlay download | |
19 | to_table({"musicOnly": true, "feelingLucky": true, "fullScreen": true, "download": true, "autoPlay": true}), | |
20 | # autoPlay video | |
21 | to_table({"musicOnly": false, "feelingLucky": true, "fullScreen": true, "download": false, "autoPlay": true}), | |
22 | ] | |
23 | for invalidOptions in invalidOptionsList: | |
24 | check(not isValidOptions(invalidOptions)) | |
25 | ||
26 | let validOptionsList = [ | |
27 | to_table({"musicOnly": false, "feelingLucky": true, "fullScreen": false, "download": true, "autoPlay": false}), | |
28 | to_table({"musicOnly": false, "feelingLucky": true, "fullScreen": true, "download": false, "autoPlay": false}), | |
29 | to_table({"musicOnly": true, "feelingLucky": true, "fullScreen": false, "download": false, "autoPlay": true}), | |
30 | ] | |
31 | for validOptions in validOptionsList: | |
32 | check(isValidOptions(validOptions)) | |
33 | ||
34 | test "rewrite invidious urls": | |
35 | let url = "https://invidious.snopyta.org/watch?v=sZhxCUay5ks" | |
36 | check(rewriteInvidiousToYouTube(url) == "https://www.youtube.com/watch?v=sZhxCUay5ks") |