import { Injectable } from '@angular/core' ; import { jest } from '@jest/globals' ; import { I18NextLoadResult } from '../../lib/I18NextLoadResult' ; import { ITranslationEvents } from '../../lib/ITranslationEvents' ; import { ITranslationService } from '../../lib/ITranslationService' ; @ Injectable ( ) export class MockI18NextService implements ITranslationService { events : ITranslationEvents ; language : string = '' ; languages : string [ ] = [ ] ; private i18nextPromise : Promise < void > ; get options ( ) : any { return { keySeparator : '.' , nsSeparator : ':' } ; } public use ( plugin ) { return this ; } public init ( options ? ) { options = options || { } ; return new Promise < any > ( ( resolve , reject ) => { resolve ( null ) ; } ) ; } public t = jest . spyOn ( this , 't' ) . mockImplementation ( ( ( key , options ? ) : string => { if ( key instanceof Array ) { return key . length > 0 ? key [ 0 ] : '' ; } return key ; } ) ) ; public format = jest . spyOn ( this , 'format' ) . and . callFake ( ( value , format , lng ) : string => { if ( ! value ) return value ; if ( format === 'cap' ) { return value [ 0 ] . toUpperCase ( ) + value . substring ( 1 ) ; } return value ; } ) ; public changeLanguage ( lng ) { return new Promise < any > ( ( resolve , reject ) => { this . language = lng ; resolve ( this . language ) ; } ) ; } public loadNamespaces ( namespaces ) { return new Promise < any > ( ( resolve , reject ) => { resolve ( ) ; } ) ; } exists ( key , options ) { return true ; } getFixedT ( lng , ns ) { return null ; } setDefaultNamespace ( ns ) { } dir ( lng ) { return 'ltr' ; } reloadResources ( ... params ) { } getResource ( lng , ns , key , options ) { return null ; } addResource ( lng , ns , key , value , options ) { } addResources ( lng , ns , resources ) { } addResourceBundle ( lng , ns , resources , deep , overwrite ) { } hasResourceBundle ( lng , ns ) { return true ; } getResourceBundle ( lng , ns ) { return null ; } removeResourceBundle ( lng , ns ) { } }