Skip to content

Commit

Permalink
Merge pull request #3 from Jhaemis-hack/feature/included-review-stari…
Browse files Browse the repository at this point in the history
…ng-func

"fix: included review repository in product test mock file"
  • Loading branch information
Jhaemis-hack authored Mar 1, 2025
2 parents 5e37559 + a1b3bd1 commit dccab25
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
1 change: 0 additions & 1 deletion src/modules/products/products.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import { INVALID_ORG_ID, INVALID_PRODUCT_ID } from '@shared/constants/SystemMess
import { CustomHttpException } from '@shared/helpers/custom-http-filter';
import { SuperAdminGuard } from '@guards/super-admin.guard';


@ApiTags('Products')
@Controller('')
export class ProductsController {
Expand Down
11 changes: 11 additions & 0 deletions src/modules/products/tests/products.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@ import { mockComment } from './mocks/comment.mock';
import { deletedProductMock } from './mocks/deleted-product.mock';
import { createProductRequestDtoMock } from './mocks/product-request-dto.mock';
import { productMock } from './mocks/product.mock';
import { Review } from '../entities/review.entity';

describe('ProductsService', () => {
let service: ProductsService;
let productRepository: Repository<Product>;
let organisationRepository: Repository<Organisation>;
let userRepository: Repository<User>;
let commentRepository: Repository<Comment>;
let reviewRepository: Repository<Review>;

beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
Expand Down Expand Up @@ -58,6 +60,15 @@ describe('ProductsService', () => {
save: jest.fn(),
},
},
{
provide: getRepositoryToken(Review), // ✅ Added the missing ReviewRepository correctly
useValue: {
createQueryBuilder: jest.fn(), // Optional — mock these if Review is used in queries
findOne: jest.fn(),
save: jest.fn(),
create: jest.fn(),
},
},
{
provide: getRepositoryToken(User),
useClass: Repository,
Expand Down

0 comments on commit dccab25

Please sign in to comment.