-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added initial test support for graphql. #401
- Loading branch information
Martin Fenner
committed
Jan 26, 2020
1 parent
9c858e9
commit 8a72165
Showing
8 changed files
with
118 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
require "rails_helper" | ||
|
||
describe LupoSchema do | ||
it "printout is up-to-date" do | ||
current_defn = LupoSchema.to_definition | ||
printout_defn = File.read(Rails.root.join("app/graphql/schema.graphql")) | ||
expect(current_defn).to eq(printout_defn) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
require "rails_helper" | ||
|
||
describe DoiItem do | ||
describe "fields" do | ||
subject { described_class } | ||
|
||
it { is_expected.to have_field(:id).of_type(!types.ID) } | ||
it { is_expected.to have_field(:type).of_type("String!") } | ||
it { is_expected.to have_field(:creators).of_type("[Person!]") } | ||
it { is_expected.to have_field(:titles).of_type("[Title!]") } | ||
it { is_expected.to have_field(:publicationYear).of_type("Int") } | ||
it { is_expected.to have_field(:publisher).of_type("String") } | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
require "rails_helper" | ||
|
||
describe QueryType do | ||
describe "fields" do | ||
subject { described_class } | ||
|
||
it { is_expected.to have_field(:dataset).of_type("Dataset!") } | ||
it { is_expected.to have_field(:datasets).of_type("DatasetConnectionWithMeta!") } | ||
it { is_expected.to have_field(:publication).of_type("Publication!") } | ||
it { is_expected.to have_field(:publications).of_type("PublicationConnectionWithMeta!") } | ||
it { is_expected.to have_field(:service).of_type("Service!") } | ||
it { is_expected.to have_field(:services).of_type("ServiceConnectionWithMeta!") } | ||
end | ||
|
||
describe "query", elasticsearch: true do | ||
let!(:datasets) { create_list(:doi, 3, aasm_state: "findable") } | ||
|
||
before do | ||
Doi.import | ||
sleep 1 | ||
end | ||
|
||
let(:query) do | ||
%(query { | ||
datasets { | ||
totalCount | ||
nodes { | ||
id | ||
} | ||
} | ||
}) | ||
end | ||
|
||
it "returns all datasets" do | ||
response = LupoSchema.execute(query).as_json | ||
|
||
expect(response.dig("data", "datasets", "totalCount")).to eq(3) | ||
expect(response.dig("data", "datasets", "nodes").length).to eq(3) | ||
expect(response.dig("data", "datasets", "nodes", 0, "id")).to eq(datasets.first.identifier) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters