Sha256: 7574eba0e8d473c8f77970c62ec5352a2d0e8ee7f37cb451abd18943f52af066

Contents?: true

Size: 1.11 KB

Versions: 62

Compression:

Stored size: 1.11 KB

Contents

require 'test_helper'

module Workarea
  module Storefront
    class InventoryStatusViewModelTest < TestCase
      def test_message
        inventory = create_inventory(
          id: 'SKU',
          policy: 'standard',
          available: 10,
          backordered: 10
        )

        view_model = InventoryStatusViewModel.new(inventory)
        assert_equal('In Stock', view_model.message)

        inventory.available = 2
        assert_equal('Only 2 Left', view_model.message)

        inventory.policy = 'allow_backorder'
        inventory.available = 0
        inventory.backordered_until = Date.new(2014, 12, 10)
        assert_equal('Ships on 10 Dec', view_model.message)

        inventory.backordered_until = nil
        assert_equal('Backordered', view_model.message)

        inventory.policy = 'standard'
        assert_equal('Out of Stock', view_model.message)

        inventory.policy = 'allow_backorder'
        inventory.available = 0
        inventory.backordered = 0
        inventory.backordered_until = Date.new(2017, 12, 10)
        assert_equal('Out of Stock', view_model.message)
      end
    end
  end
end

Version data entries

62 entries across 62 versions & 1 rubygems

Version Path
workarea-storefront-3.5.15 test/view_models/workarea/storefront/inventory_status_view_model_test.rb
workarea-storefront-3.4.36 test/view_models/workarea/storefront/inventory_status_view_model_test.rb
workarea-storefront-3.5.14 test/view_models/workarea/storefront/inventory_status_view_model_test.rb
workarea-storefront-3.4.35 test/view_models/workarea/storefront/inventory_status_view_model_test.rb
workarea-storefront-3.5.13 test/view_models/workarea/storefront/inventory_status_view_model_test.rb
workarea-storefront-3.4.34 test/view_models/workarea/storefront/inventory_status_view_model_test.rb
workarea-storefront-3.5.12 test/view_models/workarea/storefront/inventory_status_view_model_test.rb
workarea-storefront-3.4.33 test/view_models/workarea/storefront/inventory_status_view_model_test.rb
workarea-storefront-3.5.11 test/view_models/workarea/storefront/inventory_status_view_model_test.rb
workarea-storefront-3.5.10 test/view_models/workarea/storefront/inventory_status_view_model_test.rb
workarea-storefront-3.4.32 test/view_models/workarea/storefront/inventory_status_view_model_test.rb
workarea-storefront-3.5.9 test/view_models/workarea/storefront/inventory_status_view_model_test.rb
workarea-storefront-3.4.31 test/view_models/workarea/storefront/inventory_status_view_model_test.rb
workarea-storefront-3.5.8 test/view_models/workarea/storefront/inventory_status_view_model_test.rb
workarea-storefront-3.4.30 test/view_models/workarea/storefront/inventory_status_view_model_test.rb
workarea-storefront-3.5.7 test/view_models/workarea/storefront/inventory_status_view_model_test.rb
workarea-storefront-3.4.29 test/view_models/workarea/storefront/inventory_status_view_model_test.rb
workarea-storefront-3.5.6 test/view_models/workarea/storefront/inventory_status_view_model_test.rb
workarea-storefront-3.4.28 test/view_models/workarea/storefront/inventory_status_view_model_test.rb
workarea-storefront-3.5.5 test/view_models/workarea/storefront/inventory_status_view_model_test.rb