mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-15 12:20:31 +00:00
feat: Bulk delete customers and expenses.
This commit is contained in:
@@ -10,7 +10,7 @@ import {
|
||||
} from '~/dbInit';
|
||||
|
||||
|
||||
describe.only('routes: /accounts/', () => {
|
||||
describe('routes: /accounts/', () => {
|
||||
describe('POST `/accounts`', () => {
|
||||
it('Should `name` be required.', async () => {
|
||||
const res = await request()
|
||||
@@ -190,7 +190,7 @@ describe.only('routes: /accounts/', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it.only('Should response success with correct data form.', async () => {
|
||||
it('Should response success with correct data form.', async () => {
|
||||
const account = await tenantFactory.create('account');
|
||||
const res = await request()
|
||||
.post('/api/accounts')
|
||||
|
||||
@@ -209,4 +209,42 @@ describe('route: `/customers`', () => {
|
||||
expect(foundCustomer[0].displayName).equals('Ahmed Bouhuolia, Bigcapital');
|
||||
})
|
||||
});
|
||||
|
||||
describe('DELETE: `customers`', () => {
|
||||
it('Should response customers ids not found.', async () => {
|
||||
const res = await request()
|
||||
.delete('/api/customers')
|
||||
.set('x-access-token', loginRes.body.token)
|
||||
.set('organization-id', tenantWebsite.organizationId)
|
||||
.query({
|
||||
ids: [100, 200],
|
||||
})
|
||||
.send();
|
||||
|
||||
expect(res.status).equals(404);
|
||||
expect(res.body.errors).include.something.deep.equals({
|
||||
type: 'CUSTOMERS.NOT.FOUND', code: 200,
|
||||
});
|
||||
});
|
||||
|
||||
it('Should delete the given customers.', async () => {
|
||||
const customer1 = await tenantFactory.create('customer');
|
||||
const customer2 = await tenantFactory.create('customer');
|
||||
|
||||
const res = await request()
|
||||
.delete('/api/customers')
|
||||
.set('x-access-token', loginRes.body.token)
|
||||
.set('organization-id', tenantWebsite.organizationId)
|
||||
.query({
|
||||
ids: [customer1.id, customer2.id],
|
||||
})
|
||||
.send();
|
||||
|
||||
const foundCustomers = await Customer.tenant().query()
|
||||
.whereIn('id', [customer1.id, customer2.id]);
|
||||
|
||||
expect(res.status).equals(200);
|
||||
expect(foundCustomers.length).equals(0);
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
@@ -678,4 +678,42 @@ describe('routes: /expenses/', () => {
|
||||
expect(foundExpenseCategory[0].amount).equals(3000);
|
||||
});
|
||||
});
|
||||
|
||||
describe('DELETE: `/api/expenses`', () => {
|
||||
it('Should response not found expenses ids.', async () => {
|
||||
const res = await request()
|
||||
.delete('/api/expenses')
|
||||
.set('x-access-token', loginRes.body.token)
|
||||
.set('organization-id', tenantWebsite.organizationId)
|
||||
.query({
|
||||
ids: [100, 200],
|
||||
})
|
||||
.send({});
|
||||
|
||||
expect(res.status).equals(404);
|
||||
expect(res.body.errors).include.something.deep.equals({
|
||||
type: 'EXPENSES.NOT.FOUND', code: 200,
|
||||
});
|
||||
});
|
||||
|
||||
it('Should delete the given expenses ids.', async () => {
|
||||
const expense1 = await tenantFactory.create('expense');
|
||||
const expense2 = await tenantFactory.create('expense');
|
||||
|
||||
const res = await request()
|
||||
.delete('/api/expenses')
|
||||
.set('x-access-token', loginRes.body.token)
|
||||
.set('organization-id', tenantWebsite.organizationId)
|
||||
.query({
|
||||
ids: [expense1.id, expense2.id],
|
||||
})
|
||||
.send({});
|
||||
|
||||
const foundExpenses = await Expense.tenant().query()
|
||||
.whereIn('id', [expense1.id, expense2.id]);
|
||||
|
||||
expect(res.status).equals(200);
|
||||
expect(foundExpenses.length).equals(0);
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user