diff options
author | crupest <crupest@outlook.com> | 2019-03-26 19:21:31 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2019-03-26 19:21:31 +0800 |
commit | e436cf9ebb4776e3c837f1b0935f3ea2bf254d79 (patch) | |
tree | 4181096cc9f4c08148faee4a115f5a6f44f05497 /Timeline/ClientApp/src/app/user/user-logout/user-logout.component.spec.ts | |
parent | 1834e12467b06d4a5f8a3610e93ed201502d872f (diff) | |
download | timeline-e436cf9ebb4776e3c837f1b0935f3ea2bf254d79.tar.gz timeline-e436cf9ebb4776e3c837f1b0935f3ea2bf254d79.tar.bz2 timeline-e436cf9ebb4776e3c837f1b0935f3ea2bf254d79.zip |
Add unit test.
Diffstat (limited to 'Timeline/ClientApp/src/app/user/user-logout/user-logout.component.spec.ts')
-rw-r--r-- | Timeline/ClientApp/src/app/user/user-logout/user-logout.component.spec.ts | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/Timeline/ClientApp/src/app/user/user-logout/user-logout.component.spec.ts b/Timeline/ClientApp/src/app/user/user-logout/user-logout.component.spec.ts index 91369e01..855ea4a1 100644 --- a/Timeline/ClientApp/src/app/user/user-logout/user-logout.component.spec.ts +++ b/Timeline/ClientApp/src/app/user/user-logout/user-logout.component.spec.ts @@ -1,25 +1,35 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { UserLogoutComponent } from './user-logout.component'; +import { InternalUserService } from '../internal-user-service/internal-user.service'; describe('UserLogoutComponent', () => { let component: UserLogoutComponent; let fixture: ComponentFixture<UserLogoutComponent>; + let mockInternalUserService: jasmine.SpyObj<InternalUserService>; + beforeEach(async(() => { + mockInternalUserService = jasmine.createSpyObj('InternalUserService', ['logout']); + TestBed.configureTestingModule({ - declarations: [ UserLogoutComponent ] + declarations: [UserLogoutComponent], + providers: [{ provide: InternalUserService, useValue: mockInternalUserService }] }) - .compileComponents(); + .compileComponents(); })); beforeEach(() => { fixture = TestBed.createComponent(UserLogoutComponent); component = fixture.componentInstance; - fixture.detectChanges(); }); it('should create', () => { expect(component).toBeTruthy(); }); + + it('should logout on init', () => { + fixture.detectChanges(); + expect(mockInternalUserService.logout).toHaveBeenCalled(); + }); }); |