mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-17 13:20:31 +00:00
56 lines
1.7 KiB
JavaScript
56 lines
1.7 KiB
JavaScript
import { request, expect, create } from '~/testInit';
|
|
|
|
describe('routes: `/accountOpeningBalance`', () => {
|
|
describe('POST `/accountOpeningBalance`', () => {
|
|
it('Should `accounts` be array type.', async () => {
|
|
const res = await request().post('/api/accountOpeningBalance').send({
|
|
accounts: 1000,
|
|
});
|
|
|
|
expect(res.status).equals(422);
|
|
expect(res.body.code).equals('VALIDATION_ERROR');
|
|
});
|
|
|
|
it('Should `accounts.*.id` be integer', async () => {
|
|
const res = await request().post('/api/accountOpeningBalance').send({
|
|
accounts: 1000,
|
|
});
|
|
|
|
expect(res.status).equals(422);
|
|
expect(res.body.code).equals('VALIDATION_ERROR');
|
|
});
|
|
|
|
it('Should `accounts.*.debit` be numeric.', async () => {
|
|
const res = await request().post('/api/accountOpeningBalance').send({
|
|
accounts: [{ id: 'id' }],
|
|
});
|
|
|
|
expect(res.status).equals(422);
|
|
});
|
|
|
|
it('Should `accounts.*.id` be exist in the storage.', async () => {
|
|
const res = await request().post('/api/accountOpeningBalance').send({
|
|
accounts: [
|
|
{ id: 100, credit: 100, debit: 100 },
|
|
],
|
|
});
|
|
|
|
expect(res.status).equals(422);
|
|
expect(res.body.errors).include.something.that.deep.equals({
|
|
type: 'NOT_FOUND_ACCOUNT', code: 100, ids: [100],
|
|
});
|
|
});
|
|
|
|
it('Should store the given credit and debit to the account balance in the storage.', async () => {
|
|
const account = await create('account');
|
|
const res = await request().post('/api/accountOpeningBalance').send({
|
|
accounts: [
|
|
{ id: account.id, credit: 100, debit: 2 },
|
|
],
|
|
});
|
|
|
|
console.log(res.status);
|
|
});
|
|
});
|
|
});
|