X-Git-Url: http://njoseph.me/gitweb/nimcoon.git/blobdiff_plain/956837326555259ef33d1bab42a3981b4082b20a..5f9cdfeff96bb2848e3dc72bab410859d78b9c65:/tests/tests.nim diff --git a/tests/tests.nim b/tests/tests.nim index 8b9e6d2..b412cb3 100644 --- a/tests/tests.nim +++ b/tests/tests.nim @@ -3,7 +3,6 @@ import unittest import lib -import nimcoon suite "Playing direct links": @@ -13,15 +12,25 @@ suite "Playing direct links": 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)) + let invalidOptionsList = [ + to_table({"musicOnly": true, "feelingLucky": false, "fullScreen": true, "download": false, "autoPlay": false}), + to_table({"musicOnly": false, "feelingLucky": true, "fullScreen": true, "download": true, "autoPlay": false}), + # autoPlay download + to_table({"musicOnly": true, "feelingLucky": true, "fullScreen": true, "download": true, "autoPlay": true}), + # autoPlay video + to_table({"musicOnly": false, "feelingLucky": true, "fullScreen": true, "download": false, "autoPlay": true}), + ] + for invalidOptions in invalidOptionsList: + check(not isValidOptions(invalidOptions)) + + let validOptionsList = [ + to_table({"musicOnly": false, "feelingLucky": true, "fullScreen": false, "download": true, "autoPlay": false}), + to_table({"musicOnly": false, "feelingLucky": true, "fullScreen": true, "download": false, "autoPlay": false}), + to_table({"musicOnly": true, "feelingLucky": true, "fullScreen": false, "download": false, "autoPlay": true}), + ] + 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")