/
registration-page.container.spec.ts
63 lines (51 loc) · 2.25 KB
/
registration-page.container.spec.ts
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import { Location } from '@angular/common';
import { Component } from '@angular/core';
import { ComponentFixture, TestBed, async, fakeAsync, tick } from '@angular/core/testing';
import { RouterTestingModule } from '@angular/router/testing';
import { TranslateModule } from '@ngx-translate/core';
import { MockComponent } from 'ng-mocks';
import { AVAILABLE_LOCALES } from 'ish-core/configurations/injection-keys';
import { Locale } from 'ish-core/models/locale/locale.model';
import { coreReducers } from 'ish-core/store/core-store.module';
import { ngrxTesting } from 'ish-core/utils/dev/ngrx-testing';
import { RegistrationFormComponent } from './components/registration-form/registration-form.component';
import { RegistrationPageContainerComponent } from './registration-page.container';
describe('Registration Page Container', () => {
let fixture: ComponentFixture<RegistrationPageContainerComponent>;
let component: RegistrationPageContainerComponent;
let element: HTMLElement;
let location: Location;
const defaultLocales = [
{ lang: 'de_DE', value: 'de', displayName: 'Deutsch' },
{ lang: 'fr_FR', value: 'fr', displayName: 'Fran¢aise' },
] as Locale[];
@Component({ template: 'dummy' })
class DummyComponent {}
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [DummyComponent, MockComponent(RegistrationFormComponent), RegistrationPageContainerComponent],
providers: [{ provide: AVAILABLE_LOCALES, useValue: defaultLocales }],
imports: [
RouterTestingModule.withRoutes([{ path: 'home', component: DummyComponent }]),
TranslateModule.forRoot(),
ngrxTesting({ reducers: coreReducers }),
],
}).compileComponents();
location = TestBed.get(Location);
}));
beforeEach(() => {
fixture = TestBed.createComponent(RegistrationPageContainerComponent);
component = fixture.componentInstance;
element = fixture.nativeElement;
});
it('should be created', () => {
expect(component).toBeTruthy();
expect(element).toBeTruthy();
expect(() => fixture.detectChanges()).not.toThrow();
});
it('should navigate to homepage when cancel is clicked', fakeAsync(() => {
component.onCancel();
tick(500);
expect(location.path()).toEqual('/home');
}));
});