refactor: migrate item categories to nestjs

This commit is contained in:
Ahmed Bouhuolia
2024-12-20 10:40:35 +02:00
parent 83dfaa00fd
commit 1f32a7c59a
18 changed files with 128 additions and 22 deletions

View File

@@ -0,0 +1,49 @@
import * as request from 'supertest';
import { faker } from '@faker-js/faker';
import { app } from './init-app-test';
describe('Item Categories(e2e)', () => {
it('/item-categories (POST)', () => {
return request(app.getHttpServer())
.post('/item-categories')
.set('organization-id', '4064541lv40nhca')
.send({
name: faker.person.fullName(),
description: faker.lorem.sentence(),
})
.expect(201);
});
it('/item-categories/:id (GET)', async () => {
const response = await request(app.getHttpServer())
.post('/item-categories')
.set('organization-id', '4064541lv40nhca')
.send({
name: faker.person.fullName(),
description: faker.lorem.sentence(),
});
const itemCategoryId = response.body.id;
return request(app.getHttpServer())
.get(`/item-categories/${itemCategoryId}`)
.set('organization-id', '4064541lv40nhca')
.expect(200);
});
it('/item-categories/:id (DELETE)', async () => {
const response = await request(app.getHttpServer())
.post('/item-categories')
.set('organization-id', '4064541lv40nhca')
.send({
name: faker.person.fullName(),
description: faker.lorem.sentence(),
});
const itemCategoryId = response.body.id;
return request(app.getHttpServer())
.delete(`/item-categories/${itemCategoryId}`)
.set('organization-id', '4064541lv40nhca')
.expect(200);
});
});

View File

@@ -1,8 +1,5 @@
import { Test, TestingModule } from '@nestjs/testing';
import { INestApplication } from '@nestjs/common';
import * as request from 'supertest';
import { faker } from '@faker-js/faker';
import { AppModule } from '../src/modules/App/App.module';
import { app } from './init-app-test';
describe('Items (e2e)', () => {