@@ -11,6 +11,10 @@ defmodule NeoFaker.AddressTest do
1111 end
1212
1313 describe "building_number/2" do
14+ test "returns a string by default" do
15+ assert is_binary ( Address . building_number ( ) )
16+ end
17+
1418 test "returns a random integer building number" do
1519 assert is_integer ( Address . building_number ( 1 .. 100 , type: :integer ) )
1620 end
@@ -22,6 +26,18 @@ defmodule NeoFaker.AddressTest do
2226 test "returns a random integer building number within the specified range" do
2327 assert Address . building_number ( 1 .. 100 , type: :integer ) in 1 .. 100
2428 end
29+
30+ test "raises ArgumentError for an unknown :type" do
31+ assert_raise ArgumentError , ~r/ invalid :type for building_number\/ 2/ , fn ->
32+ Address . building_number ( 1 .. 100 , type: :float )
33+ end
34+ end
35+
36+ test "raises ArgumentError for a non-atom :type" do
37+ assert_raise ArgumentError , ~r/ invalid :type for building_number\/ 2/ , fn ->
38+ Address . building_number ( 1 .. 100 , type: "string" )
39+ end
40+ end
2541 end
2642
2743 describe "city/1" do
@@ -53,6 +69,10 @@ defmodule NeoFaker.AddressTest do
5369 end
5470
5571 describe "coordinate/1" do
72+ test "returns a {latitude, longitude} tuple by default" do
73+ assert { _lat , _lng } = Address . coordinate ( )
74+ end
75+
5676 test "returns a random coordinate as a tuple of floats" do
5777 { latitude , longitude } = Address . coordinate ( )
5878
@@ -69,5 +89,17 @@ defmodule NeoFaker.AddressTest do
6989 test "returns only a random longitude as a float" do
7090 assert is_float ( Address . coordinate ( type: :longitude ) )
7191 end
92+
93+ test "raises ArgumentError for an unknown :type" do
94+ assert_raise ArgumentError , ~r/ invalid :type for coordinate\/ 1/ , fn ->
95+ Address . coordinate ( type: :altitude )
96+ end
97+ end
98+
99+ test "raises ArgumentError for a non-atom :type" do
100+ assert_raise ArgumentError , ~r/ invalid :type for coordinate\/ 1/ , fn ->
101+ Address . coordinate ( type: "full" )
102+ end
103+ end
72104 end
73105end
0 commit comments