summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorJared Norman <jared@super.gd>2019-02-05 13:19:48 -0800
committerJared Norman <jared@super.gd>2019-02-05 13:19:48 -0800
commit495f343ce7c93421bbde12745a127aff59ef30d0 (patch)
tree64bc73ee9f6f403f561367676a7070990be35282 /spec
parentb31fa3208a08f39a161f76437b968aebb93f9d2d (diff)
Make labels customizable.
Diffstat (limited to 'spec')
-rw-r--r--spec/super_good/solidus_taxjar/tax_calculator_spec.rb33
-rw-r--r--spec/super_good/solidus_taxjar_spec.rb6
2 files changed, 39 insertions, 0 deletions
diff --git a/spec/super_good/solidus_taxjar/tax_calculator_spec.rb b/spec/super_good/solidus_taxjar/tax_calculator_spec.rb
index f7a7929..1899443 100644
--- a/spec/super_good/solidus_taxjar/tax_calculator_spec.rb
+++ b/spec/super_good/solidus_taxjar/tax_calculator_spec.rb
@@ -164,6 +164,7 @@ RSpec.describe ::SuperGood::SolidusTaxJar::TaxCalculator do
expect(subject.line_item_taxes.length).to eq 1
item_tax = subject.line_item_taxes.first
+
aggregate_failures do
expect(item_tax.item_id).to eq 33
expect(item_tax.label).to eq "Sales Tax"
@@ -173,6 +174,20 @@ RSpec.describe ::SuperGood::SolidusTaxJar::TaxCalculator do
end
end
+ context "with custom line item tax labels" do
+ before do
+ allow(SuperGood::SolidusTaxJar.line_item_tax_label_maker)
+ .to receive(:call)
+ .with(taxjar_line_item)
+ .and_return("Space Tax")
+ end
+
+ it "applies those labels" do
+ expect(subject.line_item_taxes.length).to eq 1
+ expect(subject.line_item_taxes.first.label).to eq "Space Tax"
+ end
+ end
+
context "but the taxable address check returns false" do
before do
allow(SuperGood::SolidusTaxJar.taxable_address_check)
@@ -216,6 +231,24 @@ RSpec.describe ::SuperGood::SolidusTaxJar::TaxCalculator do
expect(shipment_taxes[2].included_in_price).to eq false
end
end
+
+ context "with custom shipping tax labels" do
+ before do
+ allow(SuperGood::SolidusTaxJar.shipping_tax_label_maker).to receive(:call)
+ .and_return("Magic Tax", "Spicy Tax", "Vegetable Tax")
+ end
+
+ it "applies those labels" do
+ shipment_taxes = subject.shipment_taxes
+ expect(shipment_taxes.length).to eq 3
+
+ aggregate_failures do
+ expect(shipment_taxes[0].label).to eq "Magic Tax"
+ expect(shipment_taxes[1].label).to eq "Spicy Tax"
+ expect(shipment_taxes[2].label).to eq "Vegetable Tax"
+ end
+ end
+ end
end
context "when test_mode is set" do
diff --git a/spec/super_good/solidus_taxjar_spec.rb b/spec/super_good/solidus_taxjar_spec.rb
index 36ab3b3..957e2e3 100644
--- a/spec/super_good/solidus_taxjar_spec.rb
+++ b/spec/super_good/solidus_taxjar_spec.rb
@@ -43,5 +43,11 @@ RSpec.describe SuperGood::SolidusTaxJar do
let(:shipping_tax) { BigDecimal("3.25") }
it { is_expected.to eq "Sales Tax" }
end
+
+ describe ".line_item_tax_label_maker" do
+ subject { described_class.line_item_tax_label_maker.(taxjar_line_item) }
+ let(:taxjar_line_item) { instance_double Taxjar::BreakdownLineItem }
+ it { is_expected.to eq "Sales Tax" }
+ end
end
end