diff --git a/spec/serializers/order_serializer_spec.rb b/spec/serializers/order_serializer_spec.rb new file mode 100644 index 0000000000..7b71788f17 --- /dev/null +++ b/spec/serializers/order_serializer_spec.rb @@ -0,0 +1,32 @@ +#require 'spec_helper' + +describe Api::OrderSerializer do + let(:serializer) { Api::OrderSerializer.new order } + let(:order) { create(:completed_order_with_totals) } + + + it "serializes an order" do + expect(serializer.to_json).to match order.id.to_s + end + + it "converts the total to currency and amount" do + puts order.inspect + puts serializer.serializable_hash.inspect + expect(serializer.serializable_hash[:total_money].keys).to include :currency_symbol + # Not sure what currency symbol is in test env + expect(serializer.serializable_hash[:total_money].keys).to include :amount + expect(serializer.serializable_hash[:total_money][:amount]).to eq "0.00" + end + + it "converts the balance to currency and amount" do + expect(serializer.serializable_hash[:balance_money].keys).to include :currency_symbol + # Not sure what currency symbol is in test env + expect(serializer.serializable_hash[:balance_money].keys).to include :amount + expect(serializer.serializable_hash[:balance_money][:amount]).to eq "0.00" + end + it "convert the state attributes to readable strings" do + expect(serializer.to_json).to match "Complete" + expect(serializer.to_json).to match "Balance due" + end + +end