Sha256: 0789778af12822a376134559800bef9e3e962f2f217e026134a04c1aeadf262d

Contents?: true

Size: 1.26 KB

Versions: 1

Compression:

Stored size: 1.26 KB

Contents

# frozen_string_literal: true

require 'rails_helper'

RSpec.describe Types::Admin::<%= class_name %>Type, type: :request do
  let(:query) do
    <<-GRAPHQL
      query all<%= class_name %>s($filter: FinalTestFilter, $page: Int, $perPage: Int, $sortField: String, $sortOrder: String) {
        all<%= class_name %>s(filter: $filter, page: $page, perPage: $perPage, sortField: $sortField, sortOrder: $sortOrder){
          id
        }
      }
    GRAPHQL
  end

  let(:admin_user) { create :admin_user }
  describe '#resolve' do
    it 'pass' do
      variables = <<~GQL
        {
          "filter": ,
          "page": ,
          "perPage": ,
          "sortField": ,
          "sortOrder":
        }
      GQL

      post '/api/admin/graphql', headers: admin_user.create_new_auth_token, params: { query: query, variables: variables }
      expect(response).to have_http_status(:success)
      json = JSON.parse(response.body)
      expect(json['data']['all<%= class_name %>s']['filter']).to eq
      expect(json['data']['all<%= class_name %>s']['page']).to eq
      expect(json['data']['all<%= class_name %>s']['perPage']).to eq
      expect(json['data']['all<%= class_name %>s']['sortField']).to eq
      expect(json['data']['all<%= class_name %>s']['sortOrder']).to eq
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
graphql_scaffold_fan-0.3.1 lib/generators/templates/query_test_for_get_many.haml