debian-mirror-gitlab/spec/lib/gitlab/utils/merge_hash_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

36 lines
1,004 B
Ruby
Raw Normal View History

2019-12-04 20:38:33 +05:30
# frozen_string_literal: true
2022-10-11 01:57:18 +05:30
require 'fast_spec_helper'
2020-07-28 23:09:34 +05:30
RSpec.describe Gitlab::Utils::MergeHash do
2018-03-17 18:26:18 +05:30
describe '.crush' do
it 'can flatten a hash to each element' do
input = { hello: "world", this: { crushes: ["an entire", "hash"] } }
expected_result = [:hello, "world", :this, :crushes, "an entire", "hash"]
expect(described_class.crush(input)).to eq(expected_result)
end
end
describe '.elements' do
it 'deep merges an array of elements' do
input = [{ hello: ["world"] },
{ hello: "Everyone" },
{ hello: { greetings: ['Bonjour', 'Hello', 'Hallo', 'Dzień dobry'] } },
"Goodbye", "Hallo"]
expected_output = [
{
hello:
[
"world",
"Everyone",
{ greetings: ['Bonjour', 'Hello', 'Hallo', 'Dzień dobry'] }
]
},
"Goodbye"
]
expect(described_class.merge(input)).to eq(expected_output)
end
end
end