mirror of
https://github.com/iv-org/invidious.git
synced 2024-11-13 16:57:05 +05:30
Spec: Return mocks as JSON::Any, not Hash
This commit is contained in:
parent
72fa54f5bd
commit
8559796269
@ -3,7 +3,7 @@ require "../parsers_helper.cr"
|
||||
Spectator.describe Invidious::Hashtag do
|
||||
it "parses richItemRenderer containers (test 1)" do
|
||||
# Enable mock
|
||||
test_content = load_mock("hashtag/martingarrix_page1")
|
||||
test_content = load_mock("hashtag/martingarrix_page1").as_h
|
||||
videos, _ = extract_items(test_content)
|
||||
|
||||
expect(typeof(videos)).to eq(Array(SearchItem))
|
||||
@ -56,7 +56,7 @@ Spectator.describe Invidious::Hashtag do
|
||||
|
||||
it "parses richItemRenderer containers (test 2)" do
|
||||
# Enable mock
|
||||
test_content = load_mock("hashtag/martingarrix_page2")
|
||||
test_content = load_mock("hashtag/martingarrix_page2").as_h
|
||||
videos, _ = extract_items(test_content)
|
||||
|
||||
expect(typeof(videos)).to eq(Array(SearchItem))
|
||||
|
@ -3,8 +3,8 @@ require "../../parsers_helper.cr"
|
||||
Spectator.describe "parse_video_info" do
|
||||
it "parses a regular video" do
|
||||
# Enable mock
|
||||
_player = load_mock("video/regular_mrbeast.player")
|
||||
_next = load_mock("video/regular_mrbeast.next")
|
||||
_player = load_mock("video/regular_mrbeast.player").as_h
|
||||
_next = load_mock("video/regular_mrbeast.next").as_h
|
||||
|
||||
raw_data = _player.merge!(_next)
|
||||
info = parse_video_info("2isYuQZMbdU", raw_data)
|
||||
@ -85,8 +85,8 @@ Spectator.describe "parse_video_info" do
|
||||
|
||||
it "parses a regular video with no descrition/comments" do
|
||||
# Enable mock
|
||||
_player = load_mock("video/regular_no-description.player")
|
||||
_next = load_mock("video/regular_no-description.next")
|
||||
_player = load_mock("video/regular_no-description.player").as_h
|
||||
_next = load_mock("video/regular_no-description.next").as_h
|
||||
|
||||
raw_data = _player.merge!(_next)
|
||||
info = parse_video_info("iuevw6218F0", raw_data)
|
||||
|
@ -3,8 +3,8 @@ require "../../parsers_helper.cr"
|
||||
Spectator.describe "parse_video_info" do
|
||||
it "parses scheduled livestreams data" do
|
||||
# Enable mock
|
||||
_player = load_mock("video/scheduled_live_PBD-Podcast.player")
|
||||
_next = load_mock("video/scheduled_live_PBD-Podcast.next")
|
||||
_player = load_mock("video/scheduled_live_PBD-Podcast.player").as_h
|
||||
_next = load_mock("video/scheduled_live_PBD-Podcast.next").as_h
|
||||
|
||||
raw_data = _player.merge!(_next)
|
||||
info = parse_video_info("N-yVic7BbY0", raw_data)
|
||||
|
@ -22,11 +22,11 @@ require "../src/invidious/yt_backend/extractors_utils"
|
||||
OUTPUT = File.open(File::NULL, "w")
|
||||
LOGGER = Invidious::LogHandler.new(OUTPUT, LogLevel::Off)
|
||||
|
||||
def load_mock(file) : Hash(String, JSON::Any)
|
||||
def load_mock(file) : JSON::Any
|
||||
file = File.join(__DIR__, "..", "mocks", file + ".json")
|
||||
content = File.read(file)
|
||||
|
||||
return JSON.parse(content).as_h
|
||||
return JSON.parse(content)
|
||||
end
|
||||
|
||||
Spectator.configure do |config|
|
||||
|
Loading…
Reference in New Issue
Block a user