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.4.27 test/view_models/workarea/admin/reports/insights_view_model_test.rb
workarea-admin-3.5.4 test/view_models/workarea/admin/reports/insights_view_model_test.rb
workarea-admin-3.4.26 test/view_models/workarea/admin/reports/insights_view_model_test.rb
workarea-admin-3.5.3 test/view_models/workarea/admin/reports/insights_view_model_test.rb
workarea-admin-3.4.25 test/view_models/workarea/admin/reports/insights_view_model_test.rb
workarea-admin-3.5.2 test/view_models/workarea/admin/reports/insights_view_model_test.rb
workarea-admin-3.4.24 test/view_models/workarea/admin/reports/insights_view_model_test.rb
workarea-admin-3.5.1 test/view_models/workarea/admin/reports/insights_view_model_test.rb
workarea-admin-3.4.23 test/view_models/workarea/admin/reports/insights_view_model_test.rb
workarea-admin-3.4.22 test/view_models/workarea/admin/reports/insights_view_model_test.rb
workarea-admin-3.5.0 test/view_models/workarea/admin/reports/insights_view_model_test.rb
workarea-admin-3.4.21 test/view_models/workarea/admin/reports/insights_view_model_test.rb
workarea-admin-3.5.0.beta.1 test/view_models/workarea/admin/reports/insights_view_model_test.rb
workarea-admin-3.4.20 test/view_models/workarea/admin/reports/insights_view_model_test.rb
workarea-admin-3.4.19 test/view_models/workarea/admin/reports/insights_view_model_test.rb
workarea-admin-3.4.18 test/view_models/workarea/admin/reports/insights_view_model_test.rb
workarea-admin-3.4.17 test/view_models/workarea/admin/reports/insights_view_model_test.rb
workarea-admin-3.4.16 test/view_models/workarea/admin/reports/insights_view_model_test.rb
workarea-admin-3.4.15 test/view_models/workarea/admin/reports/insights_view_model_test.rb
workarea-admin-3.4.14 test/view_models/workarea/admin/reports/insights_view_model_test.rb