-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adds getAriaName function and applies it to advanced settings #13448
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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(''); | ||
}); | ||
}); | ||
}); | ||
}); |
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' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a list somewhere of all the possible advanced configs? I'm just hoping to verify this logic will hold true for all possible values There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agree, maybe we could make a text file or read it from there and utilize that complete list in the unit test. Otherwise this looks great! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think there is a master list. However, if there are specific cases you think we should test for, I can add additional tests. Seems overkill to process / maintain the entire list, when the logic really boils down to how it handles certain characters. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fair! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably okay since we're not relying on a certain delimiter and I'm guessing/hoping the lodash |
||
*/ | ||
export function getAriaName(name) { | ||
return words(name).map(word => word.toLowerCase()).join(' '); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would
Reset {{conf.ariaName}} to default
maybe be more descriptive to users?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dunno. The button is labelled 'clear' so that's what I used for reference for the aria-label.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm fine with whatever you chose :)