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',
messageLocalizationParams: ['Demo'],
titleLocalizationParams: [],
icon: 'fa fa-info-circle',
iconTemplate : '<img src="custom-image-path.jpg" alt=""/>'
// You can customize icon
// icon: 'fa fa-exclamation-triangle', // or
// iconTemplate : '<img src="custom-image-path.jpg" alt=""/>'
}
this.confirmation.warn(

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

@ -12,7 +12,7 @@ export namespace Confirmation {
cancelText?: LocalizationParam;
yesText?: LocalizationParam;
icon?: string;
iconTemplate?:string | TemplateRef<any>
iconTemplate?:string
}
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');
}));
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`
type | selector | icon
${'info'} | ${'.info'} | ${'.fa-info-circle'}

Loading…
Cancel
Save