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

time_type_spec.rb « types « graphql « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 3b0d257e1d7f6aba3e7f46fd60cde4f781a0e5db (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
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe GitlabSchema.types['Time'] do
  let(:iso) { "2018-06-04T15:23:50+02:00" }
  let(:time) { Time.parse(iso) }

  specify { expect(described_class.graphql_name).to eq('Time') }

  it 'coerces Time object into ISO 8601' do
    expect(described_class.coerce_isolated_result(time)).to eq(iso)
  end

  it 'coerces an ISO-time into Time object' do
    expect(described_class.coerce_isolated_input(iso)).to eq(time)
  end

  it 'rejects invalid input' do
    expect { described_class.coerce_isolated_input('not valid') }
      .to raise_error(GraphQL::CoercionError)
  end

  it 'rejects nil' do
    expect { described_class.coerce_isolated_input(nil) }
      .to raise_error(GraphQL::CoercionError)
  end
end