mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-20 06:40:31 +00:00
refactor: migrate to Nestjs
This commit is contained in:
73
packages/server-nest/test/vendor-credits.e2e-spec.ts
Normal file
73
packages/server-nest/test/vendor-credits.e2e-spec.ts
Normal file
@@ -0,0 +1,73 @@
|
||||
import * as request from 'supertest';
|
||||
import { app } from './init-app-test';
|
||||
import { faker } from '@faker-js/faker';
|
||||
|
||||
const requestVendorCredit = () => ({
|
||||
vendorId: 3,
|
||||
exchangeRate: 1,
|
||||
vendorCreditNumber: faker.string.uuid(),
|
||||
vendorCreditDate: '2025-01-01',
|
||||
entries: [
|
||||
{
|
||||
index: 1,
|
||||
item_id: 1000,
|
||||
quantity: 1,
|
||||
rate: 1000,
|
||||
description: "It's description here.",
|
||||
},
|
||||
],
|
||||
branchId: 1,
|
||||
warehouseId: 1,
|
||||
});
|
||||
|
||||
describe('Vendor Credits (e2e)', () => {
|
||||
it('/vendor-credits (POST)', () => {
|
||||
return request(app.getHttpServer())
|
||||
.post('/vendor-credits')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.send(requestVendorCredit())
|
||||
.expect(201);
|
||||
});
|
||||
|
||||
it('/vendor-credits/:id (DELETE)', async () => {
|
||||
const response = await request(app.getHttpServer())
|
||||
.post('/vendor-credits')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.send(requestVendorCredit());
|
||||
|
||||
const vendorCreditId = response.body.id;
|
||||
|
||||
return request(app.getHttpServer())
|
||||
.delete(`/vendor-credits/${vendorCreditId}`)
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.expect(200);
|
||||
});
|
||||
|
||||
it('/vendor-credits/:id/open (POST)', async () => {
|
||||
const response = await request(app.getHttpServer())
|
||||
.post('/vendor-credits')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.send(requestVendorCredit());
|
||||
|
||||
const vendorCreditId = response.body.id;
|
||||
|
||||
return request(app.getHttpServer())
|
||||
.put(`/vendor-credits/${vendorCreditId}/open`)
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.expect(200);
|
||||
});
|
||||
|
||||
it('/vendor-credits/:id (GET)', async () => {
|
||||
const response = await request(app.getHttpServer())
|
||||
.post('/vendor-credits')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.send(requestVendorCredit());
|
||||
|
||||
const vendorCreditId = response.body.id;
|
||||
|
||||
return request(app.getHttpServer())
|
||||
.get(`/vendor-credits/${vendorCreditId}`)
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.expect(200);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user