Due to overly aggressive detection by RuboCop Minitest, the distinction between `[]` and `{}` was uniformly replaced with `assert_empty`,
making it impossible to differentiate between them.
As a result of https://github.com/rubocop/rubocop-minitest/issues/344, where the `Minitest/AssertEmptyLiteral` cop was disabled,
the return value has been expressed using explicit literal forms.
48 lines
1.2 KiB
Ruby
48 lines
1.2 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
require "test_helper"
|
|
|
|
module MCP
|
|
class IconTest < ActiveSupport::TestCase
|
|
def test_initialization
|
|
icon = Icon.new(mime_type: "image/png", sizes: ["48x48", "96x96"], src: "https://example.com", theme: "light")
|
|
|
|
assert_equal("image/png", icon.mime_type)
|
|
assert_equal(["48x48", "96x96"], icon.sizes)
|
|
assert_equal("https://example.com", icon.src)
|
|
assert_equal("light", icon.theme)
|
|
|
|
assert_equal({ mimeType: "image/png", sizes: ["48x48", "96x96"], src: "https://example.com", theme: "light" }, icon.to_h)
|
|
end
|
|
|
|
def test_initialization_by_default
|
|
icon = Icon.new
|
|
|
|
assert_nil(icon.mime_type)
|
|
assert_nil(icon.sizes)
|
|
assert_nil(icon.src)
|
|
assert_nil(icon.theme)
|
|
|
|
assert_equal({}, icon.to_h)
|
|
end
|
|
|
|
def test_valid_theme_for_light
|
|
assert_nothing_raised do
|
|
Icon.new(theme: "light")
|
|
end
|
|
end
|
|
|
|
def test_valid_theme_for_dark
|
|
assert_nothing_raised do
|
|
Icon.new(theme: "dark")
|
|
end
|
|
end
|
|
|
|
def test_invalid_theme
|
|
exception = assert_raises(ArgumentError) do
|
|
Icon.new(theme: "unexpected")
|
|
end
|
|
assert_equal('The value of theme must specify "light" or "dark".', exception.message)
|
|
end
|
|
end
|
|
end
|