default params provider tests

This commit is contained in:
sbriat 2023-08-22 11:30:40 +02:00
parent b7bfdf6757
commit c45e5c94e5
1 changed files with 48 additions and 0 deletions

View File

@ -0,0 +1,48 @@
import { DefaultParams } from '@modules/geography/core/application/types/default-params.type';
import { DefaultParamsProvider } from '@modules/geography/infrastructure/default-params-provider';
import { ConfigService } from '@nestjs/config';
import { Test, TestingModule } from '@nestjs/testing';
const mockConfigService = {
get: jest.fn().mockImplementation((value: string) => {
switch (value) {
case 'GEOROUTER_TYPE':
return 'graphhopper';
case 'GEOROUTER_URL':
return 'http://localhost:8989';
default:
return 'some_default_value';
}
}),
};
describe('DefaultParamsProvider', () => {
let defaultParamsProvider: DefaultParamsProvider;
beforeAll(async () => {
const module: TestingModule = await Test.createTestingModule({
imports: [],
providers: [
DefaultParamsProvider,
{
provide: ConfigService,
useValue: mockConfigService,
},
],
}).compile();
defaultParamsProvider = module.get<DefaultParamsProvider>(
DefaultParamsProvider,
);
});
it('should be defined', () => {
expect(defaultParamsProvider).toBeDefined();
});
it('should provide default params', async () => {
const params: DefaultParams = defaultParamsProvider.getParams();
expect(params.GEOROUTER_TYPE).toBe('graphhopper');
expect(params.GEOROUTER_URL).toBe('http://localhost:8989');
});
});