achievement_test.rb 1.46 KB
Newer Older
Francis's avatar
Francis committed
1 2 3 4 5 6 7
# frozen_string_literal: true

require 'test_helper'

module BlizzardApi
  module Wow
    class AchievementTest < Minitest::Test
Francis's avatar
Francis committed
8 9 10 11
      def setup
        @achievement = BlizzardApi::Wow.achievement
      end

Francis's avatar
Francis committed
12
      def test_achievement_index
Francis's avatar
Francis committed
13
        achievement_data = @achievement.index
Francis's avatar
Francis committed
14
        assert_equal 5418, achievement_data[:achievements].count
Francis's avatar
Francis committed
15 16
      end

Francis's avatar
Francis committed
17
      def test_achievement_get
Francis's avatar
Francis committed
18
        achievement_data = @achievement.get 6
Francis's avatar
Francis committed
19
        assert_equal 'Level 10', achievement_data[:name][:en_US]
Francis's avatar
Francis committed
20 21
      end

Francis's avatar
Francis committed
22
      def test_achievement_complete
Francis's avatar
Francis committed
23
        assert_raises BlizzardApi::ApiException do
Francis's avatar
Francis committed
24
          @achievement.complete
Francis's avatar
Francis committed
25 26
        end
      end
Francis's avatar
Francis committed
27 28

      def test_achievement_categories
Francis's avatar
Francis committed
29
        achievement_categories_data = @achievement.categories
Francis's avatar
Francis committed
30 31 32
        assert achievement_categories_data.key?(:root_categories)
        assert achievement_categories_data.key?(:categories)
        assert achievement_categories_data.key?(:guild_categories)
Francis's avatar
Francis committed
33 34 35
      end

      def test_achievement_category
Francis's avatar
Francis committed
36
        achievement_categories_data = @achievement.category 81
Francis's avatar
Francis committed
37
        assert_equal 'Feats of Strength', achievement_categories_data[:name][:en_US]
Francis's avatar
Francis committed
38
        assert achievement_categories_data.key?(:achievements)
Francis's avatar
Francis committed
39 40 41
      end

      def test_achievement_media
Francis's avatar
Francis committed
42
        achievement_media_data = @achievement.media 6
Francis's avatar
Francis committed
43 44 45
        assert_equal 'https://render-us.worldofwarcraft.com/icons/56/achievement_level_10.jpg',
                     achievement_media_data[:assets][0][:value]
      end
Francis's avatar
Francis committed
46 47 48
    end
  end
end