Looking to verify whether the localStorage
gets cleared when I execute my function.
Component
ngOnInit() {
// Logging out when reaching login screen for login purposes
this.authService.logout();
}
authService
logout() {
// Removing logged in user from localStorage
localStorage.removeItem('currentUser');
}
TEST
fit('ngOnInit should log out user stored in localStorage', () => {
// Example data stored as token
localStorage.setItem('token', 'someUserToken');
component.ngOnInit();
expect(localStorage.getItem('token')).toEqual('{}');
});
Is there a method to accomplish this?