debian-mirror-gitlab/spec/graphql/types/duration_type_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

25 lines
637 B
Ruby
Raw Normal View History

2021-06-08 01:23:25 +05:30
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe GitlabSchema.types['Duration'] do
let(:duration) { 17.minutes }
it 'presents information as a floating point number' do
expect(described_class.coerce_isolated_result(duration)).to eq(duration.to_f)
end
it 'accepts integers as input' do
expect(described_class.coerce_isolated_input(100)).to eq(100.0)
end
it 'accepts floats as input' do
expect(described_class.coerce_isolated_input(0.5)).to eq(0.5)
end
it 'rejects nil' do
expect { described_class.coerce_isolated_input(nil) }
.to raise_error(GraphQL::CoercionError)
end
end