Created
June 16, 2019 13:05
-
-
Save wescopeland/62dd685f817e0c9d4952bbe819d1ee07 to your computer and use it in GitHub Desktop.
notification service spec
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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