@@ -36,5 +36,53 @@ describe("Geocode", function(){
3636 done ( ) ;
3737 } ) ;
3838 } ) ;
39+
40+ it ( "should make a geocode with default client" , function ( done ) {
41+ geoData = {
42+ addressLine1 : "1 Street Name" ,
43+ city : "City" ,
44+ stateCode : "State" ,
45+ zip : "ZipCode"
46+ }
47+ helper . nock ( ) . post ( "/accounts/FakeAccountId/geocodeRequest" , helper . buildXml ( { requestAddress : geoData } ) ) . reply ( 200 , helper . xml . geocode , { "Content-Type" : "application/xml" } ) ;
48+ Geocode . request ( geoData , function ( err , geocode ) {
49+ if ( err ) {
50+ return done ( err ) ;
51+ }
52+ geocode . houseNumber . should . eql ( 1 ) ;
53+ geocode . streetName . should . eql ( "Street" ) ;
54+ geocode . streetSuffix . should . eql ( "Name" ) ;
55+ geocode . city . should . eql ( "City" ) ;
56+ geocode . stateCode . should . eql ( "State" ) ;
57+ geocode . zip . should . eql ( "ZipCode" ) ;
58+ geocode . plusFour . should . eql ( 1234 ) ;
59+ geocode . country . should . eql ( "US" ) ;
60+ done ( ) ;
61+ } ) ;
62+ } ) ;
63+
64+ it ( "should handle 409 collision without error" , function ( done ) {
65+ geoData = {
66+ addressLine1 : "123 Street Name" ,
67+ city : "City" ,
68+ stateCode : "State" ,
69+ zip : "ZipCode"
70+ }
71+ helper . nock ( ) . post ( "/accounts/FakeAccountId/geocodeRequest" , helper . buildXml ( { requestAddress : geoData } ) ) . reply ( 409 , helper . xml . geocode , { "Content-Type" : "application/xml" } ) ;
72+ Geocode . request ( helper . createClient ( ) , geoData , function ( err , geocode ) {
73+ if ( err ) {
74+ return done ( err ) ;
75+ }
76+ geocode . houseNumber . should . eql ( 1 ) ;
77+ geocode . streetName . should . eql ( "Street" ) ;
78+ geocode . streetSuffix . should . eql ( "Name" ) ;
79+ geocode . city . should . eql ( "City" ) ;
80+ geocode . stateCode . should . eql ( "State" ) ;
81+ geocode . zip . should . eql ( "ZipCode" ) ;
82+ geocode . plusFour . should . eql ( 1234 ) ;
83+ geocode . country . should . eql ( "US" ) ;
84+ done ( ) ;
85+ } ) ;
86+ } ) ;
3987 } ) ;
4088} ) ;
0 commit comments