本文整理汇总了TypeScript中app/shared/login/login.component.JhiLoginModalComponent类的典型用法代码示例。如果您正苦于以下问题:TypeScript component.JhiLoginModalComponent类的具体用法?TypeScript component.JhiLoginModalComponent怎么用?TypeScript component.JhiLoginModalComponent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了component.JhiLoginModalComponent类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: describe
describe('LoginComponent', () => {
let comp: JhiLoginModalComponent;
let fixture: ComponentFixture<JhiLoginModalComponent>;
let mockLoginService: any;
let mockStateStorageService: any;
let mockRouter: any;
let mockEventManager: any;
let mockActiveModal: any;
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [TrebolTestModule],
declarations: [JhiLoginModalComponent],
providers: [
{
provide: LoginService,
useClass: MockLoginService
},
{
provide: StateStorageService,
useClass: MockStateStorageService
}
]
})
.overrideTemplate(JhiLoginModalComponent, '')
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(JhiLoginModalComponent);
comp = fixture.componentInstance;
mockLoginService = fixture.debugElement.injector.get(LoginService);
mockStateStorageService = fixture.debugElement.injector.get(StateStorageService);
mockRouter = fixture.debugElement.injector.get(Router);
mockEventManager = fixture.debugElement.injector.get(JhiEventManager);
mockActiveModal = fixture.debugElement.injector.get(NgbActiveModal);
});
it('should authenticate the user upon login when previous state was set', inject(
[],
fakeAsync(() => {
// GIVEN
const credentials = {
username: 'admin',
password: 'admin',
rememberMe: true
};
comp.username = 'admin';
comp.password = 'admin';
comp.rememberMe = true;
comp.credentials = credentials;
mockLoginService.setResponse({});
mockStateStorageService.setResponse({ redirect: 'dummy' });
// WHEN/
comp.login();
tick(); // simulate async
// THEN
expect(comp.authenticationError).toEqual(false);
expect(mockActiveModal.dismissSpy).toHaveBeenCalledWith('login success');
expect(mockEventManager.broadcastSpy).toHaveBeenCalledTimes(1);
expect(mockLoginService.loginSpy).toHaveBeenCalledWith(credentials);
expect(mockStateStorageService.getUrlSpy).toHaveBeenCalledTimes(1);
expect(mockStateStorageService.storeUrlSpy).toHaveBeenCalledWith(null);
expect(mockRouter.navigateSpy).toHaveBeenCalledWith([{ redirect: 'dummy' }]);
})
));
it('should authenticate the user upon login when previous state was not set', inject(
[],
fakeAsync(() => {
// GIVEN
const credentials = {
username: 'admin',
password: 'admin',
rememberMe: true
};
comp.username = 'admin';
comp.password = 'admin';
comp.rememberMe = true;
comp.credentials = credentials;
mockLoginService.setResponse({});
mockStateStorageService.setResponse(null);
// WHEN
comp.login();
tick(); // simulate async
// THEN
expect(comp.authenticationError).toEqual(false);
expect(mockActiveModal.dismissSpy).toHaveBeenCalledWith('login success');
expect(mockEventManager.broadcastSpy).toHaveBeenCalledTimes(1);
expect(mockLoginService.loginSpy).toHaveBeenCalledWith(credentials);
expect(mockStateStorageService.getUrlSpy).toHaveBeenCalledTimes(1);
expect(mockStateStorageService.storeUrlSpy).not.toHaveBeenCalled();
expect(mockRouter.navigateSpy).not.toHaveBeenCalled();
})
));
//.........这里部分代码省略.........
开发者ID:Danils123,项目名称:Prueba-azure,代码行数:101,代码来源:login.component.spec.ts
示例2: it
it('should empty the credentials upon cancel', () => {
// GIVEN
const credentials = {
username: 'admin',
password: 'admin',
rememberMe: true
};
const expected = {
username: null,
password: null,
rememberMe: true
};
comp.credentials = credentials;
// WHEN
comp.cancel();
// THEN
expect(comp.authenticationError).toEqual(false);
expect(comp.credentials).toEqual(expected);
expect(mockActiveModal.dismissSpy).toHaveBeenCalledWith('cancel');
});
开发者ID:gjik911,项目名称:git_01,代码行数:24,代码来源:login.component.spec.ts
示例3: it
it('should empty the credentials upon cancel', () => {
// GIVEN
comp.loginForm.patchValue({
username: 'admin',
password: 'admin'
});
const expected = {
username: '',
password: '',
rememberMe: true
};
// WHEN
comp.cancel();
// THEN
expect(comp.authenticationError).toEqual(false);
expect(comp.loginForm.get('username').value).toEqual(expected.username);
expect(comp.loginForm.get('password').value).toEqual(expected.password);
expect(comp.loginForm.get('rememberMe').value).toEqual(expected.rememberMe);
expect(mockActiveModal.dismissSpy).toHaveBeenCalledWith('cancel');
});
开发者ID:jhipster,项目名称:jhipster-sample-app-gradle,代码行数:24,代码来源:login.component.spec.ts
注:本文中的app/shared/login/login.component.JhiLoginModalComponent类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论