mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-10-08 14:51:32 +00:00
[ADF-3286] Snackbar now supports custom configuration (#3549)
* [ADF-3286] Snackbar now supports custom configuration * [ADF-3286] Trailing whitespace removed * [ADF-3286] Tests added * [ADF-3286] Improved tests * [ADF-3286] Documentation added * [ADF-3286] Logic improved * [ADF-3286] Styling error fixed * [ADF-3286] Broken tests fixed * [ADF-3286] Broken tests fixed
This commit is contained in:
committed by
Eugenio Romano
parent
495f9937fe
commit
a6a77b8561
@@ -20,7 +20,7 @@ import { OVERLAY_PROVIDERS, OverlayModule } from '@angular/cdk/overlay';
|
||||
import { Component } from '@angular/core';
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { MatSnackBar, MatSnackBarModule } from '@angular/material';
|
||||
import { MatSnackBar, MatSnackBarModule, MatSnackBarConfig } from '@angular/material';
|
||||
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
||||
import { NotificationService } from './notification.service';
|
||||
import { TranslationMock } from '../mock/translation.service.mock';
|
||||
@@ -35,13 +35,33 @@ class ProvidesNotificationServiceComponent {
|
||||
|
||||
}
|
||||
|
||||
sendMessageWithoutConfig() {
|
||||
let promise = this.notificationService.openSnackMessage('Test notification');
|
||||
return promise;
|
||||
}
|
||||
|
||||
sendMessage() {
|
||||
let promise = this.notificationService.openSnackMessage('Test notification', 5000);
|
||||
let promise = this.notificationService.openSnackMessage('Test notification', 1000);
|
||||
return promise;
|
||||
}
|
||||
|
||||
sendCustomMessage() {
|
||||
let promise = this.notificationService.openSnackMessage('Test notification', new MatSnackBarConfig());
|
||||
return promise;
|
||||
}
|
||||
|
||||
sendMessageActionWithoutConfig() {
|
||||
let promise = this.notificationService.openSnackMessageAction('Test notification', 'TestWarn');
|
||||
return promise;
|
||||
}
|
||||
|
||||
sendMessageAction() {
|
||||
let promise = this.notificationService.openSnackMessageAction('Test notification', 'TestWarn', 5000);
|
||||
let promise = this.notificationService.openSnackMessageAction('Test notification', 'TestWarn', 1000);
|
||||
return promise;
|
||||
}
|
||||
|
||||
sendCustomMessageAction() {
|
||||
let promise = this.notificationService.openSnackMessageAction('Test notification', 'TestWarn', new MatSnackBarConfig());
|
||||
return promise;
|
||||
}
|
||||
|
||||
@@ -99,6 +119,28 @@ describe('NotificationService', () => {
|
||||
expect(document.querySelector('snack-bar-container')).not.toBeNull();
|
||||
});
|
||||
|
||||
it('should open a message notification bar without custom configuration', (done) => {
|
||||
let promise = fixture.componentInstance.sendMessageWithoutConfig();
|
||||
promise.afterDismissed().subscribe(() => {
|
||||
done();
|
||||
});
|
||||
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(document.querySelector('snack-bar-container')).not.toBeNull();
|
||||
});
|
||||
|
||||
it('should open a message notification bar with custom configuration', async((done) => {
|
||||
let promise = fixture.componentInstance.sendCustomMessage();
|
||||
promise.afterDismissed().subscribe(() => {
|
||||
done();
|
||||
});
|
||||
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(document.querySelector('snack-bar-container')).not.toBeNull();
|
||||
}));
|
||||
|
||||
it('should open a message notification bar with action', (done) => {
|
||||
let promise = fixture.componentInstance.sendMessageAction();
|
||||
promise.afterDismissed().subscribe(() => {
|
||||
@@ -110,4 +152,26 @@ describe('NotificationService', () => {
|
||||
expect(document.querySelector('snack-bar-container')).not.toBeNull();
|
||||
});
|
||||
|
||||
it('should open a message notification bar with action and custom configuration', async((done) => {
|
||||
let promise = fixture.componentInstance.sendCustomMessageAction();
|
||||
promise.afterDismissed().subscribe(() => {
|
||||
done();
|
||||
});
|
||||
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(document.querySelector('snack-bar-container')).not.toBeNull();
|
||||
}));
|
||||
|
||||
it('should open a message notification bar with action and no custom configuration', (done) => {
|
||||
let promise = fixture.componentInstance.sendMessageActionWithoutConfig();
|
||||
promise.afterDismissed().subscribe(() => {
|
||||
done();
|
||||
});
|
||||
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(document.querySelector('snack-bar-container')).not.toBeNull();
|
||||
});
|
||||
|
||||
});
|
||||
|
Reference in New Issue
Block a user