Sha256: 1a647d28c252dec2cebb448307a9a979379a16397aedef9766e647982c3d628a

Contents?: true

Size: 1.72 KB

Versions: 2

Compression:

Stored size: 1.72 KB

Contents

require File.expand_path('../support/test_helper', __FILE__)

class MergeMissingValuesTest < Minitest::Test
  def test_merge_missing_values_for_string
    original = 'foo'
    updated = 'foo'
    JSON::Validator.merge_missing_values(updated, original)
    assert_equal('foo', original)
  end

  def test_merge_missing_values_for_empty_array
    original = []
    updated = []
    JSON::Validator.merge_missing_values(updated, original)
    assert_equal([], original)
  end

  def test_merge_missing_values_for_empty_hash
    original = {}
    updated = {}
    JSON::Validator.merge_missing_values(updated, original)
    assert_equal({}, original)
  end

  def test_merge_missing_values_for_new_values
    original = {:hello => 'world'}
    updated = {'hello' => 'world', 'foo' => 'bar'}
    JSON::Validator.merge_missing_values(updated, original)
    assert_equal({:hello => 'world', 'foo' => 'bar'}, original)
  end

  def test_merge_missing_values_for_nested_array
    original = [:hello, 'world', 1, 2, 3, {:foo => :bar, 'baz' => 'qux'}]
    updated = ['hello', 'world', 1, 2, 3, {'foo' => 'bar', 'baz' => 'qux', 'this_is' => 'new'}]
    JSON::Validator.merge_missing_values(updated, original)
    assert_equal([:hello, 'world', 1, 2, 3, {:foo => :bar, 'baz' => 'qux', 'this_is' => 'new'}], original)
  end

  def test_merge_missing_values_for_nested_hash
    original = {:hello => 'world', :foo => ['bar', :baz, {:uno => {:due => 3}}]}
    updated = {'hello' => 'world', 'foo' => ['bar', 'baz', {'uno' => {'due' => 3, 'this_is' => 'new'}}], 'ack' => 'sed'}
    JSON::Validator.merge_missing_values(updated, original)
    assert_equal({:hello => 'world', :foo => ['bar', :baz, {:uno => {:due => 3, 'this_is' => 'new'}}], 'ack' => 'sed'}, original)
  end
end

Version data entries

2 entries across 1 versions & 1 rubygems

Version Path
mountapi-0.11.1 vendor/bundle/ruby/2.7.0/bundler/gems/json-schema-2253a5ee6679/test/merge_missing_values_test.rb
mountapi-0.11.1 vendor/json-schema/test/merge_missing_values_test.rb