mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-19 22:30:31 +00:00
feat: wip migrate to nestjs
This commit is contained in:
82
packages/server-nest/test/customers.e2e-spec.ts
Normal file
82
packages/server-nest/test/customers.e2e-spec.ts
Normal file
@@ -0,0 +1,82 @@
|
||||
import * as request from 'supertest';
|
||||
import { faker } from '@faker-js/faker';
|
||||
import { app } from './init-app-test';
|
||||
|
||||
describe('Customers (e2e)', () => {
|
||||
it('/customers (POST)', () => {
|
||||
return request(app.getHttpServer())
|
||||
.post('/customers')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.send({
|
||||
customerType: 'business',
|
||||
displayName: faker.commerce.productName(),
|
||||
email: faker.internet.email(),
|
||||
firstName: faker.person.firstName(),
|
||||
lastName: faker.person.lastName(),
|
||||
})
|
||||
.expect(201);
|
||||
});
|
||||
|
||||
it('/customers/:id (GET)', async () => {
|
||||
const response = await request(app.getHttpServer())
|
||||
.post('/customers')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.send({
|
||||
customerType: 'business',
|
||||
displayName: faker.commerce.productName(),
|
||||
email: faker.internet.email(),
|
||||
firstName: faker.person.firstName(),
|
||||
lastName: faker.person.lastName(),
|
||||
});
|
||||
const customerId = response.body.id;
|
||||
|
||||
return request(app.getHttpServer())
|
||||
.get(`/customers/${customerId}`)
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.expect(200);
|
||||
});
|
||||
|
||||
it('/customers/:id (DELETE)', async () => {
|
||||
const response = await request(app.getHttpServer())
|
||||
.post('/customers')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.send({
|
||||
customerType: 'business',
|
||||
displayName: faker.commerce.productName(),
|
||||
email: faker.internet.email(),
|
||||
firstName: faker.person.firstName(),
|
||||
lastName: faker.person.lastName(),
|
||||
});
|
||||
const customerId = response.body.id;
|
||||
|
||||
return request(app.getHttpServer())
|
||||
.delete(`/customers/${customerId}`)
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.expect(200);
|
||||
});
|
||||
|
||||
it('/customers/:id (PUT)', async () => {
|
||||
const response = await request(app.getHttpServer())
|
||||
.post('/customers')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.send({
|
||||
customerType: 'business',
|
||||
displayName: faker.commerce.productName(),
|
||||
email: faker.internet.email(),
|
||||
firstName: faker.person.firstName(),
|
||||
lastName: faker.person.lastName(),
|
||||
});
|
||||
const customerId = response.body.id;
|
||||
|
||||
return request(app.getHttpServer())
|
||||
.put(`/customers/${customerId}`)
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.send({
|
||||
displayName: faker.commerce.productName(),
|
||||
email: faker.internet.email(),
|
||||
firstName: faker.person.firstName(),
|
||||
lastName: faker.person.lastName(),
|
||||
})
|
||||
.expect(200);
|
||||
});
|
||||
});
|
||||
33
packages/server-nest/test/sale-invoices.e2e-spec.ts
Normal file
33
packages/server-nest/test/sale-invoices.e2e-spec.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import * as request from 'supertest';
|
||||
import { faker } from '@faker-js/faker';
|
||||
import { app } from './init-app-test';
|
||||
|
||||
describe('Sale Invoices (e2e)', () => {
|
||||
it('/sale-invoices (POST)', () => {
|
||||
return request(app.getHttpServer())
|
||||
.post('/sale-invoices')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.send({
|
||||
customerId: 2,
|
||||
invoiceDate: '2023-01-01',
|
||||
dueDate: '2023-02-01',
|
||||
invoiceNo: 'INV-002005',
|
||||
referenceNo: 'REF-000201',
|
||||
delivered: true,
|
||||
discountType: 'percentage',
|
||||
discount: 10,
|
||||
branchId: 1,
|
||||
warehouseId: 1,
|
||||
entries: [
|
||||
{
|
||||
index: 1,
|
||||
itemId: 1001,
|
||||
quantity: 2,
|
||||
rate: 1000,
|
||||
description: 'Item description...',
|
||||
},
|
||||
],
|
||||
})
|
||||
.expect(201);
|
||||
});
|
||||
});
|
||||
80
packages/server-nest/test/sale-receipts.e2e-spec.ts
Normal file
80
packages/server-nest/test/sale-receipts.e2e-spec.ts
Normal file
@@ -0,0 +1,80 @@
|
||||
import * as request from 'supertest';
|
||||
import { faker } from '@faker-js/faker';
|
||||
import { app } from './init-app-test';
|
||||
|
||||
const receiptRequest = {
|
||||
customerId: 2,
|
||||
depositAccountId: 1000,
|
||||
receiptDate: '2022-02-02',
|
||||
referenceNo: '123',
|
||||
receiptNumber: faker.string.uuid(),
|
||||
branchId: 1,
|
||||
warehouseId: 1,
|
||||
discount: 100,
|
||||
discountType: 'amount',
|
||||
entries: [
|
||||
{
|
||||
index: 1,
|
||||
itemId: 1001,
|
||||
quantity: 1,
|
||||
rate: 2000,
|
||||
description: 'asdfsadf',
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
describe('Sale Receipts (e2e)', () => {
|
||||
it('/sale-reeipts (POST)', () => {
|
||||
return request(app.getHttpServer())
|
||||
.post('/sale-receipts')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.send(receiptRequest)
|
||||
.expect(201);
|
||||
});
|
||||
|
||||
it('/sale-receipts/:id (DELETE)', async () => {
|
||||
const response = await request(app.getHttpServer())
|
||||
.post('/sale-receipts')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.send(receiptRequest);
|
||||
|
||||
const receiptId = response.body.id;
|
||||
|
||||
return request(app.getHttpServer())
|
||||
.delete(`/sale-receipts/${receiptId}`)
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.send();
|
||||
});
|
||||
|
||||
it('/sale-receipts/:id (PUT)', async () => {
|
||||
const response = await request(app.getHttpServer())
|
||||
.post('/sale-receipts')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.send(receiptRequest);
|
||||
|
||||
const receiptId = response.body.id;
|
||||
|
||||
return request(app.getHttpServer())
|
||||
.delete(`/sale-receipts/${receiptId}`)
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.send({
|
||||
...receiptRequest,
|
||||
referenceNo: '321',
|
||||
})
|
||||
.expect(200);
|
||||
});
|
||||
|
||||
it('/sale-receipts/:id (GET)', async () => {
|
||||
const response = await request(app.getHttpServer())
|
||||
.post('/sale-receipts')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.send(receiptRequest);
|
||||
|
||||
const receiptId = response.body.id;
|
||||
|
||||
return request(app.getHttpServer())
|
||||
.get(`/sale-receipts/${receiptId}`)
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.expect(200);
|
||||
});
|
||||
});
|
||||
75
packages/server-nest/test/vendors.e2e-spec.ts
Normal file
75
packages/server-nest/test/vendors.e2e-spec.ts
Normal file
@@ -0,0 +1,75 @@
|
||||
import * as request from 'supertest';
|
||||
import { faker } from '@faker-js/faker';
|
||||
import { app } from './init-app-test';
|
||||
|
||||
describe('Vendors (e2e)', () => {
|
||||
it('/vendors (POST)', () => {
|
||||
return request(app.getHttpServer())
|
||||
.post('/vendors')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.send({
|
||||
displayName: faker.commerce.productName(),
|
||||
email: faker.internet.email(),
|
||||
firstName: faker.person.firstName(),
|
||||
lastName: faker.person.lastName(),
|
||||
})
|
||||
.expect(201);
|
||||
});
|
||||
|
||||
it('/vendors/:id (PUT)', async () => {
|
||||
const response = await request(app.getHttpServer())
|
||||
.post('/vendors')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.send({
|
||||
displayName: faker.commerce.productName(),
|
||||
email: faker.internet.email(),
|
||||
firstName: faker.person.firstName(),
|
||||
lastName: faker.person.lastName(),
|
||||
});
|
||||
const vendorId = response.body.id;
|
||||
|
||||
return request(app.getHttpServer())
|
||||
.put(`/vendors/${vendorId}`)
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.send({
|
||||
displayName: faker.commerce.productName(),
|
||||
email: faker.internet.email(),
|
||||
firstName: faker.person.firstName(),
|
||||
lastName: faker.person.lastName(),
|
||||
})
|
||||
.expect(200);
|
||||
});
|
||||
|
||||
it('/vendors/:id (GET)', async () => {
|
||||
const response = await request(app.getHttpServer())
|
||||
.post('/vendors')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.send({
|
||||
displayName: faker.commerce.productName(),
|
||||
email: faker.internet.email(),
|
||||
firstName: faker.person.firstName(),
|
||||
lastName: faker.person.lastName(),
|
||||
});
|
||||
const vendorId = response.body.id;
|
||||
|
||||
return request(app.getHttpServer())
|
||||
.get(`/vendors/${vendorId}`)
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.expect(200);
|
||||
});
|
||||
|
||||
it('/vendors/:id (DELETE)', async () => {
|
||||
const response = await request(app.getHttpServer())
|
||||
.post('/vendors')
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.send({
|
||||
displayName: faker.commerce.productName(),
|
||||
});
|
||||
const vendorId = response.body.id;
|
||||
|
||||
return request(app.getHttpServer())
|
||||
.delete(`/vendors/${vendorId}`)
|
||||
.set('organization-id', '4064541lv40nhca')
|
||||
.expect(200);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user