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

menus_shared_examples.rb « lib « shared_examples « support « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 2c2cb362b075482c422added398b904773886310 (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

RSpec.shared_examples_for 'pill_count formatted results' do
  let(:count_service) { raise NotImplementedError }

  subject(:pill_count) { menu.pill_count }

  it 'returns all digits for count value under 1000' do
    allow_next_instance_of(count_service) do |service|
      allow(service).to receive(:count).and_return(999)
    end

    expect(pill_count).to eq('999')
  end

  it 'returns truncated digits for count value over 1000' do
    allow_next_instance_of(count_service) do |service|
      allow(service).to receive(:count).and_return(2300)
    end

    expect(pill_count).to eq('2.3k')
  end

  it 'returns truncated digits for count value over 10000' do
    allow_next_instance_of(count_service) do |service|
      allow(service).to receive(:count).and_return(12560)
    end

    expect(pill_count).to eq('12.6k')
  end

  it 'returns truncated digits for count value over 100000' do
    allow_next_instance_of(count_service) do |service|
      allow(service).to receive(:count).and_return(112560)
    end

    expect(pill_count).to eq('112.6k')
  end
end