Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
beforeEach(async(() => {
return TestBed.configureTestingModule({
imports: [CommonModule, TranslateModule.forRoot(), MatCardModule],
declarations: [TestComponent, StarkAppLogoComponent, StarkSessionCardComponent],
providers: [
{ provide: STARK_LOGGING_SERVICE, useValue: new MockStarkLoggingService() },
{ provide: STARK_ROUTING_SERVICE, useValue: new MockStarkRoutingService() } // needed by AppLogo component
]
}).compileComponents();
}));public level?: number;
public menuGroup: StarkMenuGroup = {
id: "id-item",
label: "Label",
isVisible: true,
isEnabled: true,
targetState: "test"
};
}
// IMPORTANT: The official way to test components using ChangeDetectionStrategy.OnPush is to wrap it with a test host component
// see https://github.com/angular/angular/issues/12313#issuecomment-444623173
let hostComponent: TestHostComponent;
let component: StarkAppMenuItemComponent;
let hostFixture: ComponentFixture;
const mockRoutingService: MockStarkRoutingService = new MockStarkRoutingService();
/**
* async beforeEach
*/
beforeEach(async(() => {
return (
TestBed.configureTestingModule({
declarations: [StarkAppMenuItemComponent, TestHostComponent],
imports: [MatExpansionModule, MatListModule, NoopAnimationsModule, UIRouterModule],
providers: [
{ provide: STARK_LOGGING_SERVICE, useValue: new MockStarkLoggingService() },
{ provide: STARK_ROUTING_SERVICE, useValue: mockRoutingService }
],
schemas: [NO_ERRORS_SCHEMA] // tells the Angular compiler to ignore unrecognized elements and attributes (svgIcon)
})
/**beforeEach(async(() => {
return TestBed.configureTestingModule({
declarations: [StarkAppLogoComponent, StarkSessionCardComponent, StarkSessionExpiredPageComponent],
imports: [CommonModule, MatButtonModule, MatCardModule, TranslateModule.forRoot()],
providers: [
{ provide: STARK_ROUTING_SERVICE, useValue: new MockStarkRoutingService() }, // needed by AppLogo component
{ provide: STARK_LOGGING_SERVICE, useValue: mockLogger },
{ provide: STARK_APP_CONFIG, useValue: mockStarkAppConfig }
]
}).compileComponents();
}));describe("PreloadingPageComponent", () => {
let component: StarkPreloadingPageComponent;
let fixture: ComponentFixture;
const mockUser: StarkUser = { firstName: "John", lastName: "Doe", username: "jdoe", uuid: "mock-uuid", roles: [] };
const mockLogger: MockStarkLoggingService = new MockStarkLoggingService();
const mockUserService: MockStarkUserService = new MockStarkUserService();
const mockSessionService: MockStarkSessionService = new MockStarkSessionService();
const mockRoutingService: MockStarkRoutingService = new MockStarkRoutingService();
beforeEach(async(() => {
return TestBed.configureTestingModule({
declarations: [StarkAppLogoComponent, StarkSessionCardComponent, StarkPreloadingPageComponent],
imports: [CommonModule, MatButtonModule, MatCardModule, TranslateModule.forRoot()],
providers: [
{ provide: STARK_LOGGING_SERVICE, useValue: mockLogger },
{ provide: STARK_ROUTING_SERVICE, useValue: mockRoutingService },
{ provide: STARK_USER_SERVICE, useValue: mockUserService },
{ provide: STARK_SESSION_SERVICE, useValue: mockSessionService }
]
}).compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(StarkPreloadingPageComponent);