mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
[ADF-3118] translation support for notification service (snackbars) (#3427)
* translation support for snackbar * unit tests
This commit is contained in:
committed by
Eugenio Romano
parent
6909c459a8
commit
2f51b9f2b8
@@ -23,6 +23,8 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { MatSnackBar, MatSnackBarModule } from '@angular/material';
|
||||
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
||||
import { NotificationService } from './notification.service';
|
||||
import { TranslationMock } from '../mock/translation.service.mock';
|
||||
import { TranslationService } from './translation.service';
|
||||
|
||||
@Component({
|
||||
template: '',
|
||||
@@ -47,6 +49,7 @@ class ProvidesNotificationServiceComponent {
|
||||
|
||||
describe('NotificationService', () => {
|
||||
let fixture: ComponentFixture<ProvidesNotificationServiceComponent>;
|
||||
let translationService: TranslationService;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
@@ -60,11 +63,12 @@ describe('NotificationService', () => {
|
||||
NotificationService,
|
||||
MatSnackBar,
|
||||
OVERLAY_PROVIDERS,
|
||||
LiveAnnouncer
|
||||
LiveAnnouncer,
|
||||
{ provide: TranslationService, useClass: TranslationMock }
|
||||
]
|
||||
});
|
||||
|
||||
TestBed.compileComponents();
|
||||
translationService = TestBed.get(TranslationService);
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
@@ -72,6 +76,18 @@ describe('NotificationService', () => {
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should translate messages', (done) => {
|
||||
spyOn(translationService, 'instant').and.callThrough();
|
||||
|
||||
let promise = fixture.componentInstance.sendMessage();
|
||||
promise.afterDismissed().subscribe(() => {
|
||||
expect(translationService.instant).toHaveBeenCalled();
|
||||
done();
|
||||
});
|
||||
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should open a message notification bar', (done) => {
|
||||
let promise = fixture.componentInstance.sendMessage();
|
||||
promise.afterDismissed().subscribe(() => {
|
||||
|
Reference in New Issue
Block a user