datasurvey/src/main/webapp/app/admin/user-management/detail/user-management-detail.comp...

61 lines
1.7 KiB
TypeScript

import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { ActivatedRoute } from '@angular/router';
import { of } from 'rxjs';
import { Authority } from 'app/config/authority.constants';
import { User } from '../user-management.model';
import { UserManagementDetailComponent } from './user-management-detail.component';
describe('Component Tests', () => {
describe('User Management Detail Component', () => {
let comp: UserManagementDetailComponent;
let fixture: ComponentFixture<UserManagementDetailComponent>;
beforeEach(
waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [UserManagementDetailComponent],
providers: [
{
provide: ActivatedRoute,
useValue: {
data: of({ user: new User(123, 'user', 'first', 'last', 'first@last.com', true, 'en', [Authority.USER], 'admin') }),
},
},
],
})
.overrideTemplate(UserManagementDetailComponent, '')
.compileComponents();
})
);
beforeEach(() => {
fixture = TestBed.createComponent(UserManagementDetailComponent);
comp = fixture.componentInstance;
});
describe('OnInit', () => {
it('Should call load all on init', () => {
// WHEN
comp.ngOnInit();
// THEN
expect(comp.user).toEqual(
expect.objectContaining({
id: 123,
login: 'user',
firstName: 'first',
lastName: 'last',
email: 'first@last.com',
activated: true,
langKey: 'en',
authorities: [Authority.USER],
createdBy: 'admin',
})
);
});
});
});
});