36 lines
1.1 KiB
TypeScript
36 lines
1.1 KiB
TypeScript
|
import { Test, TestingModule } from '@nestjs/testing';
|
||
|
import { TimezoneFinder } from '../../../../adapters/secondaries/timezone-finder';
|
||
|
import { GeoTimezoneFinder } from '../../../../../geography/adapters/secondaries/geo-timezone-finder';
|
||
|
|
||
|
const mockGeoTimezoneFinder = {
|
||
|
timezones: jest.fn().mockImplementation(() => ['Europe/Paris']),
|
||
|
};
|
||
|
|
||
|
describe('Timezone Finder', () => {
|
||
|
let timezoneFinder: TimezoneFinder;
|
||
|
|
||
|
beforeAll(async () => {
|
||
|
const module: TestingModule = await Test.createTestingModule({
|
||
|
imports: [],
|
||
|
providers: [
|
||
|
TimezoneFinder,
|
||
|
{
|
||
|
provide: GeoTimezoneFinder,
|
||
|
useValue: mockGeoTimezoneFinder,
|
||
|
},
|
||
|
],
|
||
|
}).compile();
|
||
|
|
||
|
timezoneFinder = module.get<TimezoneFinder>(TimezoneFinder);
|
||
|
});
|
||
|
|
||
|
it('should be defined', () => {
|
||
|
expect(timezoneFinder).toBeDefined();
|
||
|
});
|
||
|
it('should get timezone for Nancy(France) as Europe/Paris', () => {
|
||
|
const timezones = timezoneFinder.timezones(6.179373, 48.687913);
|
||
|
expect(timezones.length).toBe(1);
|
||
|
expect(timezones[0]).toBe('Europe/Paris');
|
||
|
});
|
||
|
});
|