Sha256: 8677feb131caacaddc3134b1b50732129e00f0dc15637baec133cd41b0469f8e
Contents?: true
Size: 1.6 KB
Versions: 1
Compression:
Stored size: 1.6 KB
Contents
require 'test_helper' module GraphQL module Client class ResponseTest < Minitest::Test def test_initialize_parses_json body = { data: { id: 1 } } response = Response.new(body.to_json) assert_equal({ 'data' => { 'id' => 1 } }, response.body) assert_equal({ 'id' => 1 }, response.data) end def test_initialize_sets_errors body = { data: { id: 1 }, errors: [ { message: 'error' } ] } response = Response.new(body.to_json) assert_equal [{ 'message' => 'error' }], response.errors end def test_initialize_sets_errors_default body = { data: { id: 1 } } response = Response.new(body.to_json) assert_equal [], response.errors end def test_initialize_sets_extensions body = { data: { id: 1 }, extensions: [ { foo: 'bar' } ] } response = Response.new(body.to_json) assert_equal [{ 'foo' => 'bar' }], response.extensions end def test_initialize_sets_extensions_default body = { data: { id: 1 } } response = Response.new(body.to_json) assert_equal [], response.extensions end def test_initialize_raises_error_if_response_contains_errors_without_data assert_raises ResponseError do body = { errors: [{}] } Response.new(body.to_json) end assert_raises ResponseError do body = { data: nil, errors: [{}] } Response.new(body.to_json) end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
graphql_client-0.3.3 | test/graphql_client/response_test.rb |