Files
bigcapital/server/tests/routes/accountOpeningBalance.test.js
2019-09-08 02:41:46 +02:00

45 lines
1.3 KiB
JavaScript

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],
});
});
});
});