X-Git-Url: http://njoseph.me/gitweb/nimcoon.git/blobdiff_plain/427e87f9d63a2514a8f31ba915e934fcab8399a2..a2d28598f44142969997ae56f6bd684c54d95e0b:/tests/tests.nim diff --git a/tests/tests.nim b/tests/tests.nim index a218596..fd44065 100644 --- a/tests/tests.nim +++ b/tests/tests.nim @@ -1,6 +1,9 @@ -import unittest +import + tables, + unittest import lib +import nimcoon suite "Playing direct links": @@ -8,3 +11,21 @@ suite "Playing direct links": let expected = "https://www.youtube.com/watch?v=QOEMv0S8AcA" check(sanitizeURL("https://youtu.be/QOEMv0S8AcA") == expected) check(sanitizeURL("https://www.youtube.com/watch\\?v\\=QOEMv0S8AcA") == expected) + + test "validate options": + let invalidOptionsList = [ + to_table({"musicOnly": true, "feelingLucky": false, "fullScreen": true, "download": false}), + to_table({"musicOnly": false, "feelingLucky": true, "fullScreen": true, "download": true}) + ] + for invalidOptions in invalidOptionsList: + check(not isValidOptions(invalidOptions)) + let validOptionsList = [ + to_table({"musicOnly": false, "feelingLucky": true, "fullScreen": false, "download": true}), + to_table({"musicOnly": false, "feelingLucky": true, "fullScreen": true, "download": false}) + ] + for validOptions in validOptionsList: + check(isValidOptions(validOptions)) + + test "rewrite invidious urls": + let url = "https://invidious.snopyta.org/watch?v=sZhxCUay5ks" + check(rewriteInvidiousToYouTube(url) == "https://www.youtube.com/watch?v=sZhxCUay5ks")