Unverified Commit 6da70150 authored by jonhehir's avatar jonhehir Committed by GitHub

fix: null string passed as text to Flag component prevents page load (#466)

* Coerce null to empty string in Flag

Fixes bug where a null value passed as text to a Flag component breaks entire pages.

* added unit test
parent 346731b2
......@@ -16,6 +16,7 @@ export interface FlagProps {
}
export function convertText(str: string, caseType: string): string {
str = str || '';
switch (caseType) {
case CaseType.LOWER_CASE:
return str.toLowerCase();
......
......@@ -51,5 +51,9 @@ describe('Flag', () => {
it('returns text in defauilt case', () => {
expect(convertText(text, 'not a valid options')).toEqual(text);
});
it('returns empty strings for null values', () => {
expect(convertText(null, CaseType.SENTENCE_CASE)).toEqual('');
});
});
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment