Sha256: 50bce1e7ecaa1fecf8ced98c15b1582c53166b71b59f1ba4ddeb0a3beeb666b3

Contents?: true

Size: 1.09 KB

Versions: 62

Compression:

Stored size: 1.09 KB

Contents

require 'test_helper'

module Workarea
  module Storefront
    class CartViewModelTest < TestCase
      setup :setup_view_model

      def setup_view_model
        @order = Order.new
        @view_model = CartViewModel.wrap(@order, action: 'show')
      end

      def test_items_has_the_newest_item_first
        @order.add_item(product_id: '123', sku: 'SKU1')
        @order.add_item(product_id: '123', sku: 'SKU2')
        assert_equal('SKU2', @view_model.items.first.sku)
      end

      def test_items_passes_options_to_order_item_view_model
        @order.add_item(product_id: '123', sku: 'SKU1')
        @order.add_item(product_id: '123', sku: 'SKU2')
        assert_equal('show', @view_model.items.first.options[:action])
      end

      def test_free_gifts_excludes_items_not_in_inventory
        create_inventory(id: 'SKU', available: 0)
        @order.items.build(sku: 'SKU', free_gift: true)
        assert(@view_model.free_gifts.empty?)
      end

      def test_shipping_options_is_empty_if_shipping_address_is_blank
        assert(@view_model.shipping_options.blank?)
      end
    end
  end
end

Version data entries

62 entries across 62 versions & 1 rubygems

Version Path
workarea-storefront-3.5.27 test/view_models/workarea/storefront/cart_view_model_test.rb
workarea-storefront-3.5.26 test/view_models/workarea/storefront/cart_view_model_test.rb
workarea-storefront-3.4.45 test/view_models/workarea/storefront/cart_view_model_test.rb
workarea-storefront-3.5.25 test/view_models/workarea/storefront/cart_view_model_test.rb
workarea-storefront-3.5.23 test/view_models/workarea/storefront/cart_view_model_test.rb
workarea-storefront-3.4.44 test/view_models/workarea/storefront/cart_view_model_test.rb
workarea-storefront-3.5.22 test/view_models/workarea/storefront/cart_view_model_test.rb
workarea-storefront-3.4.43 test/view_models/workarea/storefront/cart_view_model_test.rb
workarea-storefront-3.5.21 test/view_models/workarea/storefront/cart_view_model_test.rb
workarea-storefront-3.4.42 test/view_models/workarea/storefront/cart_view_model_test.rb
workarea-storefront-3.5.20 test/view_models/workarea/storefront/cart_view_model_test.rb
workarea-storefront-3.4.41 test/view_models/workarea/storefront/cart_view_model_test.rb
workarea-storefront-3.5.19 test/view_models/workarea/storefront/cart_view_model_test.rb
workarea-storefront-3.4.40 test/view_models/workarea/storefront/cart_view_model_test.rb
workarea-storefront-3.5.18 test/view_models/workarea/storefront/cart_view_model_test.rb
workarea-storefront-3.4.39 test/view_models/workarea/storefront/cart_view_model_test.rb
workarea-storefront-3.5.17 test/view_models/workarea/storefront/cart_view_model_test.rb
workarea-storefront-3.4.38 test/view_models/workarea/storefront/cart_view_model_test.rb
workarea-storefront-3.5.16 test/view_models/workarea/storefront/cart_view_model_test.rb
workarea-storefront-3.4.37 test/view_models/workarea/storefront/cart_view_model_test.rb