Add data type view/workspace
[sdc.git] / catalog-ui / src / app / ng2 / pages / type-workspace / workspace-menu / workspace-menu.component.spec.ts
1 /*
2  * -
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
9  *
10  *       http://www.apache.org/licenses/LICENSE-2.0
11  *
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.
17  *
18  *  SPDX-License-Identifier: Apache-2.0
19  *  ============LICENSE_END=========================================================
20  */
21
22 import {async, ComponentFixture, TestBed} from '@angular/core/testing';
23
24 import {WorkspaceMenuComponent} from './workspace-menu.component';
25 import {CacheService} from "../../../services/cache.service";
26 import {States} from "../../../../utils/constants";
27 import {IAppMenu} from "../../../../models/app-config";
28 import {SdcMenuToken} from "../../../config/sdc-menu.config";
29
30 describe('WorkspaceMenuComponent', () => {
31   let component: WorkspaceMenuComponent;
32   let fixture: ComponentFixture<WorkspaceMenuComponent>;
33   let cacheService: Partial<CacheService> = {
34     'get': jest.fn(param => {
35       if (param === 'version') {
36         return 'version';
37       }
38       if (param === 'user') {
39         return {};
40       }
41     })
42   };
43   let sdcMenuMock: Partial<IAppMenu> = {
44     'component_workspace_menu_option': {
45       "DataType": [
46         {"text": "General", "action": "onMenuItemPressed", "state": "general"}
47       ]
48     }
49   };
50   let stateMock: Partial<ng.ui.IStateService> = {
51     'current': {
52       'name': States.TYPE_WORKSPACE
53     }
54   };
55   let injectorMock: Partial<ng.auto.IInjectorService> = {
56     'get': jest.fn(param => {
57       if (param === '$state') {
58         return stateMock;
59       }
60     })
61   };
62
63   beforeEach(async(() => {
64     TestBed.configureTestingModule({
65       declarations: [ WorkspaceMenuComponent ],
66       providers: [
67         {provide: CacheService, useValue: cacheService},
68         {provide: '$injector', useValue: injectorMock},
69         {provide: SdcMenuToken, useValue: sdcMenuMock}
70       ]
71     })
72     .compileComponents();
73   }));
74
75   beforeEach(() => {
76     fixture = TestBed.createComponent(WorkspaceMenuComponent);
77     component = fixture.componentInstance;
78     fixture.detectChanges();
79   });
80
81   it('should create', () => {
82     expect(component).toBeTruthy();
83   });
84 });