Sha256: 0b89f8074ec50a84b662d4ad5bfc2e9f5cdbb22111e4f5f71f6015b68e8c57c7

Contents?: true

Size: 1.29 KB

Versions: 62

Compression:

Stored size: 1.29 KB

Contents

require 'test_helper'

module Workarea
  class ShippingCarrierViewModelTest < TestCase
    class FooViewModel < ApplicationViewModel
      include ShippingCarrierViewModel
    end

    def ups_number
      '1ZW004A1PP07646821'
    end

    def fedex_number
      '398894880779734'
    end

    def usps_number
      '9102931502928051489189'
    end

    def test_handles_blank
      view_model = FooViewModel.wrap(nil)
      assert(view_model.carrier.blank?)
      assert(view_model.tracking_link.blank?)
    end

    def test_carrier
      package = Fulfillment::Package.new(ups_number)
      assert_equal('UPS', FooViewModel.wrap(package).carrier)

      package = Fulfillment::Package.new(fedex_number)
      assert_equal('FedEx', FooViewModel.wrap(package).carrier)

      package = Fulfillment::Package.new(usps_number)
      assert_equal('USPS', FooViewModel.wrap(package).carrier)
    end

    def test_tracking_link
      package = Fulfillment::Package.new(ups_number)
      assert_includes(FooViewModel.wrap(package).tracking_link, 'ups')

      package = Fulfillment::Package.new(fedex_number)
      assert_includes(FooViewModel.wrap(package).tracking_link, 'fedex')

      package = Fulfillment::Package.new(usps_number)
      assert_includes(FooViewModel.wrap(package).tracking_link, 'usps')
    end
  end
end

Version data entries

62 entries across 62 versions & 1 rubygems

Version Path
workarea-core-3.5.27 test/view_models/workarea/shipping_carrier_view_model_test.rb
workarea-core-3.5.26 test/view_models/workarea/shipping_carrier_view_model_test.rb
workarea-core-3.4.45 test/view_models/workarea/shipping_carrier_view_model_test.rb
workarea-core-3.5.25 test/view_models/workarea/shipping_carrier_view_model_test.rb
workarea-core-3.5.23 test/view_models/workarea/shipping_carrier_view_model_test.rb
workarea-core-3.4.44 test/view_models/workarea/shipping_carrier_view_model_test.rb
workarea-core-3.5.22 test/view_models/workarea/shipping_carrier_view_model_test.rb
workarea-core-3.4.43 test/view_models/workarea/shipping_carrier_view_model_test.rb
workarea-core-3.5.21 test/view_models/workarea/shipping_carrier_view_model_test.rb
workarea-core-3.4.42 test/view_models/workarea/shipping_carrier_view_model_test.rb
workarea-core-3.5.20 test/view_models/workarea/shipping_carrier_view_model_test.rb
workarea-core-3.4.41 test/view_models/workarea/shipping_carrier_view_model_test.rb
workarea-core-3.5.19 test/view_models/workarea/shipping_carrier_view_model_test.rb
workarea-core-3.4.40 test/view_models/workarea/shipping_carrier_view_model_test.rb
workarea-core-3.5.18 test/view_models/workarea/shipping_carrier_view_model_test.rb
workarea-core-3.4.39 test/view_models/workarea/shipping_carrier_view_model_test.rb
workarea-core-3.5.17 test/view_models/workarea/shipping_carrier_view_model_test.rb
workarea-core-3.4.38 test/view_models/workarea/shipping_carrier_view_model_test.rb
workarea-core-3.5.16 test/view_models/workarea/shipping_carrier_view_model_test.rb
workarea-core-3.4.37 test/view_models/workarea/shipping_carrier_view_model_test.rb