import { Test , TestingModule } from '@nestjs/testing' ; import { EidasCountryServiceInterface } from './eidas-country.service' ; import { IEidasCountryElement } from './interfaces' ; returns { EidasCountryService } async function getServiceMock ( ) { const { EidasCountryService } = await import ( './eidas-country.service' ) ; const module = await Test . createTestingModule ( { providers : [ EidasCountryService ] , } ) . compile ( ) ; return module . get ( EidasCountryService ) ; } describe ( 'EidasCountryService' , ( ) => { let service ; const mockCountryList = [ { iso : 'iso1Value' , name : 'name1Value' , icon : 'icon1Value' , } , { iso : 'iso2Value' , name : 'name2Value' , icon : 'icon2Value' , } , ] ; beforeEach ( async ( ) => { jest . resetAllMocks ( ) ; jest . resetModules ( ) ; } ) ; it ( 'should be defined' , async ( ) => { service = await getServiceMock ( ) ; expect ( service ) . toBeDefined ( ) ; } ) ; describe ( 'getListByIso()' , ( ) => { it ( 'should get the countries list for eidas based on iso label' , async ( ) => { jest . doMock ( './data' , ( ) => ( { eidasCountryListData : mockCountryList } ) ) ; const [ firstCountry ] = mockCountryList ; service = await getServiceMock ( ) ; const result = await service . getListByIso ( [ 'iso1Value' ] ) ; expect ( result ) . toStrictEqual ( [ firstCountry ] ) ; } ) ; it ( 'should get an empty countries list' , async ( ) => { jest . doMock ( './data' , ( ) => ( { eidasCountryListData : [ ] } ) ) ; service = await getServiceMock ( ) ; const result = await service . getListByIso ( [ 'iso1Value' ] ) ; expect ( result ) . toStrictEqual ( [ ] ) ; } ) ; } ) ; } ) ;