From 9a6702ba447b010f1bb7bbf60d9fd4e5b094d957 Mon Sep 17 00:00:00 2001 From: Samantaz Fox Date: Tue, 6 Jun 2023 23:10:35 +0200 Subject: [PATCH] Spec: Return mocks as JSON::Any, not Hash --- spec/invidious/hashtag_spec.cr | 4 ++-- spec/invidious/videos/regular_videos_extract_spec.cr | 8 ++++---- spec/invidious/videos/scheduled_live_extract_spec.cr | 4 ++-- spec/parsers_helper.cr | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/spec/invidious/hashtag_spec.cr b/spec/invidious/hashtag_spec.cr index abc81225..9578929d 100644 --- a/spec/invidious/hashtag_spec.cr +++ b/spec/invidious/hashtag_spec.cr @@ -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)) diff --git a/spec/invidious/videos/regular_videos_extract_spec.cr b/spec/invidious/videos/regular_videos_extract_spec.cr index f96703f6..f7f6ba13 100644 --- a/spec/invidious/videos/regular_videos_extract_spec.cr +++ b/spec/invidious/videos/regular_videos_extract_spec.cr @@ -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) diff --git a/spec/invidious/videos/scheduled_live_extract_spec.cr b/spec/invidious/videos/scheduled_live_extract_spec.cr index c3a9b228..344883b6 100644 --- a/spec/invidious/videos/scheduled_live_extract_spec.cr +++ b/spec/invidious/videos/scheduled_live_extract_spec.cr @@ -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) diff --git a/spec/parsers_helper.cr b/spec/parsers_helper.cr index 6589acad..7646cfde 100644 --- a/spec/parsers_helper.cr +++ b/spec/parsers_helper.cr @@ -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|