diff options
| author | Samantaz Fox <coding@samantaz.fr> | 2022-06-14 00:04:19 +0200 |
|---|---|---|
| committer | Samantaz Fox <coding@samantaz.fr> | 2022-07-04 22:21:27 +0200 |
| commit | 0e3820b634cd94a647af099805d3957cd5c8998c (patch) | |
| tree | f0361bafac7fea1ccf8d1ee4942380a26e8578e1 /spec | |
| parent | 6c73614a47a5a88df45aa32fadb64e85595d2a18 (diff) | |
| download | invidious-0e3820b634cd94a647af099805d3957cd5c8998c.tar.gz invidious-0e3820b634cd94a647af099805d3957cd5c8998c.tar.bz2 invidious-0e3820b634cd94a647af099805d3957cd5c8998c.zip | |
Add #to_http_params method to Query (Fixes #3148)
Diffstat (limited to 'spec')
| -rw-r--r-- | spec/invidious/search/query_spec.cr | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/spec/invidious/search/query_spec.cr b/spec/invidious/search/query_spec.cr index 4853e9e9..063b69f1 100644 --- a/spec/invidious/search/query_spec.cr +++ b/spec/invidious/search/query_spec.cr @@ -197,4 +197,46 @@ Spectator.describe Invidious::Search::Query do ) end end + + describe "#to_http_params" do + it "formats regular search" do + query = described_class.new( + HTTP::Params.parse("q=The+Simpsons+hiding+in+bush&duration=short"), + Invidious::Search::Query::Type::Regular, nil + ) + + params = query.to_http_params + + expect(params).to have_key("duration") + expect(params["duration"]?).to eq("short") + + expect(params).to have_key("q") + expect(params["q"]?).to eq("The Simpsons hiding in bush") + + # Check if there aren't other parameters + params.delete("duration") + params.delete("q") + expect(params).to be_empty + end + + it "formats channel search" do + query = described_class.new( + HTTP::Params.parse("q=channel:UC2DjFE7Xf11URZqWBigcVOQ%20multimeter"), + Invidious::Search::Query::Type::Regular, nil + ) + + params = query.to_http_params + + expect(params).to have_key("channel") + expect(params["channel"]?).to eq("UC2DjFE7Xf11URZqWBigcVOQ") + + expect(params).to have_key("q") + expect(params["q"]?).to eq("multimeter") + + # Check if there aren't other parameters + params.delete("channel") + params.delete("q") + expect(params).to be_empty + end + end end |
