3 * ============LICENSE_START=======================================================
4 * Copyright (C) 2022 Nordix Foundation.
5 * ================================================================================
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
18 * SPDX-License-Identifier: Apache-2.0
19 * ============LICENSE_END=========================================================
22 import {async, ComponentFixture, TestBed} from '@angular/core/testing';
24 import {TypeWorkspaceComponent} from './type-workspace.component';
25 import {ReactiveFormsModule} from "@angular/forms";
26 import {TranslateModule} from "../../shared/translator/translate.module";
27 import {UiElementsModule} from "../../components/ui/ui-elements.module";
28 import {DataTypeService} from "../../services/data-type.service";
29 import {TranslateService} from "../../shared/translator/translate.service";
30 import {WorkspaceMenuComponent} from "./workspace-menu/workspace-menu.component";
31 import {TypeWorkspaceGeneralComponent} from "./type-workspace-general/type-workspace-general.component";
32 import {LayoutModule} from "../../components/layout/layout.module";
33 import {CacheService} from "../../services/cache.service";
34 import {IAppMenu, SdcMenuToken} from "../../config/sdc-menu.config";
35 import {AuthenticationService} from "../../services/authentication.service";
36 import {ISdcConfig, SdcConfigToken} from "../../config/sdc-config.config";
37 import {States} from "../../../utils/constants";
38 import {IUserProperties} from "../../../models/user";
39 import {Observable} from "rxjs/Observable";
41 describe('TypeWorkspaceComponent', () => {
42 let component: TypeWorkspaceComponent;
43 let fixture: ComponentFixture<TypeWorkspaceComponent>;
44 let translateServiceMock: Partial<TranslateService> = {
45 'languageChangedObservable': Observable.of(),
46 'translate': jest.fn()
48 let dataTypeServiceMock: Partial<DataTypeService>;
49 let cacheService: Partial<CacheService> = {
50 'get': jest.fn(param => {
51 if (param === 'version') {
54 if (param === 'user') {
59 let stateMock: Partial<ng.ui.IStateService> = {
61 'name': States.TYPE_WORKSPACE
64 let stateParamsMock: Partial<ng.ui.IStateParamsService> = {};
65 let injectorMock: Partial<ng.auto.IInjectorService> = {
66 'get': jest.fn(param => {
67 if (param === '$state') {
72 let sdcMenuMock: Partial<IAppMenu> = {
73 'component_workspace_menu_option': {
75 {"text": "General", "action": "onMenuItemPressed", "state": "general"}
79 let sdcConfigMock: Partial<ISdcConfig>;
80 let user: Partial<IUserProperties> = {
83 let authenticationService: Partial<AuthenticationService> = {
84 'getLoggedinUser': jest.fn(() => {
89 beforeEach(async(() => {
90 TestBed.configureTestingModule({
91 declarations: [ TypeWorkspaceComponent, WorkspaceMenuComponent, TypeWorkspaceGeneralComponent ],
99 {provide: DataTypeService, useValue: dataTypeServiceMock},
100 {provide: TranslateService, useValue: translateServiceMock},
101 {provide: CacheService, useValue: cacheService},
102 {provide: '$state', useValue: stateMock},
103 {provide: '$stateParams', useValue: stateParamsMock},
104 {provide: '$injector', useValue: injectorMock},
105 {provide: SdcMenuToken, useValue: sdcMenuMock},
106 {provide: SdcConfigToken, useValue: sdcConfigMock},
107 {provide: AuthenticationService, useValue: authenticationService},
110 .compileComponents();
114 fixture = TestBed.createComponent(TypeWorkspaceComponent);
115 component = fixture.componentInstance;
116 fixture.detectChanges();
119 it('should create', () => {
120 expect(component).toBeTruthy();