aboutsummaryrefslogtreecommitdiff
path: root/Timeline/ClientApp/src/app/user/user-login-success/user-login-success.component.spec.ts
blob: ba015ae6a547f72432261c54d3399762ddb0c3f8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import { async, ComponentFixture, TestBed } from '@angular/core/testing';

import { UserLoginSuccessComponent } from './user-login-success.component';
import { By } from '@angular/platform-browser';

describe('UserLoginSuccessComponent', () => {
  let component: UserLoginSuccessComponent;
  let fixture: ComponentFixture<UserLoginSuccessComponent>;

  const mockUserInfo = {
    username: 'crupest',
    roles: ['superman', 'coder']
  };

  beforeEach(async(() => {
    TestBed.configureTestingModule({
      declarations: [UserLoginSuccessComponent]
    })
      .compileComponents();
  }));

  beforeEach(() => {
    fixture = TestBed.createComponent(UserLoginSuccessComponent);
    component = fixture.componentInstance;
    component.userInfo = mockUserInfo;
    fixture.detectChanges();
  });

  it('should create', () => {
    expect(component).toBeTruthy();
  });

  it('should work well', () => {
    expect((fixture.debugElement.query(By.css('span.username')).nativeElement as HTMLSpanElement).textContent)
      .toBe(mockUserInfo.username);
    expect((fixture.debugElement.query(By.css('span.roles')).nativeElement as HTMLSpanElement).textContent)
      .toBe(mockUserInfo.roles.join(', '));
  });
});