mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-17 21:30:31 +00:00
WIP Metadata class.
This commit is contained in:
44
server/tests/routes/accountOpeningBalance.test.js
Normal file
44
server/tests/routes/accountOpeningBalance.test.js
Normal file
@@ -0,0 +1,44 @@
|
||||
import { request, expect } from '~/testInit';
|
||||
|
||||
describe.only('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.only('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],
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user