Sha256: 9a398daf27d7af424e0567caa19a915d5f603b6fcde8545c7cac702e9fb57338

Contents?: true

Size: 1.34 KB

Versions: 62

Compression:

Stored size: 1.34 KB

Contents

require 'test_helper'

module Workarea
  module Storefront
    class OrderItemViewModelTest < TestCase
      def test_product
        product = create_product
        item = Order::Item.new(
          product_attributes: product.attributes,
          sku: product.skus.first
        )

        view_model = Storefront::OrderItemViewModel.new(item)
        assert_equal(product.skus.first, view_model.product.options[:sku])
      end

      def test_customizations_unit_price
        item = Order::Item.new

        assert_equal(
          0.to_m,
          Storefront::OrderItemViewModel.new(item).customizations_unit_price
        )

        item.price_adjustments.build(
          price: 'item',
          quantity: 1,
          amount: 10.to_m,
          description: 'test customizations'
        )

        assert_equal(
          10.to_m,
          Storefront::OrderItemViewModel.new(item).customizations_unit_price
        )
      end

      def test_default_category_name
        product = create_product
        create_category(name: 'Test 1', product_ids: [product.id.to_s])
        create_category(name: 'Test 2', product_ids: [product.id.to_s])
        item = Order::Item.new(sku: product.skus.first)

        view_model = Storefront::OrderItemViewModel.new(item)
        assert_equal('Test 1', view_model.default_category_name)
      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/order_item_view_model_test.rb
workarea-storefront-3.5.26 test/view_models/workarea/storefront/order_item_view_model_test.rb
workarea-storefront-3.4.45 test/view_models/workarea/storefront/order_item_view_model_test.rb
workarea-storefront-3.5.25 test/view_models/workarea/storefront/order_item_view_model_test.rb
workarea-storefront-3.5.23 test/view_models/workarea/storefront/order_item_view_model_test.rb
workarea-storefront-3.4.44 test/view_models/workarea/storefront/order_item_view_model_test.rb
workarea-storefront-3.5.22 test/view_models/workarea/storefront/order_item_view_model_test.rb
workarea-storefront-3.4.43 test/view_models/workarea/storefront/order_item_view_model_test.rb
workarea-storefront-3.5.21 test/view_models/workarea/storefront/order_item_view_model_test.rb
workarea-storefront-3.4.42 test/view_models/workarea/storefront/order_item_view_model_test.rb
workarea-storefront-3.5.20 test/view_models/workarea/storefront/order_item_view_model_test.rb
workarea-storefront-3.4.41 test/view_models/workarea/storefront/order_item_view_model_test.rb
workarea-storefront-3.5.19 test/view_models/workarea/storefront/order_item_view_model_test.rb
workarea-storefront-3.4.40 test/view_models/workarea/storefront/order_item_view_model_test.rb
workarea-storefront-3.5.18 test/view_models/workarea/storefront/order_item_view_model_test.rb
workarea-storefront-3.4.39 test/view_models/workarea/storefront/order_item_view_model_test.rb
workarea-storefront-3.5.17 test/view_models/workarea/storefront/order_item_view_model_test.rb
workarea-storefront-3.4.38 test/view_models/workarea/storefront/order_item_view_model_test.rb
workarea-storefront-3.5.16 test/view_models/workarea/storefront/order_item_view_model_test.rb
workarea-storefront-3.4.37 test/view_models/workarea/storefront/order_item_view_model_test.rb