summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab/diff/formatters/image_formatter_spec.rb
blob: 579776d44aa22064367499f0b72185589325246e (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
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Gitlab::Diff::Formatters::ImageFormatter do
  let(:base_attrs) do
    {
      base_sha: 123,
      start_sha: 456,
      head_sha: 789,
      old_path: 'old_image.png',
      new_path: 'new_image.png',
      file_identifier_hash: '777',
      position_type: 'image'
    }
  end

  let(:attrs) do
    base_attrs.merge(width: 100, height: 100, x: 1, y: 2)
  end

  it_behaves_like 'position formatter'

  describe '#==' do
    subject { described_class.new(attrs) }

    it { is_expected.to eq(subject) }

    [:width, :height, :x, :y].each do |attr|
      let(:other_formatter) do
        described_class.new(attrs.merge(attr => 9))
      end

      it { is_expected.not_to eq(other_formatter) }
    end
  end
end