1 $:.unshift(File.dirname(__FILE__) + '/../lib')
3 require File.expand_path(File.dirname(__FILE__) + "/../../../../config/environment")
11 class TestGoogleMaps< Test::Unit::TestCase
12 def test_javascriptify_method
13 assert_equal("addOverlayToHello",MappingObject::javascriptify_method("add_overlay_to_hello"))
16 def test_javascriptify_variable_mapping_object
18 assert_equal(map.to_javascript,MappingObject::javascriptify_variable(map))
21 def test_javascriptify_variable_numeric
22 assert_equal("123.4",MappingObject::javascriptify_variable(123.4))
25 def test_javascriptify_variable_array
27 assert_equal("[123.4,#{map.to_javascript},[123.4,#{map.to_javascript}]]",MappingObject::javascriptify_variable([123.4,map,[123.4,map]]))
30 def test_javascriptify_variable_hash
32 test_str = MappingObject::javascriptify_variable("hello" => map, "chopotopoto" => [123.55,map])
33 assert("{hello : #{map.to_javascript},chopotopoto : [123.55,#{map.to_javascript}]}" == test_str || "{chopotopoto : [123.55,#{map.to_javascript}],hello : #{map.to_javascript}}" == test_str)
36 def test_method_call_on_mapping_object
37 map = GMap.new("div","map")
38 assert_equal("map.addHello(123.4);",map.add_hello(123.4).to_s)
41 def test_nested_calls_on_mapping_object
42 gmap = GMap.new("div","map")
43 assert_equal("map.addHello(map.hoYoYo(123.4),map);",gmap.add_hello(gmap.ho_yo_yo(123.4),gmap).to_s)
46 def test_declare_variable_latlng
47 point = GLatLng.new([123.4,123.6])
48 assert_equal("var point = new GLatLng(123.4,123.6);",point.declare("point"))
49 assert_equal("point",point.variable)
52 def test_array_indexing
53 obj = Variable.new("obj")
54 assert_equal("obj[0]",obj[0].variable)
57 def test_google_maps_geocoding
60 placemarks = Geocoding.get("Rue Clovis Paris")
61 assert_equal(Geocoding::GEO_SUCCESS,placemarks.status)
62 assert_equal(1,placemarks.length)
63 placemark = placemarks[0]
64 assert_equal("FR",placemark.country_code)
65 assert_equal("Paris",placemark.locality)
66 assert_equal("75005",placemark.postal_code)
68 #test iwht multiple placemarks
69 placemarks = Geocoding.get('hoogstraat, nl')
70 assert_equal(Geocoding::GEO_SUCCESS,placemarks.status)
71 assert(placemarks.length > 1)
72 assert(placemarks[0].latitude != placemarks[1].latitude )