summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorJared Norman <jared@super.gd>2019-01-24 17:57:06 -0800
committerJared Norman <jared@super.gd>2019-01-28 10:35:05 -0800
commitc9633203f85fc690ec0213aca4da7198dcd43f16 (patch)
treecb974be0ec61c1da8969bdb443e1cc5c35ecbd55 /spec
parent0eb33f99cd2054230c5a3ba80ab8d3633f16c04b (diff)
Introduce DiscountCalculator
This extracts the functionality of calculating the discount for a line item in the interest of making this behaviour configurable for stores that would like to factor in order level adjustments in some way.
Diffstat (limited to 'spec')
-rw-r--r--spec/super_good/solidus_taxjar/discount_calculator_spec.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/spec/super_good/solidus_taxjar/discount_calculator_spec.rb b/spec/super_good/solidus_taxjar/discount_calculator_spec.rb
new file mode 100644
index 0000000..b89b4dc
--- /dev/null
+++ b/spec/super_good/solidus_taxjar/discount_calculator_spec.rb
@@ -0,0 +1,13 @@
+require 'spec_helper'
+
+RSpec.describe SuperGood::SolidusTaxJar::DiscountCalculator do
+ describe "#discount" do
+ subject { calculator.discount }
+
+ let(:calculator) { described_class.new line_item }
+
+ let(:line_item) { ::Spree::LineItem.new(promo_total: 12.34) }
+
+ it { is_expected.to eq(-12.34) }
+ end
+end