Created
April 13, 2020 02:55
-
-
Save ManuelDeLeon/a27ac1af2a0f7bb6a2609c414c51a240 to your computer and use it in GitHub Desktop.
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
it("Clicking the clear button calls clear on the message service", () => { | |
const messagesService = TestBed.get(MessageService); | |
messagesService.messages = [{}]; | |
spyOn(messagesService, "clear"); | |
fixture.detectChanges(); | |
const button: HTMLButtonElement = fixture.debugElement.query( | |
By.css("button") | |
).nativeElement; | |
button.click(); | |
// No need to detect changes because we're not checking changes in the DOM | |
expect(messagesService.clear).toHaveBeenCalled(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment