Sha256: fb2adad0dc6381b497cafe02976c03c9270cbcd28364aadd6400ada8ae3c679b

Contents?: true

Size: 1.07 KB

Versions: 1

Compression:

Stored size: 1.07 KB

Contents

# frozen_string_literal: true

require 'spec_helper'

RSpec.describe SolidusPaypalCommercePlatform::PaypalOrder, type: :model do
  describe '#to_json' do
    subject(:to_json) { described_class.new(order).to_json('intent') }

    let(:order) { create(:order_ready_to_complete) }

    it { expect { to_json }.not_to raise_error }

    if Spree.solidus_gem_version >= Gem::Version.new('2.11')
      it 'returns the name of the user' do
        expect(to_json).to match hash_including(
          purchase_units: array_including(
            hash_including(shipping: hash_including(name: { full_name: 'John Von Doe' }))
          ),
          payer: hash_including(name: { given_name: 'John', surname: 'Von Doe' })
        )
      end
    else
      it 'returns the name and surname of the user' do
        expect(to_json).to match hash_including(
          purchase_units: array_including(
            hash_including(shipping: hash_including(name: { full_name: 'John' }))
          ),
          payer: hash_including(name: { given_name: 'John', surname: nil })
        )
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
solidus_paypal_commerce_platform-0.3.2 spec/models/solidus_paypal_commerce_platform/paypal_order_spec.rb