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

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/helpers/numbers_helper_spec.rb')
-rw-r--r--spec/helpers/numbers_helper_spec.rb31
1 files changed, 31 insertions, 0 deletions
diff --git a/spec/helpers/numbers_helper_spec.rb b/spec/helpers/numbers_helper_spec.rb
new file mode 100644
index 00000000000..a546f625ce8
--- /dev/null
+++ b/spec/helpers/numbers_helper_spec.rb
@@ -0,0 +1,31 @@
+# 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