Add tests
This commit is contained in:
parent
9ec58d8a67
commit
7f66e8ad17
2 changed files with 14 additions and 1 deletions
|
@ -7,7 +7,7 @@ module IconsHelper
|
|||
# font-awesome-rails gem, but should we ever use a different icon pack in the
|
||||
# future we won't have to change hundreds of method calls.
|
||||
def icon(names, options = {})
|
||||
if !options['aria-hidden'] and !options['aria-label']
|
||||
if (options.keys & %w[aria-hidden aria-label]).empty?
|
||||
# Add `aria-hidden` if there are no aria's set
|
||||
options['aria-hidden'] = true
|
||||
end
|
||||
|
|
|
@ -1,6 +1,19 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe IconsHelper do
|
||||
describe 'icon' do
|
||||
it 'returns aria-hidden by default' do
|
||||
star = icon('star')
|
||||
expect(star['aria-hidden']).to eq 'aria-hidden'
|
||||
end
|
||||
|
||||
it 'does not return aria-hidden if aria-label is set' do
|
||||
up = icon('up', 'aria-label' => 'up')
|
||||
expect(up['aria-hidden']).to eq nil
|
||||
expect(up['aria-label']).to eq 'aria-label'
|
||||
end
|
||||
end
|
||||
|
||||
describe 'file_type_icon_class' do
|
||||
it 'returns folder class' do
|
||||
expect(file_type_icon_class('folder', 0, 'folder_name')).to eq 'folder'
|
||||
|
|
Loading…
Reference in a new issue