Sha256: 4804bfc8dbd969dea111601bae664659bf742628e413386fcc4189d7b5d69e10

Contents?: true

Size: 781 Bytes

Versions: 1

Compression:

Stored size: 781 Bytes

Contents

require 'test_helper'

class Superstore::Types::GeoPointTypeTest < Superstore::Types::TestCase
  test 'deserialize' do
    lat, lon = 47.604, -122.329
    seattle = {lat: lat, lon: lon}

    assert_equal seattle, type.deserialize('lat' => lat, 'lon' => lon)
  end

  test 'cast_value' do
    lat, lon = 47.604, -122.329
    seattle = {lat: lat, lon: lon}

    assert_equal seattle, type.cast_value(lat: lat, lon: lon)
    assert_equal seattle, type.cast_value({ "lat" => lat, "lon" => lon })
    assert_equal seattle, type.cast_value([lat, lon])

    assert_equal({lat: 0.0, lon: 0.0}, type.cast_value(lat: "cats", lon: "dogs"))

    assert_nil type.cast_value([])
    assert_nil type.cast_value('invalid')
  end

  test 'type' do
    assert_equal 'geo_point', type.type
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
superstore-3.0.0 test/unit/types/geo_point_type_test.rb