diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-03-16 18:18:33 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-03-16 18:18:33 +0000 |
commit | f64a639bcfa1fc2bc89ca7db268f594306edfd7c (patch) | |
tree | a2c3c2ebcc3b45e596949db485d6ed18ffaacfa1 /spec/lib/gitlab/word_diff/chunk_collection_spec.rb | |
parent | bfbc3e0d6583ea1a91f627528bedc3d65ba4b10f (diff) | |
download | gitlab-ce-f64a639bcfa1fc2bc89ca7db268f594306edfd7c.tar.gz |
Add latest changes from gitlab-org/gitlab@13-10-stable-eev13.10.0-rc40
Diffstat (limited to 'spec/lib/gitlab/word_diff/chunk_collection_spec.rb')
-rw-r--r-- | spec/lib/gitlab/word_diff/chunk_collection_spec.rb | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/spec/lib/gitlab/word_diff/chunk_collection_spec.rb b/spec/lib/gitlab/word_diff/chunk_collection_spec.rb new file mode 100644 index 00000000000..aa837f760c1 --- /dev/null +++ b/spec/lib/gitlab/word_diff/chunk_collection_spec.rb @@ -0,0 +1,44 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Gitlab::WordDiff::ChunkCollection do + subject(:collection) { described_class.new } + + describe '#add' do + it 'adds elements to the chunk collection' do + collection.add('Hello') + collection.add(' World') + + expect(collection.content).to eq('Hello World') + end + end + + describe '#content' do + subject { collection.content } + + context 'when no elements in the collection' do + it { is_expected.to eq('') } + end + + context 'when elements exist' do + before do + collection.add('Hi') + collection.add(' GitLab!') + end + + it { is_expected.to eq('Hi GitLab!') } + end + end + + describe '#reset' do + it 'clears the collection' do + collection.add('1') + collection.add('2') + + collection.reset + + expect(collection.content).to eq('') + end + end +end |