mirror of
https://github.com/iv-org/invidious.git
synced 2026-11-05 03:17:17 +00:00
chore: Encapsulate more functions into their own modules and improve spec files (#6046)
* chore: Encapsulate more functions into their own modules and improve specs * update path for required .cr file in search/hastag_spec.cr * make the linter happy * Align PR changes with the current source code
This commit is contained in:
23
spec/invidious/channel/community_spec.cr
Normal file
23
spec/invidious/channel/community_spec.cr
Normal file
File diff suppressed because one or more lines are too long
26
spec/invidious/helpers/tokens_spec.cr
Normal file
26
spec/invidious/helpers/tokens_spec.cr
Normal file
@@ -0,0 +1,26 @@
|
||||
require "../../spec_helper"
|
||||
|
||||
Spectator.describe Invidious::Helpers::Tokens do
|
||||
describe ".sign_token" do
|
||||
it "correctly signs a given hash" do
|
||||
token = {
|
||||
"session" => "v1:AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
|
||||
"expires" => 1554680038,
|
||||
"scopes" => [
|
||||
":notifications",
|
||||
":subscriptions/*",
|
||||
"GET:tokens*",
|
||||
],
|
||||
"signature" => "f__2hS20th8pALF305PJFK-D2aVtvefNnQheILHD2vU=",
|
||||
}
|
||||
expect(Invidious::Helpers::Tokens.sign_token("SECRET_KEY", token)).to eq(token["signature"])
|
||||
|
||||
token = {
|
||||
"session" => "v1:AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
|
||||
"scopes" => [":notifications", "POST:subscriptions/*"],
|
||||
"signature" => "fNvXoT0MRAL9eE6lTE33CEg8HitYJDOL9a22rSN2Ihg=",
|
||||
}
|
||||
expect(Invidious::Helpers::Tokens.sign_token("SECRET_KEY", token)).to eq(token["signature"])
|
||||
end
|
||||
end
|
||||
end
|
||||
File diff suppressed because one or more lines are too long
11
spec/invidious/search/ctoken_spec.cr
Normal file
11
spec/invidious/search/ctoken_spec.cr
Normal file
@@ -0,0 +1,11 @@
|
||||
require "../../spec_helper"
|
||||
|
||||
Spectator.describe Invidious::Search::CToken do
|
||||
describe ".produce_channel_search_continuation" do
|
||||
it "correctly produces token for searching a specific channel" do
|
||||
expect(Invidious::Search::CToken.produce_channel_search_continuation("UCXuqSBlHAE6Xw-yeJA0Tunw", "", 100)).to eq("4qmFsgJqEhhVQ1h1cVNCbEhBRTZYdy15ZUpBMFR1bncaIEVnWnpaV0Z5WTJnd0FUZ0JZQUY2QkVkS2IxaTRBUUE9WgCaAilicm93c2UtZmVlZFVDWHVxU0JsSEFFNlh3LXllSkEwVHVud3NlYXJjaA%3D%3D")
|
||||
|
||||
expect(Invidious::Search::CToken.produce_channel_search_continuation("UCXuqSBlHAE6Xw-yeJA0Tunw", "По ожиशुपतिरपि子而時ஸ்றீனி", 0)).to eq("4qmFsgKoARIYVUNYdXFTQmxIQUU2WHcteWVKQTBUdW53GiBFZ1p6WldGeVkyZ3dBVGdCWUFGNkJFZEJRVDI0QVFBPVo-0J_QviDQvtC20LjgpLbgpYHgpKrgpKTgpL_gpLDgpKrgpL_lrZDogIzmmYLgrrjgr43grrHgr4Dgrqngrr-aAilicm93c2UtZmVlZFVDWHVxU0JsSEFFNlh3LXllSkEwVHVud3NlYXJjaA%3D%3D")
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,4 +1,4 @@
|
||||
require "../parsers_helper.cr"
|
||||
require "../../parsers_helper.cr"
|
||||
|
||||
Spectator.describe Invidious::Hashtag do
|
||||
it "parses richItemRenderer containers (test 1)" do
|
||||
@@ -9,7 +9,6 @@ require "../src/invidious/videos/caption"
|
||||
require "../src/invidious/videos"
|
||||
require "../src/invidious/playlists"
|
||||
require "../src/invidious/search/ctoken"
|
||||
require "../src/invidious/trending"
|
||||
require "spectator"
|
||||
|
||||
Spectator.configure do |config|
|
||||
|
||||
Reference in New Issue
Block a user