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.15 test/view_models/workarea/admin/reports/insights_view_model_test.rb
workarea-admin-3.4.36 test/view_models/workarea/admin/reports/insights_view_model_test.rb
workarea-admin-3.5.14 test/view_models/workarea/admin/reports/insights_view_model_test.rb
workarea-admin-3.4.35 test/view_models/workarea/admin/reports/insights_view_model_test.rb
workarea-admin-3.5.13 test/view_models/workarea/admin/reports/insights_view_model_test.rb
workarea-admin-3.4.34 test/view_models/workarea/admin/reports/insights_view_model_test.rb
workarea-admin-3.5.12 test/view_models/workarea/admin/reports/insights_view_model_test.rb
workarea-admin-3.4.33 test/view_models/workarea/admin/reports/insights_view_model_test.rb
workarea-admin-3.5.11 test/view_models/workarea/admin/reports/insights_view_model_test.rb
workarea-admin-3.5.10 test/view_models/workarea/admin/reports/insights_view_model_test.rb
workarea-admin-3.4.32 test/view_models/workarea/admin/reports/insights_view_model_test.rb
workarea-admin-3.5.9 test/view_models/workarea/admin/reports/insights_view_model_test.rb
workarea-admin-3.4.31 test/view_models/workarea/admin/reports/insights_view_model_test.rb
workarea-admin-3.5.8 test/view_models/workarea/admin/reports/insights_view_model_test.rb
workarea-admin-3.4.30 test/view_models/workarea/admin/reports/insights_view_model_test.rb
workarea-admin-3.5.7 test/view_models/workarea/admin/reports/insights_view_model_test.rb
workarea-admin-3.4.29 test/view_models/workarea/admin/reports/insights_view_model_test.rb
workarea-admin-3.5.6 test/view_models/workarea/admin/reports/insights_view_model_test.rb
workarea-admin-3.4.28 test/view_models/workarea/admin/reports/insights_view_model_test.rb
workarea-admin-3.5.5 test/view_models/workarea/admin/reports/insights_view_model_test.rb