refactor: warehouses to nestjs

This commit is contained in:
Ahmed Bouhuolia
2024-12-21 15:07:01 +02:00
parent cb8fd68d46
commit 8a12caf48d
29 changed files with 348 additions and 100 deletions

View File

@@ -0,0 +1,71 @@
import * as request from 'supertest';
import { faker } from '@faker-js/faker';
import { app } from './init-app-test';
describe('Branches (e2e)', () => {
it('/branches (POST)', () => {
return request(app.getHttpServer())
.post('/branches')
.set('organization-id', '4064541lv40nhca')
.send({
name: faker.commerce.productName(),
code: faker.string.alpha(4),
})
.expect(201);
});
it('/branches/:id (DELETE)', async () => {
const response = await request(app.getHttpServer())
.post('/branches')
.set('organization-id', '4064541lv40nhca')
.send({
name: faker.commerce.productName(),
code: faker.string.alpha(4),
});
const branchId = response.body.id;
return request(app.getHttpServer())
.delete(`/branches/${branchId}`)
.set('organization-id', '4064541lv40nhca')
.expect(200);
});
it('/branches/:id (PUT)', async () => {
const response = await request(app.getHttpServer())
.post('/branches')
.set('organization-id', '4064541lv40nhca')
.send({
name: faker.commerce.productName(),
code: faker.string.alpha(4),
});
const branchId = response.body.id;
return request(app.getHttpServer())
.put(`/branches/${branchId}`)
.set('organization-id', '4064541lv40nhca')
.expect(200);
});
it('/branches/:id (GET)', async () => {
const response = await request(app.getHttpServer())
.post('/branches')
.set('organization-id', '4064541lv40nhca')
.send({
name: faker.commerce.productName(),
code: faker.string.alpha(4),
});
const branchId = response.body.id;
return request(app.getHttpServer())
.get(`/branches/${branchId}`)
.set('organization-id', '4064541lv40nhca')
.expect(200);
});
it('/branches (GET)', async () => {
return request(app.getHttpServer())
.get('/branches')
.set('organization-id', '4064541lv40nhca')
.expect(200);
});
});