]> njoseph.me Git - nimcoon.git/blame - tests/tests.nim
YouTube auto-play
[nimcoon.git] / tests / tests.nim
CommitLineData
6f161e0b
JN
1import
2 tables,
3 unittest
d65a1dcf
JN
4
5import lib
6
7suite "Playing direct links":
8
9 test "sanitize URL":
d65a1dcf
JN
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)
6f161e0b
JN
13
14 test "validate options":
a2d28598 15 let invalidOptionsList = [
5f9cdfef
JN
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}),
a2d28598
JN
22 ]
23 for invalidOptions in invalidOptionsList:
24 check(not isValidOptions(invalidOptions))
5f9cdfef 25
a2d28598 26 let validOptionsList = [
5f9cdfef
JN
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}),
a2d28598
JN
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")