Sha256: 224598c3fb24df774efd38b767d30fd89c0001f026415332c6f1221c5d83f178

Contents?: true

Size: 1.2 KB

Versions: 62

Compression:

Stored size: 1.2 KB

Contents

require 'test_helper'

module Workarea
  module Admin
    module Reports
      class InsightsViewModelTest < TestCase
        setup :create_insights

        def create_insights
          @hot = create_hot_products
          @cold = create_cold_products
        end

        def test_type_options
          view_model = InsightsViewModel.wrap(nil)
          assert_equal(3, view_model.type_options.size)
          assert(view_model.type_options.include?([t('workarea.admin.reports.insights.all_insights'), nil]))
          assert(view_model.type_options.include?(['Hot Products', @hot.class.name]))
          assert(view_model.type_options.include?(['Cold Products', @cold.class.name]))
        end

        def test_feed
          view_model = InsightsViewModel.wrap(nil)
          assert(view_model.feed.all? { |i| i.is_a?(InsightViewModel) })
          assert_equal([@cold, @hot], view_model.feed.map(&:model))

          view_model = InsightsViewModel.wrap(nil, type: @hot.class.name)
          assert_equal([@hot], view_model.feed.map(&:model))

          view_model = InsightsViewModel.wrap(nil, type: @cold.class.name)
          assert_equal([@cold], view_model.feed.map(&:model))
        end
      end
    end
  end
end

Version data entries

62 entries across 62 versions & 1 rubygems

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