Skip to content

Commit

Permalink
Increase utils test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
styd committed Oct 20, 2024
1 parent 09c763c commit 3031dc6
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 4 deletions.
31 changes: 31 additions & 0 deletions spec/utils/copy_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# frozen_string_literal: true

RSpec.describe ApexCharts::Utils::Copy do
context '.deep_copy' do
let(:hash) {
{
a: {
b: ['1', '2', {c: '3'}]
}
}
}

before do
class DummyClass
include ApexCharts::Utils::Copy

def copy_data(hash)
deep_copy(hash)
end
end
end

it 'copies hashes and arrays deeply' do
dc = DummyClass.new
dup_hash = dc.copy_data(hash)
hash[:a][:b][2][:c] = 3

expect(dup_hash.dig(:a, :b, 2, :c)).to eq '3'
end
end
end
8 changes: 4 additions & 4 deletions spec/utils/hash_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
b: {
d: 'four'
},
e: 'five',
f: 'six'
e: 'six',
f: 'seven'
},
g: 7
}
Expand All @@ -35,8 +35,8 @@
c: '3',
d: 'four'
},
e: 'five',
f: 'six'
e: 'six',
f: 'seven'
},
f: :six,
g: 7
Expand Down

0 comments on commit 3031dc6

Please sign in to comment.