Sha256: 87d76d0b9fdf5b0311b762d5257d6ce167020c07caa611dc613b02dc09877396

Contents?: true

Size: 1.07 KB

Versions: 3

Compression:

Stored size: 1.07 KB

Contents

require 'test_helper'

module Workarea
  module Storefront
    class PackageProductViewModelTest < TestCase
      def test_packaged_products
        package_child_1 = create_product(variants: [{ sku: 'SKUC1', regular: 5.00 }])
        package_child_2 = create_product
        package_product = create_product(product_ids: [package_child_1.id, package_child_2.id])

        view_model = ProductViewModel.new(package_product)
        assert_equal(package_child_1.id, view_model.packaged_products[0].id)
        assert_equal(package_child_2.id, view_model.packaged_products[1].id)

        create_inventory(id: 'SKUC1', policy: 'standard', available: 0)

        view_model = ProductViewModel.new(package_product)
        assert_equal(package_child_2.id, view_model.packaged_products[0].id)
        assert_equal(1, view_model.packaged_products.count)

        bad_packaged_product = create_product(product_ids: [package_child_2.id, 'not_an_id'])
        view_model = ProductViewModel.new(bad_packaged_product)
        assert_equal(1, view_model.packaged_products.count)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
workarea-package_products-3.4.1 test/view_models/workarea/storefront/package_product_view_model_test.rb
workarea-package_products-3.4.0 test/view_models/workarea/storefront/package_product_view_model_test.rb
workarea-package_products-3.3.3 test/view_models/workarea/storefront/package_product_view_model_test.rb