@@ -2,16 +2,17 @@ import { ComponentFixture, TestBed } from '@angular/core/testing';
2
2
import { RouterTestingModule } from '@angular/router/testing' ;
3
3
import { BrowserAnimationsModule } from '@angular/platform-browser/animations' ;
4
4
import { MatSidenavModule , MatListModule } from '@angular/material' ;
5
+
5
6
import { TranslateModule } from '@ngx-translate/core' ;
6
7
7
8
import { AppComponent } from './app.component' ;
8
9
import { CoreModule } from './core/core.module' ;
9
- import { LanguageService } from './core/services/language .service' ;
10
+ import { OperatorMenuService } from './core/services/operator-menu .service' ;
10
11
11
12
describe ( 'AppComponent' , ( ) => {
12
13
let component : AppComponent ;
13
14
let fixture : ComponentFixture < AppComponent > ;
14
- let languageService : LanguageService ;
15
+ let operatorMenuService : OperatorMenuService ;
15
16
16
17
beforeEach ( ( ) => {
17
18
TestBed . configureTestingModule ( {
@@ -24,19 +25,28 @@ describe('AppComponent', () => {
24
25
TranslateModule . forRoot ( )
25
26
] ,
26
27
declarations : [ AppComponent ] ,
27
- providers : [ LanguageService ]
28
+ providers : [ OperatorMenuService ]
28
29
} ) ;
29
30
31
+ operatorMenuService = TestBed . get ( OperatorMenuService ) ;
30
32
fixture = TestBed . createComponent ( AppComponent ) ;
31
33
component = fixture . componentInstance ;
32
- languageService = TestBed . get ( LanguageService ) ;
34
+ fixture . detectChanges ( ) ;
33
35
} ) ;
34
36
35
- it ( 'should init supported languages on initialization ' , ( ) => {
36
- spyOn ( languageService , 'init ' ) . and . stub ( ) ;
37
+ it ( 'should call openOperatorMenu on shouldOpenChildMenu if condition is true ' , ( ) => {
38
+ spyOn ( operatorMenuService , 'openOperatorMenu ' ) . and . stub ( ) ;
37
39
38
- fixture . detectChanges ( ) ;
40
+ component . shouldOpenChildMenu ( 'MENU.OPERATORS' ) ;
41
+
42
+ expect ( operatorMenuService . openOperatorMenu ) . toHaveBeenCalled ( ) ;
43
+ } ) ;
44
+
45
+ it ( 'should not call openOperatorMenu on shouldOpenChildMenu if condition is false' , ( ) => {
46
+ spyOn ( operatorMenuService , 'openOperatorMenu' ) . and . stub ( ) ;
47
+
48
+ component . shouldOpenChildMenu ( 'MENU.HOME' ) ;
39
49
40
- expect ( languageService . init ) . toHaveBeenCalledWith ( [ 'en' , 'ru' ] ) ;
50
+ expect ( operatorMenuService . openOperatorMenu ) . not . toHaveBeenCalled ( ) ;
41
51
} ) ;
42
52
} ) ;
0 commit comments