aboutsummaryrefslogtreecommitdiff
path: root/Timeline/ClientApp/src/app/user/user-logout/user-logout.component.spec.ts
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2019-03-26 19:21:31 +0800
committercrupest <crupest@outlook.com>2019-03-26 19:21:31 +0800
commitd7bfb99d41ac74763f1a1b96a850633994e1efff (patch)
tree126e05c4ad4d0aadab72578194720321148e3fbf /Timeline/ClientApp/src/app/user/user-logout/user-logout.component.spec.ts
parentbfff5579382ba5671a531cbab5ff14b7207dd15e (diff)
downloadtimeline-d7bfb99d41ac74763f1a1b96a850633994e1efff.tar.gz
timeline-d7bfb99d41ac74763f1a1b96a850633994e1efff.tar.bz2
timeline-d7bfb99d41ac74763f1a1b96a850633994e1efff.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.ts16
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();
+ });
});