Skip to content

Commit 3031dc6

Browse files
committed
Increase utils test coverage
1 parent 09c763c commit 3031dc6

File tree

2 files changed

+35
-4
lines changed

2 files changed

+35
-4
lines changed

spec/utils/copy_spec.rb

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# frozen_string_literal: true
2+
3+
RSpec.describe ApexCharts::Utils::Copy do
4+
context '.deep_copy' do
5+
let(:hash) {
6+
{
7+
a: {
8+
b: ['1', '2', {c: '3'}]
9+
}
10+
}
11+
}
12+
13+
before do
14+
class DummyClass
15+
include ApexCharts::Utils::Copy
16+
17+
def copy_data(hash)
18+
deep_copy(hash)
19+
end
20+
end
21+
end
22+
23+
it 'copies hashes and arrays deeply' do
24+
dc = DummyClass.new
25+
dup_hash = dc.copy_data(hash)
26+
hash[:a][:b][2][:c] = 3
27+
28+
expect(dup_hash.dig(:a, :b, 2, :c)).to eq '3'
29+
end
30+
end
31+
end

spec/utils/hash_spec.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
b: {
2222
d: 'four'
2323
},
24-
e: 'five',
25-
f: 'six'
24+
e: 'six',
25+
f: 'seven'
2626
},
2727
g: 7
2828
}
@@ -35,8 +35,8 @@
3535
c: '3',
3636
d: 'four'
3737
},
38-
e: 'five',
39-
f: 'six'
38+
e: 'six',
39+
f: 'seven'
4040
},
4141
f: :six,
4242
g: 7

0 commit comments

Comments
 (0)