Skip to content

Commit

Permalink
fix: tests
Browse files Browse the repository at this point in the history
  • Loading branch information
HenryT-CG committed Oct 26, 2024
1 parent 9483704 commit 1fcdc70
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

:host ::ng-deep {
&.p-overlaypanel .p-overlaypanel-content {
//padding: var(--panel-content-padding);
padding: 0;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ export class OneCXAnnouncementListActiveComponent implements ocxRemoteComponent,
})
)
}

// display simple formatted text
public convertLineBreaks(text?: string) {
return text?.replace(/(?:\r\n|\r|\n)/g, '<br/>') ?? ''
Expand Down
9 changes: 9 additions & 0 deletions src/app/shared/utils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { SelectItem } from 'primeng/api'

import {
limitText,
convertLineBreaks,
copyToClipboard,
forceFormValidation,
dropDownSortItemsByLabel,
Expand Down Expand Up @@ -106,4 +107,12 @@ describe('util functions', () => {
expect(sortedStrings[0]).toEqual('str1')
})
})

describe('sortByLocale', () => {
it('should convert line breaks to br', () => {
const text = '123\r456'

expect(convertLineBreaks(text)).toEqual('123<br/>456')
})
})
})
5 changes: 5 additions & 0 deletions src/app/shared/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,8 @@ export function dropDownGetLabelByValue(ddArray: SelectItem[], val: string): str
export function sortByLocale(a: string, b: string): number {
return a.toUpperCase().localeCompare(b.toUpperCase())
}

// display simple formatted text
export function convertLineBreaks(text?: string) {
return text?.replace(/(?:\r\n|\r|\n)/g, '<br/>') ?? ''
}

0 comments on commit 1fcdc70

Please sign in to comment.