mirror of
https://github.com/bitwarden/server.git
synced 2024-11-25 12:45:18 +01:00
Fix bug in TaxInfo (#1682)
* Fixed bug in TaxInfo * Added a few more tests to TaxInfoTests * Added tests for HasTaxId
This commit is contained in:
parent
dcc11e3819
commit
4c9d9b248c
@ -51,6 +51,7 @@
|
||||
if (BillingAddressState?.Contains("bec") ?? false)
|
||||
{
|
||||
_taxIdType = "ca_qst";
|
||||
break;
|
||||
}
|
||||
_taxIdType = "ca_bn";
|
||||
break;
|
||||
|
@ -1,4 +1,5 @@
|
||||
using Bit.Core.Models.Business;
|
||||
using NSubstitute;
|
||||
using Xunit;
|
||||
|
||||
namespace Bit.Core.Test.Models.Business
|
||||
@ -14,7 +15,7 @@ namespace Bit.Core.Test.Models.Business
|
||||
[InlineData("AE", "PH", null, "ae_trn")]
|
||||
[InlineData("AU", "PH", null, "au_abn")]
|
||||
[InlineData("BR", "PH", null, "br_cnpj")]
|
||||
// [InlineData("CA", "PH", "bec", "ca_qst")] // This test will fail, I believe this is a bug
|
||||
[InlineData("CA", "PH", "bec", "ca_qst")]
|
||||
[InlineData("CA", "PH", null, "ca_bn")]
|
||||
[InlineData("CL", "PH", null, "cl_tin")]
|
||||
[InlineData("AT", "PH", null, "eu_vat")]
|
||||
@ -76,5 +77,40 @@ namespace Bit.Core.Test.Models.Business
|
||||
|
||||
Assert.Equal(expectedTaxIdType, taxInfo.TaxIdType);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetTaxIdType_CreateOnce_ReturnCacheSecondTime()
|
||||
{
|
||||
var taxInfo = new TaxInfo
|
||||
{
|
||||
BillingAddressCountry = "US",
|
||||
TaxIdNumber = "PH",
|
||||
BillingAddressState = null,
|
||||
};
|
||||
|
||||
Assert.Equal("us_ein", taxInfo.TaxIdType);
|
||||
|
||||
// Per the current spec even if the values change to something other than null it
|
||||
// will return the cached version of TaxIdType.
|
||||
taxInfo.BillingAddressCountry = "ZA";
|
||||
|
||||
Assert.Equal("us_ein", taxInfo.TaxIdType);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(null, null, false)]
|
||||
[InlineData("123", "US", true)]
|
||||
[InlineData("123", "ZQ12", false)]
|
||||
[InlineData(" ", "US", false)]
|
||||
public void HasTaxId_ReturnsExpected(string taxIdNumber, string billingAddressCountry, bool expected)
|
||||
{
|
||||
var taxInfo = new TaxInfo
|
||||
{
|
||||
TaxIdNumber = taxIdNumber,
|
||||
BillingAddressCountry = billingAddressCountry,
|
||||
};
|
||||
|
||||
Assert.Equal(expected, taxInfo.HasTaxId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
0
test/coverage.sh
Normal file → Executable file
0
test/coverage.sh
Normal file → Executable file
Loading…
Reference in New Issue
Block a user