diff --git a/ng2-components/ng2-activiti-form/src/components/widgets/display-value/display-value.widget.spec.ts b/ng2-components/ng2-activiti-form/src/components/widgets/display-value/display-value.widget.spec.ts index 284a02b03b..e66e2ee12c 100644 --- a/ng2-components/ng2-activiti-form/src/components/widgets/display-value/display-value.widget.spec.ts +++ b/ng2-components/ng2-activiti-form/src/components/widgets/display-value/display-value.widget.spec.ts @@ -641,4 +641,33 @@ describe('DisplayValueWidget', () => { expect(widget.getCellValue(row, column)).toBe(''); }); + it('should prepend default amount currency', () => { + const value = '10'; + let row = { value: { key: value } }; + let column = { id: 'key', type: 'Amount' }; + + const expected = `$ ${value}`; + expect(widget.getCellValue(row, column)).toBe(expected); + }); + + it('should prepend custom amount currency', () => { + const value = '10'; + const currency = 'GBP'; + let row = { value: { key: value } }; + let column = { id: 'key', type: 'Amount', amountCurrency: currency }; + + const expected = `${currency} ${value}`; + expect(widget.getCellValue(row, column)).toBe(expected); + }); + + it('should use zero for missing amount', () => { + const value = null; + const currency = 'GBP'; + let row = { value: { key: value } }; + let column = { id: 'key', type: 'Amount', amountCurrency: currency }; + + const expected = `${currency} 0`; + expect(widget.getCellValue(row, column)).toBe(expected); + }); + }); diff --git a/ng2-components/ng2-activiti-form/src/components/widgets/display-value/display-value.widget.ts b/ng2-components/ng2-activiti-form/src/components/widgets/display-value/display-value.widget.ts index 567d995fd3..5c93995c4d 100644 --- a/ng2-components/ng2-activiti-form/src/components/widgets/display-value/display-value.widget.ts +++ b/ng2-components/ng2-activiti-form/src/components/widgets/display-value/display-value.widget.ts @@ -180,6 +180,10 @@ export class DisplayValueWidget extends WidgetComponent implements OnInit { } } + if (column.type === 'Amount') { + return (column.amountCurrency || '$') + ' ' + (result || 0); + } + return result || ''; } }