Sha256: e978af66cc9f4abc8db783782357d34c61333a84244006d19f9bb3181d247a0a

Contents?: true

Size: 1.08 KB

Versions: 3

Compression:

Stored size: 1.08 KB

Contents

require 'test_helper'

module Workarea
  module Storefront
    module ProductTemplates
      class PackageViewModelTest < TestCase
        def test_packaged_products
          product_one = create_product(template: 'option_selects')
          product_two = create_product
          package = create_product(product_ids: [product_one.id, product_two.id])

          view_model = Storefront::ProductTemplates::PackageViewModel.new(package)

          assert_equal(
            Storefront::ProductTemplates::OptionSelectsViewModel,
            view_model.packaged_products.first.class
          )

          assert_equal(
            Storefront::ProductViewModel,
            view_model.packaged_products.second.class
          )

          product_one = create_product(template: 'test')
          product_two = create_product(variants: [])
          package = create_product(product_ids: [product_one.id, product_two.id])

          view_model = Storefront::ProductTemplates::PackageViewModel.new(package)
          assert_equal(1, view_model.packaged_products.length)
        end
      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_templates/package_view_model_test.rb
workarea-package_products-3.4.0 test/view_models/workarea/storefront/package_templates/package_view_model_test.rb
workarea-package_products-3.3.3 test/view_models/workarea/storefront/package_templates/package_view_model_test.rb