1717 * under the License.
1818 */
1919
20- import { getKibanaTranslationFilesMock , initTranslationsMock } from './i18n_service.test.mocks' ;
20+ import {
21+ getKibanaTranslationFilesMock ,
22+ initTranslationsMock ,
23+ registerRoutesMock ,
24+ } from './i18n_service.test.mocks' ;
2125
2226import { BehaviorSubject } from 'rxjs' ;
2327import { I18nService } from './i18n_service' ;
2428
2529import { configServiceMock } from '../config/mocks' ;
2630import { mockCoreContext } from '../core_context.mock' ;
31+ import { httpServiceMock } from '../http/http_service.mock' ;
2732
2833const getConfigService = ( locale = 'en' ) => {
2934 const configService = configServiceMock . create ( ) ;
@@ -41,21 +46,24 @@ const getConfigService = (locale = 'en') => {
4146describe ( 'I18nService' , ( ) => {
4247 let service : I18nService ;
4348 let configService : ReturnType < typeof configServiceMock . create > ;
49+ let http : ReturnType < typeof httpServiceMock . createInternalSetupContract > ;
4450
4551 beforeEach ( ( ) => {
4652 jest . clearAllMocks ( ) ;
4753 configService = getConfigService ( ) ;
4854
4955 const coreContext = mockCoreContext . create ( { configService } ) ;
5056 service = new I18nService ( coreContext ) ;
57+
58+ http = httpServiceMock . createInternalSetupContract ( ) ;
5159 } ) ;
5260
5361 describe ( '#setup' , ( ) => {
5462 it ( 'calls `getKibanaTranslationFiles` with the correct parameters' , async ( ) => {
5563 getKibanaTranslationFilesMock . mockResolvedValue ( [ ] ) ;
5664
5765 const pluginPaths = [ '/pathA' , '/pathB' ] ;
58- await service . setup ( { pluginPaths } ) ;
66+ await service . setup ( { pluginPaths, http } ) ;
5967
6068 expect ( getKibanaTranslationFilesMock ) . toHaveBeenCalledTimes ( 1 ) ;
6169 expect ( getKibanaTranslationFilesMock ) . toHaveBeenCalledWith ( 'en' , pluginPaths ) ;
@@ -65,17 +73,27 @@ describe('I18nService', () => {
6573 const translationFiles = [ '/path/to/file' , 'path/to/another/file' ] ;
6674 getKibanaTranslationFilesMock . mockResolvedValue ( translationFiles ) ;
6775
68- await service . setup ( { pluginPaths : [ ] } ) ;
76+ await service . setup ( { pluginPaths : [ ] , http } ) ;
6977
7078 expect ( initTranslationsMock ) . toHaveBeenCalledTimes ( 1 ) ;
7179 expect ( initTranslationsMock ) . toHaveBeenCalledWith ( 'en' , translationFiles ) ;
7280 } ) ;
7381
82+ it ( 'calls `registerRoutesMock` with the correct parameters' , async ( ) => {
83+ await service . setup ( { pluginPaths : [ ] , http } ) ;
84+
85+ expect ( registerRoutesMock ) . toHaveBeenCalledTimes ( 1 ) ;
86+ expect ( registerRoutesMock ) . toHaveBeenCalledWith ( {
87+ locale : 'en' ,
88+ router : expect . any ( Object ) ,
89+ } ) ;
90+ } ) ;
91+
7492 it ( 'returns accessors for locale and translation files' , async ( ) => {
7593 const translationFiles = [ '/path/to/file' , 'path/to/another/file' ] ;
7694 getKibanaTranslationFilesMock . mockResolvedValue ( translationFiles ) ;
7795
78- const { getLocale, getTranslationFiles } = await service . setup ( { pluginPaths : [ ] } ) ;
96+ const { getLocale, getTranslationFiles } = await service . setup ( { pluginPaths : [ ] , http } ) ;
7997
8098 expect ( getLocale ( ) ) . toEqual ( 'en' ) ;
8199 expect ( getTranslationFiles ( ) ) . toEqual ( translationFiles ) ;
0 commit comments