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

filter_array_spec.rb « banzai « lib « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 2ba2bd1893788dbd3a7d3414c2ecf8b4f5d02f06 (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
require 'spec_helper'

describe Banzai::FilterArray do
  describe '#insert_after' do
    it 'inserts an element after a provided element' do
      filters = described_class.new(%w[a b c])

      filters.insert_after('b', '1')

      expect(filters).to eq %w[a b 1 c]
    end

    it 'inserts an element at the end when the provided element does not exist' do
      filters = described_class.new(%w[a b c])

      filters.insert_after('d', '1')

      expect(filters).to eq %w[a b c 1]
    end
  end

  describe '#insert_before' do
    it 'inserts an element before a provided element' do
      filters = described_class.new(%w[a b c])

      filters.insert_before('b', '1')

      expect(filters).to eq %w[a 1 b c]
    end

    it 'inserts an element at the beginning when the provided element does not exist' do
      filters = described_class.new(%w[a b c])

      filters.insert_before('d', '1')

      expect(filters).to eq %w[1 a b c]
    end
  end
end