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