Skip to content

Commit

Permalink
Improve GraphQL specs
Browse files Browse the repository at this point in the history
  • Loading branch information
y9v committed Sep 11, 2024
1 parent 6b372be commit c7fcae4
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 14 deletions.
31 changes: 19 additions & 12 deletions spec/datadog/appsec/contrib/graphql/gateway/multiplex_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@
stub_const('TestSchema', Class.new(::GraphQL::Schema))
end

let(:multiplex) do
::GraphQL::Execution::Multiplex.new(
schema: schema,
queries: queries,
context: { dataloader: GraphQL::Dataloader.new(nonblocking: nil) },
max_complexity: nil
)
end

describe '#arguments' do
let(:multiplex) do
::GraphQL::Execution::Multiplex.new(
schema: schema,
queries: queries,
context: { dataloader: GraphQL::Dataloader.new(nonblocking: nil) },
max_complexity: nil
)
end

context 'query with argument values provided inline in the query' do
let(:queries) do
[
Expand Down Expand Up @@ -360,6 +360,15 @@
end

describe '#queries' do
let(:multiplex) do
::GraphQL::Execution::Multiplex.new(
schema: schema,
queries: [query],
context: { dataloader: GraphQL::Dataloader.new(nonblocking: nil) },
max_complexity: nil
)
end

let(:query) do
::GraphQL::Query.new(
schema,
Expand All @@ -371,10 +380,8 @@
)
end

let(:queries) { [query] }

it 'returns queries' do
expect(dd_multiplex.queries).to eq(queries)
expect(dd_multiplex.queries).to eq([query])
end
end
end
4 changes: 2 additions & 2 deletions spec/datadog/appsec/contrib/graphql/integration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
RSpec.describe Datadog::AppSec::Contrib::GraphQL::Integration do
describe '.ast_node_classes_defined?' do
it 'returns true when all AST node classes are defined' do
expect(described_class.ast_node_classes_defined?).to eq(true)
expect(described_class.ast_node_classes_defined?).to be(true)
end

it 'returns false when at least one of AST node classes is not defined' do
hide_const('GraphQL::Language::Nodes::Field')
expect(described_class.ast_node_classes_defined?).to eq(false)
expect(described_class.ast_node_classes_defined?).to be(false)
end
end
end

0 comments on commit c7fcae4

Please sign in to comment.