Welcome to mirror list, hosted at ThFree Co, Russian Federation.

widget_interface_spec.rb « work_items « types « graphql « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: b9e8edacf155b0aa124f5ba34f6af5cca2cafa45 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Types::WorkItems::WidgetInterface do
  include GraphqlHelpers

  it 'exposes the expected fields' do
    expected_fields = %i[type]

    expect(described_class).to have_graphql_fields(*expected_fields)
  end

  describe ".resolve_type" do
    using RSpec::Parameterized::TableSyntax

    where(:widget_class, :widget_type_name) do
      WorkItems::Widgets::Description | Types::WorkItems::Widgets::DescriptionType
      WorkItems::Widgets::Hierarchy   | Types::WorkItems::Widgets::HierarchyType
      WorkItems::Widgets::Assignees   | Types::WorkItems::Widgets::AssigneesType
      WorkItems::Widgets::Labels      | Types::WorkItems::Widgets::LabelsType
    end

    with_them do
      it 'knows the correct type for objects' do
        expect(
          described_class.resolve_type(widget_class.new(build(:work_item)), {})
        ).to eq(widget_type_name)
      end
    end

    it 'raises an error for an unknown type' do
      project = build(:project)

      expect { described_class.resolve_type(project, {}) }
        .to raise_error("Unknown GraphQL type for widget #{project}")
    end
  end
end