// import { HttpService } from "@nestjs/axios";
// import { ConfigModule } from "@nestjs/config";
// import { Test } from "@nestjs/testing";
// import exp from "constants";
// import { of } from "rxjs";
// import { EsTime } from "src/core/domain/enums/es-time.enum";
// import { HttpResponseException } from "src/core/exceptions";
// import { SearchService } from "src/core/services/common/search.service";

// describe('Unit tests for SearchService', () => {
//     let searchService: SearchService;
//     let httpService: HttpService;


//     beforeAll(async () => {
//         const moduleRef = await Test.createTestingModule({
//             providers: [
//                 SearchService,
//                 {
//                     provide: HttpService,
//                     useValue: {
//                         post: jest.fn(),
//                     },
//                 },
//             ],
//             imports: [
//                 ConfigModule.forRoot({
//                 isGlobal: true,
//                 cache: true,
//                 expandVariables: true,
//                 })
//             ],
//         }).compile();

//         searchService = moduleRef.get(SearchService);
//         httpService = moduleRef.get(HttpService);
//     });

//     describe('getPIT()', () => {
//         it('Should touch HttpService.post() method', () => {
//             let postMock = jest.spyOn(httpService, 'post').mockReturnValue(of({
//                 data: {id: '2567'},
//                 status: 0,
//                 statusText: '',
//                 headers: {},
//                 config: {},
//             }));

//             searchService.getPIT(1);
//             expect(postMock).toHaveBeenCalled();
//         });

//         it('Should contain correct port in the URI from .env', () => {
//             let postMock = jest.spyOn(httpService, 'post').mockReturnValue(of({
//                 data: {id: '2567'},
//                 status: 0,
//                 statusText: '',
//                 headers: {},
//                 config: {},
//             }));

//             searchService.getPIT(1);
//             expect(postMock).toHaveBeenCalledWith(`http://localhost:${process.env.ES_PORT}/papers/_pit?keep_alive=1m`);
//         });

//         it('Should touch HttpService with correct URI when time alive and time-unit are set', () => {
//             let postMock = jest.spyOn(httpService, 'post').mockReturnValue(of({
//                 data: {id: '2567'},
//                 status: 0,
//                 statusText: '',
//                 headers: {},
//                 config: {},
//             }));

//             let time = 2;
//             let unit = EsTime.sec;
            
//             searchService.getPIT(time, unit);
//             expect(postMock).toHaveBeenCalledWith(`http://localhost:${process.env.ES_PORT}/papers/_pit?keep_alive=${time+unit}`);
//         });

//         it('Should return error exeception when HttpService fails', () => {
//             jest.spyOn(httpService, 'post').mockImplementation(() => {
//                 throw HttpResponseException;
//             });

//             expect(searchService.getPIT(1)).rejects.toEqual(HttpResponseException);
//         });

//         it('Should return a non-empty string when HttpService request succeedes', () => {
//             jest.spyOn(httpService, 'post').mockReturnValue(of({
//                 data: {id: '2567', keep_alive: '1m'},
//                 status: 0,
//                 statusText: '',
//                 headers: {},
//                 config: {},
//             }));

//             expect(searchService.getPIT(1)).resolves.toEqual({
//                 id: '2567',
//                 keep_alive: '1m',
//             });
//         });


//     });

//     describe('deletePIT()', () => {
//         it.todo('Should fail to delete, because the requested PIT ID is invalid');
//         it.todo('Should call HttpService.delete() method with correct body');
//     });
// });