Skip to content

Commit e28a560

Browse files
committed
fix: code run fixes
1 parent 0698b6f commit e28a560

File tree

4 files changed

+23
-13
lines changed

4 files changed

+23
-13
lines changed

backend/src/converter/converter.controller.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1+
import { INestApplication } from '@nestjs/common';
12
import { Test, TestingModule } from '@nestjs/testing';
3+
import * as request from 'supertest';
24
import { ConverterController } from './converter.controller';
35
import { ConverterService } from './converter.service';
4-
import * as request from 'supertest';
5-
import { INestApplication } from '@nestjs/common';
66

77
describe('ConverterController', () => {
88
let app: INestApplication;
@@ -36,7 +36,7 @@ describe('ConverterController', () => {
3636
it('should call convertCode and return the result', async () => {
3737
const payload = { code: 'console.log(1)', from: 'js', to: 'py' };
3838
const expectedResponse = { success: true, translatedCode: 'print(1)' };
39-
39+
4040
mockConverterService.convertCode.mockResolvedValue(expectedResponse);
4141

4242
return request(app.getHttpServer())
@@ -76,4 +76,4 @@ describe('ConverterController', () => {
7676
.expect(expectedResponse);
7777
});
7878
});
79-
});
79+
});

backend/src/converter/converter.service.spec.ts

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { Test, TestingModule } from '@nestjs/testing';
2-
import { ConverterService } from './converter.service';
31
import { ChatOllama } from '@langchain/ollama';
42
import { InternalServerErrorException } from '@nestjs/common';
3+
import { Test, TestingModule } from '@nestjs/testing';
4+
import { ConverterService } from './converter.service';
55

66
// Mock the LangChain Ollama module
77
jest.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+
});

biome.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"dist/**",
1010
"frontend/src/main.tsx",
1111
"**/*.test.tsx",
12-
"frontend/src/App.test.tsx"
12+
"**/*.spec.ts"
1313
]
1414
},
1515
"formatter": {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"dev": "docker compose up",
1111
"dev:build": "docker compose up --build",
1212
"dev:down": "docker compose down",
13-
"test:fron": "npm run test --workspace=frontend",
13+
"test:fe": "npm run test --workspace=frontend",
1414
"test:be": "npm run test --workspace=backend",
1515
"biome:format": "biome format --write .",
1616
"biome:lint": "biome lint .",

0 commit comments

Comments
 (0)