-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds getAriaName function and applies it to advanced settings (#13448)
- Loading branch information
Showing
4 changed files
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
src/core_plugins/kibana/public/management/sections/settings/lib/__tests__/get_aria_name.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
|
||
import { getAriaName } from '../get_aria_name'; | ||
import expect from 'expect.js'; | ||
|
||
describe('Settings', function () { | ||
describe('Advanced', function () { | ||
describe('getAriaName(name)', function () { | ||
it('should be a function', function () { | ||
expect(getAriaName).to.be.a(Function); | ||
}); | ||
|
||
it('should return a space delimited lower-case string with no special characters', function () { | ||
expect(getAriaName('xPack:defaultAdminEmail')).to.be('x pack default admin email'); | ||
expect(getAriaName('search:queryLanguage:switcher:enable')).to.be('search query language switcher enable'); | ||
expect(getAriaName('doc_table:highlight')).to.be('doc table highlight'); | ||
expect(getAriaName('foo')).to.be('foo'); | ||
}); | ||
|
||
it('should return an empty string if passed undefined or null', function () { | ||
expect(getAriaName()).to.be(''); | ||
expect(getAriaName(undefined)).to.be(''); | ||
expect(getAriaName(null)).to.be(''); | ||
}); | ||
}); | ||
}); | ||
}); |
13 changes: 13 additions & 0 deletions
13
src/core_plugins/kibana/public/management/sections/settings/lib/get_aria_name.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
|
||
import { words } from 'lodash'; | ||
|
||
/** | ||
* @name {string} the name of the configuration object | ||
* @returns {string} a space demimited, lowercase string with | ||
* special characters removed. | ||
* | ||
* Example: 'xPack:fooBar:foo_bar_baz' -> 'x pack foo bar foo bar baz' | ||
*/ | ||
export function getAriaName(name) { | ||
return words(name).map(word => word.toLowerCase()).join(' '); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters