mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-14 06:03:45 +01:00
default to USD if there is no match
This commit is contained in:
@@ -39,6 +39,6 @@ module.exports = GeoIpLookup =
|
||||
logger.err err:err, ip:ip, "problem getting currencyCode for ip, defaulting to USD"
|
||||
return callback(null, "USD")
|
||||
countryCode = ipDetails?.country_code?.toUpperCase()
|
||||
currencyCode = currencyMappings[countryCode]
|
||||
currencyCode = currencyMappings[countryCode] || "USD"
|
||||
logger.log ip:ip, currencyCode:currencyCode, ipDetails:ipDetails, "got currencyCode for ip"
|
||||
callback(err, currencyCode)
|
||||
@@ -96,3 +96,10 @@ describe "GeoIpLookup", ->
|
||||
@GeoIpLookup.getCurrencyCode @ipAddress, (err, currencyCode)->
|
||||
currencyCode.should.equal "USD"
|
||||
done()
|
||||
|
||||
it "should default to USD if there is no match for their country", (done)->
|
||||
@stubbedResponse.country_code = "Non existant"
|
||||
@GeoIpLookup.getDetails = sinon.stub().callsArgWith(1, null, @stubbedResponse)
|
||||
@GeoIpLookup.getCurrencyCode @ipAddress, (err, currencyCode)->
|
||||
currencyCode.should.equal "USD"
|
||||
done()
|
||||
|
||||
Reference in New Issue
Block a user