1- import { Test , TestingModule } from '@nestjs/testing' ;
2- import { ConverterService } from './converter.service' ;
31import { ChatOllama } from '@langchain/ollama' ;
42import { InternalServerErrorException } from '@nestjs/common' ;
3+ import { Test , TestingModule } from '@nestjs/testing' ;
4+ import { ConverterService } from './converter.service' ;
55
66// Mock the LangChain Ollama module
77jest . mock ( '@langchain/ollama' , ( ) => {
@@ -37,13 +37,19 @@ describe('ConverterService', () => {
3737 const mockResponse = { content : 'print("hello")' } ;
3838 mockModel . invoke . mockResolvedValue ( mockResponse ) ;
3939
40- const result = await service . convertCode ( 'console.log("hello")' , 'js' , 'python' ) ;
40+ const result = await service . convertCode (
41+ 'console.log("hello")' ,
42+ 'js' ,
43+ 'python' ,
44+ ) ;
4145
4246 expect ( result ) . toEqual ( {
4347 success : true ,
4448 translatedCode : 'print("hello")' ,
4549 } ) ;
46- expect ( mockModel . invoke ) . toHaveBeenCalledWith ( expect . stringContaining ( 'Convert the input from js to python' ) ) ;
50+ expect ( mockModel . invoke ) . toHaveBeenCalledWith (
51+ expect . stringContaining ( 'Convert the input from js to python' ) ,
52+ ) ;
4753 } ) ;
4854 } ) ;
4955
@@ -58,13 +64,17 @@ describe('ConverterService', () => {
5864 success : true ,
5965 reviewContent : '- Use const instead of let' ,
6066 } ) ;
61- expect ( mockModel . invoke ) . toHaveBeenCalledWith ( expect . stringContaining ( 'Review the following javascript code' ) ) ;
67+ expect ( mockModel . invoke ) . toHaveBeenCalledWith (
68+ expect . stringContaining ( 'Review the following javascript code' ) ,
69+ ) ;
6270 } ) ;
6371 } ) ;
6472
6573 describe ( 'fixBugs' , ( ) => {
6674 it ( 'should return fixed code and explanation' , async ( ) => {
67- const mockResponse = { content : 'Fixed Code\nExplanation: removed error' } ;
75+ const mockResponse = {
76+ content : 'Fixed Code\nExplanation: removed error' ,
77+ } ;
6878 mockModel . invoke . mockResolvedValue ( mockResponse ) ;
6979
7080 const result = await service . fixBugs ( 'erroneous code' , 'typescript' ) ;
@@ -85,4 +95,4 @@ describe('ConverterService', () => {
8595 ) ;
8696 } ) ;
8797 } ) ;
88- } ) ;
98+ } ) ;
0 commit comments