@@ -3,6 +3,7 @@ import { Directive } from '@angular/core';
3
3
import { expectPropertiesValues } from '../../util-test/util-expect.spec' ;
4
4
5
5
import * as utilsFunctions from '../../utils/util' ;
6
+ import { PoLanguageService } from '../../services/po-language/po-language.service' ;
6
7
7
8
import { PoNavbarBaseComponent , poNavbarLiteralsDefault } from './po-navbar-base.component' ;
8
9
@@ -12,7 +13,8 @@ export class PoNavbarComponent extends PoNavbarBaseComponent {
12
13
}
13
14
14
15
describe ( 'PoNavbarBaseComponent:' , ( ) => {
15
- const component = new PoNavbarComponent ( ) ;
16
+ const languageService = new PoLanguageService ( ) ;
17
+ const component = new PoNavbarComponent ( languageService ) ;
16
18
17
19
it ( 'should be created' , ( ) => {
18
20
expect ( component instanceof PoNavbarBaseComponent ) . toBeTruthy ( ) ;
@@ -44,47 +46,47 @@ describe('PoNavbarBaseComponent:', () => {
44
46
} ) ;
45
47
46
48
it ( 'literals: should be in portuguese if browser is setted with an unsupported language' , ( ) => {
47
- spyOn ( utilsFunctions , < any > 'browserLanguage' ) . and . returnValue ( 'zw' ) ;
49
+ component [ 'language' ] = 'zw' ;
48
50
49
51
component . literals = { } ;
50
52
51
53
expect ( component . literals ) . toEqual ( poNavbarLiteralsDefault [ utilsFunctions . poLocaleDefault ] ) ;
52
54
} ) ;
53
55
54
56
it ( 'literals: should be in portuguese if browser is setted with `pt`' , ( ) => {
55
- spyOn ( utilsFunctions , < any > 'browserLanguage' ) . and . returnValue ( 'pt' ) ;
57
+ component [ 'language' ] = 'pt' ;
56
58
57
59
component . literals = { } ;
58
60
59
61
expect ( component . literals ) . toEqual ( poNavbarLiteralsDefault . pt ) ;
60
62
} ) ;
61
63
62
64
it ( 'literals: should be in english if browser is setted with `en`' , ( ) => {
63
- spyOn ( utilsFunctions , < any > 'browserLanguage' ) . and . returnValue ( 'en' ) ;
65
+ component [ 'language' ] = 'en' ;
64
66
65
67
component . literals = { } ;
66
68
67
69
expect ( component . literals ) . toEqual ( poNavbarLiteralsDefault . en ) ;
68
70
} ) ;
69
71
70
72
it ( 'literals: should be in spanish if browser is setted with `es`' , ( ) => {
71
- spyOn ( utilsFunctions , < any > 'browserLanguage' ) . and . returnValue ( 'es' ) ;
73
+ component [ 'language' ] = 'es' ;
72
74
73
75
component . literals = { } ;
74
76
75
77
expect ( component . literals ) . toEqual ( poNavbarLiteralsDefault . es ) ;
76
78
} ) ;
77
79
78
80
it ( 'literals: should be in russian if browser is setted with `ru`' , ( ) => {
79
- spyOn ( utilsFunctions , < any > 'browserLanguage' ) . and . returnValue ( 'ru' ) ;
81
+ component [ 'language' ] = 'ru' ;
80
82
81
83
component . literals = { } ;
82
84
83
85
expect ( component . literals ) . toEqual ( poNavbarLiteralsDefault . ru ) ;
84
86
} ) ;
85
87
86
88
it ( 'literals: should accept custom literals' , ( ) => {
87
- spyOn ( utilsFunctions , < any > 'browserLanguage' ) . and . returnValue ( utilsFunctions . poLocaleDefault ) ;
89
+ component [ 'language' ] = utilsFunctions . poLocaleDefault ;
88
90
89
91
const customLiterals = Object . assign ( { } , poNavbarLiteralsDefault [ utilsFunctions . poLocaleDefault ] ) ;
90
92
@@ -99,7 +101,7 @@ describe('PoNavbarBaseComponent:', () => {
99
101
it ( 'literals: should update property with default literals if is setted with invalid values' , ( ) => {
100
102
const invalidValues = [ null , undefined , false , true , '' , 'literals' , 0 , 10 , [ ] , [ 1 , 2 ] , ( ) => { } ] ;
101
103
102
- spyOn ( utilsFunctions , < any > 'browserLanguage' ) . and . returnValue ( utilsFunctions . poLocaleDefault ) ;
104
+ component [ 'language' ] = utilsFunctions . poLocaleDefault ;
103
105
104
106
expectPropertiesValues (
105
107
component ,
0 commit comments