Project

General

Profile

Feature #43087 » test-for-43087.patch

Marius BĂLTEANU, 2026-02-03 03:04

View differences:

test/helpers/icons_helper_test.rb
132 132
  def test_icon_for_mime_type_should_return_generic_file_icon_for_unknown_mime_types
133 133
    assert_equal 'file', icon_for_mime_type('unknown-type')
134 134
  end
135

  
136
  def test_sprite_source_without_theme_should_return_default_sprite
137
    stubs(:current_theme).returns(nil)
138

  
139
    assert_equal "icons.svg", sprite_source
140
  end
141

  
142
  def test_sprite_source_with_theme_and_sprite_image_should_return_theme_path
143
    theme = mock('theme')
144
    theme.stubs(:images).returns(['icons.svg'])
145
    theme.stubs(:image_path).with('icons.svg').returns('themes/test/icons.svg')
146
    stubs(:current_theme).returns(theme)
147

  
148
    assert_equal "themes/test/icons.svg", sprite_source
149
  end
150

  
151
  def test_sprite_source_with_theme_without_sprite_image_should_return_default_sprite
152
    theme = mock('theme')
153
    theme.stubs(:images).returns([])
154
    stubs(:current_theme).returns(theme)
155

  
156
    assert_equal "icons.svg", sprite_source
157
  end
158

  
159
  def test_sprite_icon_with_theme_override_should_use_theme_sprite
160
    theme = mock('theme')
161
    theme.stubs(:images).returns(['icons.svg'])
162
    theme.stubs(:image_path).with('icons.svg').returns('themes/test/icons.svg')
163
    stubs(:current_theme).returns(theme)
164

  
165
    expected = %r{<svg class="s18 icon-svg" aria-hidden="true"><use href="/assets/themes/test/icons.svg#icon--edit"></use></svg>$}
166
    assert_match expected, sprite_icon('edit')
167
  end
135 168
end
(3-3/4)