Skip to content

Instantly share code, notes, and snippets.

@wescopeland
Created June 16, 2019 13:05
Show Gist options
  • Save wescopeland/62dd685f817e0c9d4952bbe819d1ee07 to your computer and use it in GitHub Desktop.
Save wescopeland/62dd685f817e0c9d4952bbe819d1ee07 to your computer and use it in GitHub Desktop.
notification service spec
import { SpectatorService, SpyObject, createService } from '@netbasal/spectator/jest';
import { MatSnackBar } from '@angular/material/snack-bar';
import { NotificationService } from './notification.service';
describe('Service: NotificationService', () => {
let snackBar: SpyObject<MatSnackBar>;
let spectator: SpectatorService<NotificationService> = createService({
service: NotificationService,
mocks: [MatSnackBar]
});
beforeEach(() => {
snackBar = spectator.get(MatSnackBar);
});
it('exists', () => {
expect(spectator.service).toBeDefined();
});
it('can pop open a snackbar notification', () => {
spectator.service.notify('mock notification');
expect(snackBar.open).toHaveBeenCalledWith('mock notification', 'CLOSE', {
duration: 7000
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment