Sha256: 1355c4fe9829432cec6613b99836f3285f63da69f291eb5c3aee8ab36c2731cd

Contents?: true

Size: 983 Bytes

Versions: 2

Compression:

Stored size: 983 Bytes

Contents

require 'spec_helper'

RSpec.describe SolidusBolt::OrderDecorator do
  let(:order) { create(:order_with_line_items) }

  describe '#bolt_cart' do
    it 'returns a hash with line items and price' do
      result = {
        total_amount: (order.total * 100).to_i,
        order_reference: order.number,
        currency: 'USD',
        items: [{
          sku: order.line_items.first.sku,
          name: order.line_items.first.name,
          unit_price: 1000,
          quantity: 1
        }]
      }
      expect(order.bolt_cart).to eq(result)
    end
  end

  describe '#bolt_user_identifier' do
    it 'returns a hash with email and phone' do
      result = { email: order.email, phone: '555-555-0199' }
      expect(order.bolt_user_identifier).to eq(result)
    end
  end

  describe '#bolt_user_identity' do
    it 'returns a hash with name' do
      result = { 'first_name': 'John', 'last_name': 'Doe' }
      expect(order.bolt_user_identity).to eq(result)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
solidus_bolt-0.1.0 spec/decorators/models/solidus_bolt/order_decorator_spec.rb
solidus_bolt-0.0.1 spec/decorators/models/solidus_bolt/order_decorator_spec.rb