Commit 2df27d4b authored by Vitali Tatarintev's avatar Vitali Tatarintev

Merge branch 'pedropombeiro/345729-add-number-helper-tests' into 'master'

Add NumbersHelper tests

See merge request gitlab-org/gitlab!75750
parents d55709ab 8936f118
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe NumbersHelper do
describe '#limited_counter_with_delimiter' do
using RSpec::Parameterized::TableSyntax
subject { limited_counter_with_delimiter(resource, **options) }
where(:count, :options, :expected_result) do
# Using explicit limit
9 | { limit: 10 } | '9'
10 | { limit: 10 } | '10'
11 | { limit: 10 } | '10+'
12 | { limit: 10 } | '10+'
# Using default limit
999 | {} | '999'
1000 | {} | '1,000'
1001 | {} | '1,000+'
1002 | {} | '1,000+'
end
with_them do
let(:page) { double('page', total_count_with_limit: [count, options.fetch(:limit, 1000) + 1].min) }
let(:resource) { class_double(Ci::Runner, page: page) }
it { is_expected.to eq(expected_result) }
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment