Browse Source

Custom icon tests added the confirmation service

pull/11576/head
Mahmut Gundogdu 5 years ago
parent
commit
0795ee3fb8
  1. 5
      docs/en/UI/Angular/Confirmation-Service.md
  2. 2
      npm/ng-packs/packages/theme-shared/src/lib/models/confirmation.ts
  3. 23
      npm/ng-packs/packages/theme-shared/src/lib/tests/confirmation.service.spec.ts

5
docs/en/UI/Angular/Confirmation-Service.md

@ -75,8 +75,9 @@ const options: Partial<Confirmation.Options> = {
yesText: 'Confirm', yesText: 'Confirm',
messageLocalizationParams: ['Demo'], messageLocalizationParams: ['Demo'],
titleLocalizationParams: [], titleLocalizationParams: [],
icon: 'fa fa-info-circle', // You can customize icon
iconTemplate : '<img src="custom-image-path.jpg" alt=""/>' // icon: 'fa fa-exclamation-triangle', // or
// iconTemplate : '<img src="custom-image-path.jpg" alt=""/>'
} }
this.confirmation.warn( this.confirmation.warn(

2
npm/ng-packs/packages/theme-shared/src/lib/models/confirmation.ts

@ -12,7 +12,7 @@ export namespace Confirmation {
cancelText?: LocalizationParam; cancelText?: LocalizationParam;
yesText?: LocalizationParam; yesText?: LocalizationParam;
icon?: string; icon?: string;
iconTemplate?:string | TemplateRef<any> iconTemplate?:string
} }
export interface DialogData { export interface DialogData {

23
npm/ng-packs/packages/theme-shared/src/lib/tests/confirmation.service.spec.ts

@ -60,6 +60,29 @@ describe('ConfirmationService', () => {
expect(selectConfirmationContent('.custom-yes')).toBe('YES'); expect(selectConfirmationContent('.custom-yes')).toBe('YES');
})); }));
test('should display custom FA icon', fakeAsync(() => {
service.show('MESSAGE', 'TITLE',undefined,{
icon:'fa fa-info'
});
tick();
expect(selectConfirmationElement(".icon").className).toBe('icon fa fa-info')
}));
test('should display custom icon as html element', fakeAsync(() => {
const className = 'custom-icon'
const selector = '.'+className;
service.show('MESSAGE', 'TITLE',undefined,{
iconTemplate: `<span class="${className}">I am icon</span>`
});
tick();
const element = selectConfirmationElement(selector)
expect(element).toBeTruthy()
expect(element.innerHTML).toBe("I am icon")
}));
test.each` test.each`
type | selector | icon type | selector | icon
${'info'} | ${'.info'} | ${'.fa-info-circle'} ${'info'} | ${'.info'} | ${'.fa-info-circle'}

Loading…
Cancel
Save