Merge branch 'develop' into fix/cw-4085
This commit is contained in:
@@ -8,6 +8,7 @@ import {
|
||||
timeStampAppendedURL,
|
||||
getHostNameFromURL,
|
||||
extractFilenameFromUrl,
|
||||
sanitizeAllowedDomains,
|
||||
} from '../URLHelper';
|
||||
|
||||
describe('#URL Helpers', () => {
|
||||
@@ -318,4 +319,32 @@ describe('#URL Helpers', () => {
|
||||
).toBe('file.doc');
|
||||
});
|
||||
});
|
||||
|
||||
describe('sanitizeAllowedDomains', () => {
|
||||
it('returns empty string for falsy input', () => {
|
||||
expect(sanitizeAllowedDomains('')).toBe('');
|
||||
expect(sanitizeAllowedDomains(null)).toBe('');
|
||||
expect(sanitizeAllowedDomains(undefined)).toBe('');
|
||||
});
|
||||
|
||||
it('trims whitespace and converts newlines to commas', () => {
|
||||
const input = ' example.com \n foo.bar\nbar.baz ';
|
||||
expect(sanitizeAllowedDomains(input)).toBe('example.com,foo.bar,bar.baz');
|
||||
});
|
||||
|
||||
it('handles Windows newlines and mixed spacing', () => {
|
||||
const input = ' example.com\r\n\tfoo.bar , bar.baz ';
|
||||
expect(sanitizeAllowedDomains(input)).toBe('example.com,foo.bar,bar.baz');
|
||||
});
|
||||
|
||||
it('removes empty values from repeated commas', () => {
|
||||
const input = ',,example.com,,foo.bar,,';
|
||||
expect(sanitizeAllowedDomains(input)).toBe('example.com,foo.bar');
|
||||
});
|
||||
|
||||
it('lowercases entries and de-duplicates preserving order', () => {
|
||||
const input = 'Example.com,FOO.bar,example.com,Bar.Baz,foo.BAR';
|
||||
expect(sanitizeAllowedDomains(input)).toBe('example.com,foo.bar,bar.baz');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -4,6 +4,7 @@ import {
|
||||
convertToCategorySlug,
|
||||
convertToPortalSlug,
|
||||
sanitizeVariableSearchKey,
|
||||
formatToTitleCase,
|
||||
} from '../commons';
|
||||
|
||||
describe('#createPendingMessage', () => {
|
||||
@@ -115,3 +116,51 @@ describe('sanitizeVariableSearchKey', () => {
|
||||
expect(sanitizeVariableSearchKey()).toBe('');
|
||||
});
|
||||
});
|
||||
|
||||
describe('formatToTitleCase', () => {
|
||||
it('converts underscore-separated string to title case', () => {
|
||||
expect(formatToTitleCase('round_robin')).toBe('Round Robin');
|
||||
});
|
||||
|
||||
it('converts single word to title case', () => {
|
||||
expect(formatToTitleCase('priority')).toBe('Priority');
|
||||
});
|
||||
|
||||
it('converts multiple underscores to title case', () => {
|
||||
expect(formatToTitleCase('auto_assignment_policy')).toBe(
|
||||
'Auto Assignment Policy'
|
||||
);
|
||||
});
|
||||
|
||||
it('handles already capitalized words', () => {
|
||||
expect(formatToTitleCase('HIGH_PRIORITY')).toBe('HIGH PRIORITY');
|
||||
});
|
||||
|
||||
it('handles mixed case with underscores', () => {
|
||||
expect(formatToTitleCase('first_Name_last')).toBe('First Name Last');
|
||||
});
|
||||
|
||||
it('handles empty string', () => {
|
||||
expect(formatToTitleCase('')).toBe('');
|
||||
});
|
||||
|
||||
it('handles null input', () => {
|
||||
expect(formatToTitleCase(null)).toBe('');
|
||||
});
|
||||
|
||||
it('handles undefined input', () => {
|
||||
expect(formatToTitleCase(undefined)).toBe('');
|
||||
});
|
||||
|
||||
it('handles string without underscores', () => {
|
||||
expect(formatToTitleCase('hello')).toBe('Hello');
|
||||
});
|
||||
|
||||
it('handles string with numbers', () => {
|
||||
expect(formatToTitleCase('priority_1_high')).toBe('Priority 1 High');
|
||||
});
|
||||
|
||||
it('handles leading and trailing underscores', () => {
|
||||
expect(formatToTitleCase('_leading_trailing_')).toBe('Leading Trailing');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -218,6 +218,7 @@ describe('templateHelper', () => {
|
||||
expect(result.header).toEqual({
|
||||
media_url: '',
|
||||
media_type: 'document',
|
||||
media_name: '',
|
||||
});
|
||||
expect(result.body).toEqual({
|
||||
1: '',
|
||||
|
||||
Reference in New Issue
Block a user